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