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 included from Doxygen comments.
See the Documentation overview section in the Documentation Generation developer guide for information about reStructuredText.
Before you start¶
See the Installing the documentation processors section in the Documentation Generation developer guide for information about installing the required tools to build the documentation and their supported versions.
In addition to these tools, you must install mscgen and make sure the
mscgen executable is in your
On Windows, the Sphinx executable
sphinx-build.exe is placed in the
Scripts folder of your Python installation path.
Dependending on how you have installed Python, you might need to add this folder to your
PATH environment variable.
Follow the instructions in Windows Python Path if needed.
All documentation build files are located in 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 are provided in a
*.rst file in the same directory as the code.
Building the documentation output requires building output for all documentation sets.
Currently, there are four sets: nrf, nrfxlib, zephyr, and mcuboot (covering the contents of
Since there are links from the ncs documentation set into other documentation sets, the other documentation sets must be built first.
Building documentation output¶
Complete the following steps to build the documentation output:
Open a shell and enter the doc folder
Hold shift and right-click on the
docfolder. Select Open command window here.
On Linux or macOS:
Open a shell window.
ncs/nrf/doc. If the ncs folder is in your home directory, enter:
Generate the Ninja build files:
cmake -GNinja -B_build .
Enter the generated build folder:
Run ninja to build the documentation:
This command will build all documentation sets. Note that this process can take quite some time.
Alternatively, if you want to build each documentation set separately, complete the following steps:
Run ninja to build the Kconfig documentation:
Run ninja to build the Zephyr documentation:
This step can take up to 15 minutes.
Run ninja to build the mcuboot documentation:
Run ninja to build the nrfxlib inventory file (used by nrf):
Run ninja to build the nRF Connect SDK documentation:
Run ninja to build the nrfxlib documentation:
The documentation output is written to
index.html file to display the documentation in your browser.
If you modify or add RST files, you do not need to rerun the full documentation build.
For simple changes, it is sufficient to run the substep that builds the respective documentation (for example, only
ninja nrf for changes to the nRF Connect SDK documentation).
If this results in unexpected build errors, follow Caching and cleaning and rerun
Caching and cleaning¶
To speed up the documentation build, Sphinx processes only those files that have been changed since the last build. In addition, RST files are copied to a different location during the build process. This mechanism can cause outdated or deleted files to be used in the build, or the navigation to not be updated as expected.
If you experience any such problems, clean the build folders before you run the documentation build. Note that this will cause the documentation to be built from scratch, which takes a considerable time.
To clean the build folders for the Zephyr documentation:
To clean the build folders for the nrfxlib documentation:
To clean the build folders for the MCUboot documentation:
To clean the build folders for the nRF Connect SDK documentation:
Out-of-tree builds are also supported, so you can actually build from outside the source tree:
# On Linux/macOS cd ~ source ncs/zephyr/zephyr-env.sh cd ~ mkdir build # On Windows cd %userprofile% ncs\zephyr\zephyr-env.cmd mkdir build # Use cmake to configure a Ninja-based build system: cmake -GNinja -Bbuild/ -Hncs/nrf/doc # Now run ninja on the generated build system: ninja -C build/ zephyr ninja -C build/ mcuboot ninja -C build/ nrfxlib-inventory ninja -C build/ nrf ninja -C build/ nrfxlib # If you modify or add .rst files in the nRF repository, run ninja again: ninja -C build/ nrf
If you want to build the documentation from scratch, delete the contents of the build folder and run
cmake and then
Documentation sets for different versions of the nRF Connect SDK are defined in the
This file is used to display the version drop-down in the top-left corner of the documentation.
The version drop-down is displayed only if the documentation files are organized in the required folder structure and the documentation is hosted on a web server. To test the version drop-down locally, complete the following steps:
In the documentation build folder (for example,
_build), rename the
Open a command 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,