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