Building the nRF Connect SDK documentation
The nRF Connect SDK documentation is written using the reStructuredText markup language (.rst
file extension) with Sphinx extensions and processed using Sphinx.
API documentation is generated from Doxygen comments.
See Documentation overview in the Zephyr developer guide for information about reStructuredText.
Before you start
Before you can build the documentation, you must install the required tools. The following tool versions have been tested to work:
Doxygen 1.12
Mscgen 0.20
PlantUML
Python dependencies as listed in Building documentation on the Requirements page
Complete the following steps to install the required tools:
If you have not done so already, install the nRF Connect SDK as described in Installing the nRF Connect SDK.
Install or update all required Python dependencies.
Install the additional Python dependencies for building the documentation by entering the following command in a terminal window in the
ncs
folder. Python virtual environment needs to be active for the command to work:pip install -U -r nrf/doc/requirements.txt
Install Doxygen.
Install Mscgen and make sure that the
mscgen
executable is in yourPATH
.Install PlantUML. On Windows, you can install PlantUML from chocolatey.
Building documentation output
All documentation build files are located in the ncs/nrf/doc
folder.
The nrf
subfolder in that directory contains all .rst
source files that are not directly related to a sample application or a library.
Documentation for samples and libraries is provided in a README.rst
or another .rst
file in the same directory as the code.
Building the documentation output requires building the output for all documentation sets that are part of the Documentation structure. Since there are links from the nRF Connect SDK documentation set into other documentation sets, the documentation is built in a predefined order.
Complete the following steps to build the documentation output:
Start the toolchain environment in a terminal window.
Enter the doc folder
ncs/nrf/doc
.Generate the Ninja build files by entering the following command:
cmake -GNinja -S. -B_build
Enter the generated build folder:
cd _build
Run ninja to build the complete documentation by entering the following command:
ninja
The documentation output is written to the doc/_build/html
folder.
Double-click the index.html
file to display the documentation in your browser.
Alternatively, you can work with just a single documentation set, for example, nrf
.
The build system provides individual targets for such a purpose.
If you have not built all documentation sets before, it is recommended to run the following command:
ninja docset-name-all
Here, docset-name is the name of the documentation set, for example, nrf
.
This target will build the documentation sets that are needed for docset-name.
Note that Doxygen-only docsets like nrfx
do not have the -all
target as they have no dependencies.
On subsequent builds, it is recommended to just run the following command:
ninja docset-name
The last couple of targets mentioned in Documentation structure will only invoke the build for the corresponding documentation set (referred by docset-name), assuming that all of its dependencies are available.
Additionally, the *docset-name*-live-all
and *docset-name*-live
targets are provided with equal functionality plus hot reloading.
The advantage of using live
targets is that by just editing and saving changes, a re-build will be triggered and browser window will be refreshed.
Caching and cleaning
To speed up the documentation build, Sphinx processes only those files that have been changed since the last build. This mechanism can sometimes cause issues such as navigation not being updated correctly.
If you experience any of such issues, clean the build folders before you run the documentation build.
To clean all the build files:
ninja clean
To clean the build folders for a particular documentation set:
ninja docset-name-clean
Here, docset-name is the name of the documentation set, for example, nrf
.
Optimizing build speed
When working with documentation locally, you can enable the -DNO_DTS_BINDINGS=ON
option when configuring the build.
This option skips generating devicetree bindings pages, which speeds up the Zephyr documentation set build process.
Testing locally
Documentation sets for different versions of the nRF Connect SDK are defined in the doc/versions.json
file.
This file is used to display the version drop-down.
To test the version drop-down locally, complete the following steps:
In the documentation build folder (for example,
_build
), rename thehtml
folder tolatest
.Open a command-line window in the documentation build folder and enter the following command to start a Python web server:
python -m http.server
Access http://localhost:8000/latest/index.html with your browser to see the documentation.
To add other versions of the documentation to your local documentation output, build the versions from a tagged release and rename the html
folder to the respective version (for example, 2.7.0
).