David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 1 | .. _zephyr_doc: |
Inaky Perez-Gonzalez | e3683c2 | 2016-06-13 12:53:57 -0700 | [diff] [blame] | 2 | |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 3 | Zephyr documentation |
| 4 | #################### |
Rodrigo Caballero | a4a50fa | 2015-05-15 11:38:34 -0500 | [diff] [blame] | 5 | |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 6 | These instructions will walk you through generating the Zephyr Project's |
| 7 | documentation on your local system using the same documentation sources |
| 8 | as we use to create the online documentation found at |
| 9 | https://zephyrproject.org/doc |
Rodrigo Caballero | a4a50fa | 2015-05-15 11:38:34 -0500 | [diff] [blame] | 10 | |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 11 | Documentation overview |
| 12 | ********************** |
Rodrigo Caballero | a4a50fa | 2015-05-15 11:38:34 -0500 | [diff] [blame] | 13 | |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 14 | Zephyr Project content is written using the reStructuredText markup |
| 15 | language (.rst file extension) with Sphinx extensions, and processed |
| 16 | using sphinx to create a formatted stand-alone website. Developers can |
| 17 | view this content either in its raw form as .rst markup files, or you |
| 18 | can generate the HTML content and view it with a web browser directly on |
| 19 | your workstation. This same .rst content is also fed into the Zephyr |
| 20 | Project's public website documentation area (with a different theme |
| 21 | applied). |
Rodrigo Caballero | a4a50fa | 2015-05-15 11:38:34 -0500 | [diff] [blame] | 22 | |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 23 | You can read details about `reStructuredText`_, and `Sphinx`_ from |
David B. Kinder | 6b55414 | 2017-01-15 12:43:03 -0800 | [diff] [blame] | 24 | their respective websites. |
| 25 | |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 26 | The project's documentation contains the following items: |
Rodrigo Caballero | a4a50fa | 2015-05-15 11:38:34 -0500 | [diff] [blame] | 27 | |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 28 | * ReStructuredText source files used to generate documentation found at the |
David B. Kinder | 6b55414 | 2017-01-15 12:43:03 -0800 | [diff] [blame] | 29 | https://zephyrproject.org/doc website. Most of the reStructuredText sources |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 30 | are found in the ``/doc`` directory, but others are stored within the |
David B. Kinder | 6b55414 | 2017-01-15 12:43:03 -0800 | [diff] [blame] | 31 | code source tree near their specific component (such as ``/samples`` and |
| 32 | ``/boards``) |
Rodrigo Caballero | a4a50fa | 2015-05-15 11:38:34 -0500 | [diff] [blame] | 33 | |
David B. Kinder | 6b55414 | 2017-01-15 12:43:03 -0800 | [diff] [blame] | 34 | * Doxygen-generated material used to create all API-specific documents |
| 35 | also found at https://zephyrproject.org/doc |
Rodrigo Caballero | a4a50fa | 2015-05-15 11:38:34 -0500 | [diff] [blame] | 36 | |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 37 | * Script-generated material for kernel configuration options based on Kconfig |
David B. Kinder | 6b55414 | 2017-01-15 12:43:03 -0800 | [diff] [blame] | 38 | files found in the source code tree |
| 39 | |
David B. Kinder | 6b55414 | 2017-01-15 12:43:03 -0800 | [diff] [blame] | 40 | The reStructuredText files are processed by the Sphinx documentation system, |
| 41 | and make use of the breathe extension for including the doxygen-generated API |
| 42 | material. Additional tools are required to generate the |
| 43 | documentation locally, as described in the following sections. |
Rodrigo Caballero | a4a50fa | 2015-05-15 11:38:34 -0500 | [diff] [blame] | 44 | |
| 45 | Installing the documentation processors |
| 46 | *************************************** |
| 47 | |
David B. Kinder | 6b55414 | 2017-01-15 12:43:03 -0800 | [diff] [blame] | 48 | Our documentation processing has been tested to run with: |
| 49 | |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 50 | * Doxygen version 1.8.11 |
| 51 | * Sphinx version 1.5.5 |
| 52 | * Breathe version 4.6.0 |
| 53 | * docutils version 0.13.1 |
David B. Kinder | 6b55414 | 2017-01-15 12:43:03 -0800 | [diff] [blame] | 54 | |
| 55 | Begin by cloning a copy of the git repository for the zephyr project and |
| 56 | setting up your development environment as described in :ref:`getting_started` |
| 57 | or specifically for Ubuntu in :ref:`installation_linux`. (Be sure to |
| 58 | export the environment variables ``ZEPHYR_GCC_VARIANT`` and |
| 59 | ``ZEPHYR_SDK_INSTALL_DIR`` as documented there.) |
| 60 | |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 61 | Other than ``doxygen``, the documentation tools should be installed using ``pip``. |
| 62 | If you don't already have pip installed, these commands will install it: |
| 63 | |
| 64 | .. code-block:: bash |
| 65 | |
| 66 | $ curl -O 'https://bootstrap.pypa.io/get-pip.py' |
| 67 | $ ./get-pip.py |
| 68 | $ rm get-pip.py |
| 69 | |
| 70 | The documentation generation tools are included in the set of tools |
| 71 | expected for the Zephyr build environment and so are included in |
| 72 | ``requirements.txt``: |
David B. Kinder | 6b55414 | 2017-01-15 12:43:03 -0800 | [diff] [blame] | 73 | |
Rodrigo Caballero | a4a50fa | 2015-05-15 11:38:34 -0500 | [diff] [blame] | 74 | .. code-block:: bash |
| 75 | |
David B. Kinder | 11d7449 | 2017-05-17 13:55:20 -0700 | [diff] [blame] | 76 | $ sudo -E apt-get install doxygen |
Anas Nashif | 35a70b4 | 2017-07-14 17:35:20 +0300 | [diff] [blame] | 77 | $ pip install -r scripts/requirements.txt |
David B. Kinder | 6b55414 | 2017-01-15 12:43:03 -0800 | [diff] [blame] | 78 | |
David B. Kinder | ee71332 | 2017-10-17 09:46:49 -0700 | [diff] [blame] | 79 | Documentation presentation theme |
| 80 | ******************************** |
Rodrigo Caballero | a4a50fa | 2015-05-15 11:38:34 -0500 | [diff] [blame] | 81 | |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 82 | Sphinx supports easy customization of the generated documentation |
| 83 | appearance through the use of themes. Replace the theme files and do |
| 84 | another ``make htmldocs`` and the output layout and style is changed. |
| 85 | The ``read-the-docs`` theme is installed as part of the |
| 86 | ``requirements.txt`` list above, and will be used if it's available, for |
| 87 | local doc generation. |
| 88 | |
| 89 | |
| 90 | Running the documentation processors |
Rodrigo Caballero | a4a50fa | 2015-05-15 11:38:34 -0500 | [diff] [blame] | 91 | ************************************ |
| 92 | |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 93 | The ``/doc`` directory in your cloned copy of the Zephyr project git |
| 94 | repo has all the .rst source files, extra tools, and Makefile for |
| 95 | generating a local copy of the Zephyr project's technical documentation. |
| 96 | Assuming the local Zephyr project copy is ``~/zephyr``, here are the |
| 97 | commands to generate the html content locally: |
Rodrigo Caballero | a4a50fa | 2015-05-15 11:38:34 -0500 | [diff] [blame] | 98 | |
| 99 | .. code-block:: bash |
| 100 | |
David B. Kinder | 6b55414 | 2017-01-15 12:43:03 -0800 | [diff] [blame] | 101 | $ cd ~/zephyr |
| 102 | $ source zephyr-env.sh |
Anas Nashif | 602a143 | 2017-10-31 08:35:24 -0400 | [diff] [blame] | 103 | $ cd doc |
Anas Nashif | 1e60eff | 2017-01-09 11:00:08 -0500 | [diff] [blame] | 104 | $ make htmldocs |
Rodrigo Caballero | a4a50fa | 2015-05-15 11:38:34 -0500 | [diff] [blame] | 105 | |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 106 | Depending on your development system, it will take about 15 minutes to |
| 107 | collect and generate the HTML content. When done, the HTML output will |
| 108 | be in ``~/zephyr/doc/_build/html/index.html`` |
Rodrigo Caballero | a4a50fa | 2015-05-15 11:38:34 -0500 | [diff] [blame] | 109 | |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 110 | Filtering expected warnings |
| 111 | *************************** |
Rodrigo Caballero | c0871e4 | 2015-12-08 14:30:34 -0600 | [diff] [blame] | 112 | |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 113 | Alas, there are some known issues with the doxygen/Sphinx/Breathe |
| 114 | processing that generates warnings for some constructs, in particular |
| 115 | around unnamed structures in nested unions or structs. Also, adding |
| 116 | qualifiers to a function declaration, like __deprecated, can generate a |
| 117 | warning. While these issues are being considered for fixing in |
| 118 | Sphinx/Breathe, we've added a post-processing filter on the output of |
| 119 | the documentation build process to remove "expected" messages from the |
| 120 | generation process output. |
| 121 | |
| 122 | The output from the Sphinx build is processed by the python script |
| 123 | ``scripts/filter-known-issues.py`` together with a set of filter |
| 124 | configuration files in the ``.known-issues/doc`` folder. (This |
| 125 | filtering is done as part of the ``doc/Makefile``.) |
| 126 | |
| 127 | If you're contributing components included in the Zephyr API |
David B. Kinder | ee71332 | 2017-10-17 09:46:49 -0700 | [diff] [blame] | 128 | documentation and run across these warnings, you can include filtering |
David B. Kinder | 9c50ac3 | 2017-09-26 14:11:08 -0700 | [diff] [blame] | 129 | them out as "expected" warnings by adding a conf file to the |
| 130 | ``.known-issues/doc`` folder, following the example of other conf files |
| 131 | found there. |
| 132 | |
| 133 | .. _reStructuredText: http://sphinx-doc.org/rest.html |
| 134 | .. _Sphinx: http://sphinx-doc.org/ |