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