Zack Williams | 98fe232 | 2021-09-20 15:02:11 -0700 | [diff] [blame^] | 1 | Documentation Guide |
| 2 | =================== |
| 3 | |
| 4 | Writing Documentation |
| 5 | --------------------- |
| 6 | |
| 7 | Docs are generated using :doc:`Sphinx <sphinx:usage/index>`. |
| 8 | |
| 9 | Documentation is written in :doc:`reStructuredText |
| 10 | <sphinx:usage/restructuredtext/basics>` - see this link for the basic format. |
| 11 | |
| 12 | In reStructuredText documents, to create the section hierarchy (mapped in HTML |
| 13 | to ``<h1>`` through ``<h5>``) use these characters to underline headings in the |
| 14 | order given: ``=``, ``-`` ``"``, ``'``, ``^``. |
| 15 | |
| 16 | Referencing other Documentation |
| 17 | ------------------------------- |
| 18 | |
| 19 | Other Sphinx-built documentation, both ONF and non-ONF can be linked to using |
| 20 | :doc:`Intersphinx <sphinx:usage/extensions/intersphinx>`. |
| 21 | |
| 22 | You can see all link targets available on a remote Sphinx's docs by running:: |
| 23 | |
| 24 | python -msphinx.ext.intersphinx http://otherdocs/objects.inv |
| 25 | |
| 26 | Building the Docs |
| 27 | ------------------ |
| 28 | |
| 29 | The documentation build process is stored in the ``Makefile``. Building docs |
| 30 | requires Python to be installed, and most steps will create a virtualenv |
| 31 | (``venv_docs``) which contains the required tools. You may also need to |
| 32 | install the ``enchant`` C library using your system's package manager for the |
| 33 | spelling checker to function properly. |
| 34 | |
| 35 | Run ``make html`` to generate html documentation in ``_build/html``. |
| 36 | |
| 37 | To check the formatting of documentation, run ``make lint``. This will be done |
| 38 | in Jenkins to validate the documentation, so please do this before you create a |
| 39 | patchset. |
| 40 | |
| 41 | To check spelling, run ``make spelling``. If there are additional words that |
| 42 | are correctly spelled but not in the dictionary (acronyms, trademarks, etc.) |
| 43 | please add them to the ``dict.txt`` file. |
| 44 | |
| 45 | Creating new Versions of Docs |
| 46 | ----------------------------- |
| 47 | |
| 48 | To change the version shown on the built site, change the contents of the |
| 49 | ``VERSION`` file. |
| 50 | |
| 51 | There is a ``make multiversion`` target which will build all versions published |
| 52 | on the remote to ``_build``. This will use `sphinx-multiversion |
| 53 | <https://github.com/Holzhaus/sphinx-multiversion>`_ to build multiple versions |
| 54 | of the site. |
| 55 | |
| 56 | Adding Images and Diagrams |
| 57 | -------------------------- |
| 58 | |
| 59 | There are multiple ways to add images and diagrams to the documentation. |
| 60 | Generally, you should prefer using `SVG |
| 61 | <https://en.wikipedia.org/wiki/Scalable_Vector_Graphics>`_ images, as these can |
| 62 | be scaled to any size without quality loss. |
| 63 | |
| 64 | If you're creating diagrams, there are multiple tools available. |
| 65 | :doc:`Graphviz <sphinx:usage/extensions/graphviz>` can render inline text-based |
| 66 | graphs definitions and diagrams within the documentation, and is best for |
| 67 | simple diagrams. |
| 68 | |
| 69 | More complex diagrams can be created in `Diagrams.net/Draw.io |
| 70 | <https://www.diagrams.net/>`_ format. When saving these diagrams, use the |
| 71 | SVG format, and check the "Include a copy of my diagram". This will let |
| 72 | someone open the SVG later directly from the documentation and edit it, without |
| 73 | any loss in functionality or quality. |
| 74 | |
| 75 | The last resort is to use raster images. If they're drawings or screen |
| 76 | captures, use the `PNG |
| 77 | <https://en.wikipedia.org/wiki/Portable_Network_Graphics>`_ format. Consider |
| 78 | compressing them with a tool like `OptiPNG <http://optipng.sourceforge.net/>`_, |
| 79 | or `pngquant <https://pngquant.org/>`_. If it's a photograph, use `JPEG |
| 80 | <https://en.wikipedia.org/wiki/JPEG>`_. |