3 DPDK Documentation Guidelines
4 =============================
6 This document outlines the guidelines for writing the DPDK Guides and API documentation in RST and Doxygen format.
8 It also explains the structure of the DPDK documentation and shows how to build the Html and PDF versions of the documents.
11 Structure of the Documentation
12 ------------------------------
14 The DPDK source code repository contains input files to build the API documentation and User Guides.
16 The main directories that contain files related to documentation are shown below::
41 The API documentation is built from `Doxygen <http://www.stack.nl/~dimitri/doxygen/>`_ comments in the header files.
42 These files are mainly in the ``lib/librte_*`` directories although some of the Poll Mode Drivers in ``drivers/net``
43 are also documented with Doxygen.
45 The configuration files that are used to control the Doxygen output are in the ``doc/api`` directory.
47 The user guides such as *The Programmers Guide* and the *FreeBSD* and *Linux Getting Started* Guides are generated
48 from RST markup text files using the `Sphinx <http://sphinx-doc.org/index.html>`_ Documentation Generator.
50 These files are included in the ``doc/guides/`` directory.
51 The output is controlled by the ``doc/guides/conf.py`` file.
54 Role of the Documentation
55 -------------------------
57 The following items outline the roles of the different parts of the documentation and when they need to be updated or
58 added to by the developer.
62 The Release Notes document which features have been added in the current and previous releases of DPDK and highlight
64 The Releases Notes also contain notifications of features that will change ABI compatibility in the next major release.
66 Developers should update the Release Notes to add a short description of new or updated features.
67 Developers should also update the Release Notes to add ABI announcements if necessary,
68 (see :doc:`/guidelines/versioning` for details).
70 * **API documentation**
72 The API documentation explains how to use the public DPDK functions.
73 The `API index page <http://dpdk.org/doc/api/>`_ shows the generated API documentation with related groups of functions.
75 The API documentation should be updated via Doxygen comments when new functions are added.
77 * **Getting Started Guides**
79 The Getting Started Guides show how to install and configure DPDK and how to run DPDK based applications on different OSes.
81 A Getting Started Guide should be added when DPDK is ported to a new OS.
83 * **The Programmers Guide**
85 The Programmers Guide explains how the API components of DPDK such as the EAL, Memzone, Rings and the Hash Library work.
86 It also explains how some higher level functionality such as Packet Distributor, Packet Framework and KNI work.
87 It also shows the build system and explains how to add applications.
89 The Programmers Guide should be expanded when new functionality is added to DPDK.
93 The app guides document the DPDK applications in the ``app`` directory such as ``testpmd``.
95 The app guides should be updated if functionality is changed or added.
97 * **Sample App Guides**
99 The sample app guides document the DPDK example applications in the examples directory.
100 Generally they demonstrate a major feature such as L2 or L3 Forwarding, Multi Process or Power Management.
101 They explain the purpose of the sample application, how to run it and step through some of the code to explain the
104 A new sample application should be accompanied by a new sample app guide.
105 The guide for the Skeleton Forwarding app is a good starting reference.
107 * **Network Interface Controller Drivers**
109 The NIC Drivers document explains the features of the individual Poll Mode Drivers, such as software requirements,
110 configuration and initialization.
112 New documentation should be added for new Poll Mode Drivers.
116 The guideline documents record community process, expectations and design directions.
118 They can be extended, amended or discussed by submitting a patch and getting community approval.
121 Building the Documentation
122 --------------------------
128 The following dependencies must be installed to build the documentation:
132 * Sphinx (also called python-sphinx).
134 * TexLive (at least TexLive-core, extra Latex support and extra fonts).
138 `Doxygen`_ generates documentation from commented source code.
139 It can be installed as follows:
141 .. code-block:: console
144 sudo apt-get -y install doxygen
147 sudo yum -y install doxygen
149 `Sphinx`_ is a Python documentation tool for converting RST files to Html or to PDF (via LaTeX).
150 It can be installed as follows:
152 .. code-block:: console
155 sudo apt-get -y install python-sphinx
158 sudo yum -y install python-sphinx
160 # Or, on any system with Python installed.
161 sudo easy_install -U sphinx
163 For further information on getting started with Sphinx see the `Sphinx Tutorial <http://sphinx-doc.org/tutorial.html>`_.
167 To get full support for Figure and Table numbering it is best to install Sphinx 1.3.1 or later.
170 `Inkscape`_ is a vector based graphics program which is used to create SVG images and also to convert SVG images to PDF images.
171 It can be installed as follows:
173 .. code-block:: console
176 sudo apt-get -y install inkscape
179 sudo yum -y install inkscape
181 `TexLive <http://www.tug.org/texlive/>`_ is an installation package for Tex/LaTeX.
182 It is used to generate the PDF versions of the documentation.
183 The main required packages can be installed as follows:
185 .. code-block:: console
188 sudo apt-get -y install texlive-latex-extra texlive-fonts-extra \
189 texlive-fonts-recommended
192 # Red Hat/Fedora, selective install.
193 sudo yum -y install texlive-collection-latexextra \
194 texlive-collection-fontsextra
200 The documentation is built using the standard DPDK build system.
201 Some examples are shown below:
203 * Generate all the documentation targets::
207 * Generate the Doxygen API documentation in Html::
211 * Generate the guides documentation in Html::
215 * Generate the guides documentation in Pdf::
219 The output of these commands is generated in the ``build`` directory::
232 Make sure to fix any Sphinx or Doxygen warnings when adding or updating documentation.
234 The documentation output files can be removed as follows::
242 Here are some guidelines in relation to the style of the documentation:
244 * Document the obvious as well as the obscure since it won't always be obvious to the reader.
245 For example an instruction like "Set up 64 2MB Hugepages" is better when followed by a sample commandline or a link to
246 the appropriate section of the documentation.
248 * Use American English spellings throughout.
249 This can be checked using the ``aspell`` utility::
251 aspell --lang=en_US --check doc/guides/sample_app_ug/mydoc.rst
257 The RST (reStructuredText) format is a plain text markup format that can be converted to Html, PDF or other formats.
258 It is most closely associated with Python but it can be used to document any language.
259 It is used in DPDK to document everything apart from the API.
261 The Sphinx documentation contains a very useful `RST Primer <http://sphinx-doc.org/rest.html#rst-primer>`_ which is a
262 good place to learn the minimal set of syntax required to format a document.
264 The official `reStructuredText <http://docutils.sourceforge.net/rst.html>`_ website contains the specification for the
265 RST format and also examples of how to use it.
266 However, for most developers the RST Primer is a better resource.
268 The most common guidelines for writing RST text are detailed in the
269 `Documenting Python <https://docs.python.org/devguide/documenting.html>`_ guidelines.
270 The additional guidelines below reiterate or expand upon those guidelines.
276 * The recommended style for the DPDK documentation is to put sentences on separate lines.
277 This allows for easier reviewing of patches.
278 Multiple sentences which are not separated by a blank line are joined automatically into paragraphs, for example::
280 Here is an example sentence.
281 Long sentences over the limit shown below can be wrapped onto
283 These three sentences will be joined into the same paragraph.
285 This is a new paragraph, since it is separated from the
286 previous paragraph by a blank line.
288 This would be rendered as follows:
290 *Here is an example sentence.
291 Long sentences over the limit shown below can be wrapped onto
293 These three sentences will be joined into the same paragraph.*
295 *This is a new paragraph, since it is separated from the
296 previous paragraph by a blank line.*
299 * Long sentences should be wrapped at 120 characters +/- 10 characters. They should be wrapped at words.
301 * Lines in literal blocks must by less than 80 characters since they aren't wrapped by the document formatters
302 and can exceed the page width in PDF documents.
308 * Standard RST indentation is 3 spaces.
309 Code can be indented 4 spaces, especially if it is copied from source files.
312 Convert tabs in embedded code to 4 or 8 spaces.
314 * No trailing whitespace.
316 * Add 2 blank lines before each section header.
318 * Add 1 blank line after each section header.
320 * Add 1 blank line between each line of a list.
326 * Section headers should use the use the following underline formats::
344 * Level 4 headings should be used sparingly.
346 * The underlines should match the length of the text.
348 * In general, the heading should be less than 80 characters, for conciseness.
352 * Add 2 blank lines before each section header.
354 * Add 1 blank line after each section header.
360 * Bullet lists should be formatted with a leading ``*`` as follows::
364 * Item two is a long line that is wrapped and then indented to match
365 the start of the previous line.
367 * One space character between the bullet and the text is preferred.
369 * Numbered lists can be formatted with a leading number but the preference is to use ``#.`` which will give automatic numbering.
370 This is more convenient when adding or removing items::
374 #. Item two is a long line that is wrapped and then indented
375 to match the start of the e first line.
377 #. Item two is a long line that is wrapped and then indented to match
378 the start of the previous line.
380 * Definition lists can be written with or without a bullet::
384 Some text about item one.
388 Some text about item two.
390 * All lists, and sub-lists, must be separated from the preceding text by a blank line.
391 This is a syntax requirement.
393 * All list items should be separated by a blank line for readability.
396 Code and Literal block sections
397 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
399 * Inline text that is required to be rendered with a fixed width font should be enclosed in backquotes like this:
400 \`\`text\`\`, so that it appears like this: ``text``.
402 * Fixed width, literal blocks of texts should be indented at least 3 spaces and prefixed with ``::`` like this::
404 Here is some fixed width text::
406 0x0001 0x0001 0x00FF 0x00FF
408 * It is also possible to specify an encoding for a literal block using the ``.. code-block::`` directive so that syntax
409 highlighting can be applied.
410 Examples of supported highlighting are::
412 .. code-block:: console
414 .. code-block:: python
418 That can be applied as follows::
426 printf("Hello World\n");
431 Which would be rendered as:
439 printf("Hello World\n");
445 * The default encoding for a literal block using the simplified ``::``
446 directive is ``none``.
448 * Lines in literal blocks must be less than 80 characters since they can exceed the page width when converted to PDF documentation.
449 For long literal lines that exceed that limit try to wrap the text at sensible locations.
450 For example a long command line could be documented like this and still work if copied directly from the docs::
452 build/app/testpmd -c7 -n3 --vdev=eth_pcap0,iface=eth0 \
453 --vdev=eth_pcap1,iface=eth1 \
454 -- -i --nb-cores=2 --nb-ports=2 \
455 --total-num-mbufs=2048
457 * Long lines that cannot be wrapped, such as application output, should be truncated to be less than 80 characters.
463 * All images should be in SVG scalar graphics format.
464 They should be true SVG XML files and should not include binary formats embedded in a SVG wrapper.
466 * The DPDK documentation contains some legacy images in PNG format.
467 These will be converted to SVG in time.
469 * `Inkscape <inkscape.org>`_ is the recommended graphics editor for creating the images.
470 Use some of the older images in ``doc/guides/prog_guide/img/`` as a template, for example ``mbuf1.svg``
471 or ``ring-enqueue.svg``.
473 * The SVG images should include a copyright notice, as an XML comment.
475 * Images in the documentation should be formatted as follows:
477 * The image should be preceded by a label in the format ``.. _figure_XXXX:`` with a leading underscore and
478 where ``XXXX`` is a unique descriptive name.
480 * Images should be included using the ``.. figure::`` directive and the file type should be set to ``*`` (not ``.svg``).
481 This allows the format of the image to be changed if required, without updating the documentation.
483 * Images must have a caption as part of the ``.. figure::`` directive.
485 * Here is an example of the previous three guidelines::
489 .. figure:: img/mempool.*
491 A mempool in memory with its associated ring.
495 * Images can then be linked to using the ``:numref:`` directive::
497 The mempool layout is shown in :numref:`figure_mempool`.
499 This would be rendered as: *The mempool layout is shown in* :ref:`Fig 6.3 <mock_label>`.
501 **Note**: The ``:numref:`` directive requires Sphinx 1.3.1 or later.
502 With earlier versions it will still be rendered as a link but won't have an automatically generated number.
504 * The caption of the image can be generated, with a link, using the ``:ref:`` directive::
506 :ref:`figure_mempool`
508 This would be rendered as: *A mempool in memory with its associated ring.*
513 * RST tables should be used sparingly.
514 They are hard to format and to edit, they are often rendered incorrectly in PDF format, and the same information
515 can usually be shown just as clearly with a definition or bullet list.
517 * Tables in the documentation should be formatted as follows:
519 * The table should be preceded by a label in the format ``.. _table_XXXX:`` with a leading underscore and where
520 ``XXXX`` is a unique descriptive name.
522 * Tables should be included using the ``.. table::`` directive and must have a caption.
524 * Here is an example of the previous two guidelines::
528 .. table:: Sample configuration for QOS pipes.
530 +----------+----------+----------+
531 | Header 1 | Header 2 | Header 3 |
533 +==========+==========+==========+
534 | Text | Text | Text |
535 +----------+----------+----------+
537 +----------+----------+----------+
539 * Tables can be linked to using the ``:numref:`` and ``:ref:`` directives, as shown in the previous section for images.
542 The QOS configuration is shown in :numref:`table_qos_pipes`.
544 * Tables should not include merged cells since they are not supported by the PDF renderer.
552 * Links to external websites can be plain URLs.
553 The following is rendered as http://dpdk.org::
557 * They can contain alternative text.
558 The following is rendered as `Check out DPDK <http://dpdk.org>`_::
560 `Check out DPDK <http://dpdk.org>`_
562 * An internal link can be generated by placing labels in the document with the format ``.. _label_name``.
564 * The following links to the top of this section: :ref:`links`::
571 * The following links to the top of this section: :ref:`links`:
575 The label must have a leading underscore but the reference to it must omit it.
576 This is a frequent cause of errors and warnings.
578 * The use of a label is preferred since it works across files and will still work if the header text changes.