|
| 1 | +# CONTRIBUTING GUIDES |
| 2 | + |
| 3 | +Welcome and thank you for considering contributing to our project! Here |
| 4 | +we have an ecosystem of documentation tools, what helps us to deliver |
| 5 | +valuable knowledge about Python programming language to the public. |
| 6 | + |
| 7 | +Collaborating with us means delving into this, which this guide will |
| 8 | +help you navigate. From the intricacies of Sphinx to the fluidity of |
| 9 | +Mermaid diagrams, we aim to provide you with all the insights you need. |
| 10 | + |
| 11 | +Let\'s dive in! |
| 12 | + |
| 13 | +## Documentation tools |
| 14 | + |
| 15 | +[Sphinx](https://www.sphinx-doc.org/) makes it easy to create |
| 16 | +intelligent and beautiful documentation. This is the main documentation |
| 17 | +generator used on this project. There are also some 3rd-party |
| 18 | +dependencies, like `sphinxcontrib-mermaid` or `MyST markdown` installed, |
| 19 | +that makes it possible to use some extended syntax. Just install all |
| 20 | +project dependencies (including development). |
| 21 | + |
| 22 | +``` shell |
| 23 | +poetry install --with dev |
| 24 | +``` |
| 25 | + |
| 26 | +**requirements.txt** file does not split general and development deps, |
| 27 | +just do: |
| 28 | + |
| 29 | +``` shell |
| 30 | +pip install -r requirements.txt |
| 31 | +``` |
| 32 | + |
| 33 | +### Other useful tools |
| 34 | + |
| 35 | +We found [poedit](https://poedit.net/) software very useful for working |
| 36 | +with translations. It can be used for documents automatic translation, |
| 37 | +storing translation memories, proofreading etc. |
| 38 | + |
| 39 | +## Repository structure |
| 40 | + |
| 41 | + / |
| 42 | + |-- assets/ |
| 43 | + |-- src/ |
| 44 | + |-- index.txt |
| 45 | + |---- index.txt |
| 46 | + |---- <topic>/ |
| 47 | + |
| 48 | +**assets** directory contains various static content for the |
| 49 | +documentation, like CSS, images etc. |
| 50 | + |
| 51 | +**src** directory is the main documentation source, and it\'s considered |
| 52 | +to be a *content-root*. It means you may refer this directory as `/` for |
| 53 | +the Sphinx documentation builder. |
| 54 | + |
| 55 | +The **src/index.txt** is the master document. It combines all the |
| 56 | +content together. All topics are described in their own \"topic\" |
| 57 | +directories, each with its own *index.txt*. Topic index file is the |
| 58 | +`TOC (Table of Content)`{.interpreted-text role="abbr"} for the topic, |
| 59 | +and it should be added to the master TOC. |
| 60 | + |
| 61 | +### Submodules |
| 62 | + |
| 63 | +There are two major approaches in the code base organization: monorepo |
| 64 | +and multirepo. |
| 65 | + |
| 66 | +This repository uses **hybrid poly-as-mono** approach. It includes |
| 67 | +several other repositories as its submodules to glue the content from |
| 68 | +different repos together. |
| 69 | + |
| 70 | +Make sure submodules are pulled from the `devel` branch. |
| 71 | + |
| 72 | +## Documentation markup syntax |
| 73 | + |
| 74 | +The documentation build system supports: |
| 75 | + |
| 76 | +- [reStructuredText](https://docutils.sourceforge.io/rst.html) |
| 77 | +- [MarkDown](https://daringfireball.net/projects/markdown/) |
| 78 | +- [mermaid](https://mermaid.js.org/) |
| 79 | + |
| 80 | +The main documentation syntax is \"reST\", since it provides more |
| 81 | +flexibility while working with docs. |
| 82 | + |
| 83 | +### reStructuredText syntax |
| 84 | + |
| 85 | +#### Headings |
| 86 | + |
| 87 | +Here we use structure \"part \> chapter \> section \> subsection\". |
| 88 | + |
| 89 | + #### |
| 90 | + Part |
| 91 | + #### |
| 92 | + |
| 93 | + ******* |
| 94 | + Chapter |
| 95 | + ******* |
| 96 | + |
| 97 | + Section |
| 98 | + ======= |
| 99 | + |
| 100 | + Subsection |
| 101 | + ---------- |
| 102 | + |
| 103 | +All of these above will be added to |
| 104 | +`TOC (Table of Content)`{.interpreted-text role="abbr"}. In case you |
| 105 | +want to avoid this use `rubric` directive to mark a heading without |
| 106 | +adding it to the TOC. |
| 107 | + |
| 108 | + .. rubric:: Rubric heading |
| 109 | + |
| 110 | + And the content goes here. |
| 111 | + |
| 112 | +#### Mermaid diagrams |
| 113 | + |
| 114 | +The build system supports `mermaid` syntax via `.. mermaid::` directive. |
| 115 | +This is done using |
| 116 | +[sphinxcontrib-mermaid](https://pypi.org/project/sphinxcontrib-mermaid/) |
| 117 | +extension. |
| 118 | + |
| 119 | +There are two main approaches to include mermaid diagrams to the |
| 120 | +documentation: |
| 121 | + |
| 122 | +- integrate a file containing the diagram |
| 123 | + |
| 124 | + .. mermaid:: /../assets/mermaid/<path>/<file.mmd> |
| 125 | + |
| 126 | +- integrate the mermaid block itself |
| 127 | + |
| 128 | + .. mermaid:: |
| 129 | + |
| 130 | + flowchart LR |
| 131 | + id |
| 132 | + |
| 133 | +### MarkDown |
| 134 | + |
| 135 | +MarkDown is not the main markup language, but it is supported as well. |
| 136 | + |
| 137 | +#### Headings |
| 138 | + |
| 139 | +Just place a hash symbol before the heading. The number of hashes |
| 140 | +controls the heading\'s level. |
| 141 | + |
| 142 | + # Part |
| 143 | + ## Chapter |
| 144 | + ### Section |
| 145 | + #### Subsection |
| 146 | + |
| 147 | +#### Mermaid diagrams |
| 148 | + |
| 149 | +Mermaid support for MarkDown source is limited with just including |
| 150 | +mermaid blocks: |
| 151 | + |
| 152 | + ```mermaid |
| 153 | + flowchart LR |
| 154 | + id |
| 155 | + ``` |
| 156 | + |
| 157 | +## Branching |
| 158 | + |
| 159 | +### Branches explanation |
| 160 | + |
| 161 | +This repo comes with two main branches: `master` and `devel`. `master` |
| 162 | +branch contains some stable releases of the documentation, while `devel` |
| 163 | +aggregates works for the future releases. |
| 164 | + |
| 165 | +### Working with topic branch(es) |
| 166 | + |
| 167 | +We use GitFlow approach on this project. This means you would not commit |
| 168 | +to `master` or `devel` branches directly. Instead you are to create a |
| 169 | +topic branch to work with. |
| 170 | + |
| 171 | +For example, if you want to describe \"Django middleware\", you will |
| 172 | +create a new branch `[topic/|feature/]django-middleware`, and you will |
| 173 | +commit all your work to this branch. |
| 174 | + |
| 175 | +Once you consider the work is done - just open a pull request from your |
| 176 | +topic branch to `devel`. |
| 177 | + |
| 178 | +## Working with documents |
| 179 | + |
| 180 | +Do not make changes in **src** directory directly, except changes to |
| 181 | +\"conf.py\" and \"index.txt\" files. Keep your documents in dedicated |
| 182 | +topic directories instead. This project has some predefined topics |
| 183 | +already, so you can work inside of an existing topic directory. |
| 184 | + |
| 185 | +### How to add new document(s) |
| 186 | + |
| 187 | +Locate the corresponding topic and create a new text file. Use `.txt` |
| 188 | +extension for the reStructuredText documents, and `.md` for the Markdown |
| 189 | +markup. Keep filename meaningful. |
| 190 | + |
| 191 | +To attach the newly created document to the documentation builds, just |
| 192 | +add its name to the `toctree` directive content in the **index.txt** |
| 193 | +file within the appropriate topic directory. Do not add file extension |
| 194 | +while adding file to the `toctree`. |
| 195 | + |
| 196 | +In rare cases, when the new document should not be a part of any |
| 197 | +toctree, you are to `:orphan:` mark at its begging. |
| 198 | + |
| 199 | +### How to add new topic(s) |
| 200 | + |
| 201 | +Most of the topics are already present in the documents root. However, |
| 202 | +in case of need to add a new topic - you are to create a new directory |
| 203 | +inside of *src* folder. Create a file called `index.txt` within a new |
| 204 | +directory, and add it to the master doc (toctree): **src/index.txt**. |
| 205 | + |
| 206 | +### How to translate |
| 207 | + |
| 208 | +There is a target defined in Makefile to build and/or update |
| 209 | +translations called `locales`. To gather newly added or updated strings |
| 210 | +and prepare portable object files, do: |
| 211 | + |
| 212 | +``` shell |
| 213 | +make locales |
| 214 | +``` |
| 215 | + |
| 216 | +This will create/update po files in *src/\_locales* directory. Navigate |
| 217 | +to the file and perform translations. |
| 218 | + |
| 219 | +Original strings are marked as `msgid`, and the translated versions are |
| 220 | +marked as `msgstr`. |
| 221 | + |
| 222 | +Using software like [poedit](https://poedit.net/) can make the |
| 223 | +translation process more efficient. |
| 224 | + |
| 225 | +In case, you don\'t have cmake/make installed on your computer, you may |
| 226 | +use the full commands to gather the text, and prepare po file: |
| 227 | + |
| 228 | +``` shell |
| 229 | +sphinx-build -b gettext src _build/gettext |
| 230 | +sphinx-intl -c src/conf.py update -p _build/gettext |
| 231 | +``` |
| 232 | + |
| 233 | +Actually, `make locales` is the shortcut to the same set of commands. |
0 commit comments