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