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