Commit graph

111 commits

Author SHA1 Message Date
Gerard Marull-Paretas d3d93d4399 doc: enable Sphinx tracebacks
When something goes wrong in Sphinx or extensions, we'll get a detailed
traceback, so we can easily debug issues in CI.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-07-12 09:13:49 -04:00
Gerard Marull-Paretas 2c89bf5798 doc: add cmake SPHINXOPTS_EXTRA option
Add a new CMake option to append options to SPHINXOPTS. This allows us
to easily extend default SPHINXOPTS. This patch also restores the "-j
auto" option in CI (now that we use a custom runner).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-07-12 09:13:49 -04:00
Gerard Marull-Paretas 85ec85384a doc: add -W --keep-going to the default SPHINXOPTS list
Run Sphinx in warnings as error mode, but keep going so that all issues
are reported to the user.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-07-12 09:13:49 -04:00
Martí Bolívar 523de0d9be doc: set MIN_WEST_VERSION to 1.0.0
If west is installed, we have to build the Zephyr documentation with a
recent version of west. This is because the west API documentation is
part of the Zephyr documentation, and the west API documentation
contains Sphinx autodoc directives which pull API documentation out of
the west source code itself. This is similar to how we pull Doxygen
comments out of the Zephyr API headers using breathe. (If west is not
installed, we don't build the west API docs, so you can uninstall west
if you don't want this.)

The current API docs require west v1.0.0 or later to build, since that
version of west introduced new APIs and documentation for them not
available in prior versions.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2023-03-08 14:16:53 -08:00
Gerard Marull-Paretas 41566e2502 doc: add support for linkcheck
This patch adds support for the `linkcheck` Sphinx builder, so that we
can easily check for broken links in the documentation.

It can be run like this:

ninja linkcheck

Or, using the Makefile shim:

make linkcheck

All Zephyr Github issues links are ignored, since we have lots of these
URLs and they quickly hit GH rate limit. They have small chance to be
incorrect, so we should be ok.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-23 17:28:47 +00:00
Fabio Baltieri 838dbaae7f doc: fix building documentation when PYTHONPATH is set
Re-add the SEP setting in the documentation CMakeLists. This was dropped
in:

fc942ef7d3 doc: use new kconfig extension

And currently prevents building the documentation locally if a
PYTHONPATH is set.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-05-25 17:16:55 -07:00
Anas Nashif 6e9a43be79 doc: move DTS under Build/Configuration systems section
Move all DTS guides and APIs under Build/Configuration system.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-07 16:35:19 +02:00
Gerard Marull-Paretas fc942ef7d3 doc: use new kconfig extension
Enable the new extension and delete usage of the old script/extensions.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-02 09:28:37 +01:00
Torsten Rasmussen 604f705fda cmake: doc: created a doc.cmake CMake module in Zephyr CMake modules dir
Creating a doc.cmake to the new Zephyr CMake modules dir.

This removes the need for `set(NO_BOILERPLATE TRUE)` before loading the
Zephyr CMake package.

It also removes the need within the doc/CMakeLists.txt file to manually
include individual parts of the Zephyr CMake files as this is now
controlled through a single Zephyr CMake doc module.

This aligns the way a Zephyr package is sourced with other places.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Gerard Marull-Paretas 5986d882bb doc: add support for DT_TURBO_MODE
Similar to Kconfig turbo mode, add a Devicetree bindings turbo mode. In
this mode, the Devicetree bindings pages are not generated. Instead, a
page with dummy symbols is created. This takes ~1K pages out of the
build, resulting in faster builds. This mode can be useful while in
development or CI PRs.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-02-21 20:47:10 -05:00
Gerard Marull-Paretas a42ee8bd04 doc: doxygen: add version and shorten brief
Render Zephyr version in both, standalone Doxygen build and Sphinx
controlled build. In standalone mode, the package version given by
find_package(Zephyr...) is used, while in Sphinx build the conf.py
version is used.

The project brief has been shortened to make project title more compact
while still containing relevant information.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-10-07 11:54:23 -04:00
Torsten Rasmussen 36bb00d1f5 armclang: ARM Compiler C library support
Support for ARM Compiler C library.

This commit add support for the ARM Compiler C libary in:
- Kconfig
- libc/armstdc

A new Kconfig symbol is added to allow a toolchain to specify if they
support linking with the minimal C library.
Also the CMake variable `TOOLCHAIN_HAS_NEWLIB` is exported to Kconfig
so that CONFIG_NEWLIB_LIBS can only be enabled if the toolchain has
newlib.

The armclang toolchain selects the CMake scatter file generator and
disables support for the LD linker template which is not supported by
armlink.

For the ARM Compiler C library, a corresponding lib/libc/armstc/ folder
with a minimal implementation to work with the ARM Compiler C library
is added.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Torsten Rasmussen 1cccc8a8fe cmake: increase minimal required version to 3.20.0
Move to CMake 3.20.0.

At the Toolchain WG it was decided to move to CMake 3.20.0.

The main reason for increasing CMake version is better toolchain
support.

Better toolchain support is added in the following CMake versions:
- armclang, CMake 3.15
- Intel oneAPI, CMake 3.20
- IAR, CMake 3.15 and 3.20

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-20 09:47:34 +02:00
Gerard Marull-Paretas 1829dc8875 doc: do not use env vars to discover paths
ZEPHYR_BASE and ZEPHYR_BUILD directories were passed to Sphinx via
environment variables. However, these paths can be easily discovered by
the conf.py file itself. As a result, Sphinx is less dependent on CMake
to operate.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-21 07:28:18 -04:00
Gerard Marull-Paretas e46f3de447 doc: remove fix_tex script
The LaTeX build succeeds without the fix_tex.py script, so remove it.
The file actually mentions ".tex file produced by doxygen", so it may
not be relevant for Sphinx after all.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-21 10:25:39 +03:00
Gerard Marull-Paretas 4127138475 doc: enable graphviz extension
Enable the built-in Sphinx Graphviz extension to allow creating Graphviz
diagrams natively on the source files. Some style defaults have been
enabled to make sure diagrams are consistent and have good quality in
both light and dark modes.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-20 19:54:52 -04:00
Gerard Marull-Paretas 3db8d2be23 doc: cmake: allow to override LATEXMKOPTS
This is useful if the user wants to set specific latexmk options, e.g.
-quiet for CI.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-15 06:59:38 -04:00
Gerard Marull-Paretas 9cb8413445 doc: cmake: use Sphinx generated make files for PDF build
Sphinx automatically generates a Makefile/make.bat that allows to build
the LaTeX output. This converts the CMake `pdf` target into a shim to
this Makefile, making the solution more future-proof if Sphinx decides
to change something.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-15 06:59:38 -04:00
Gerard Marull-Paretas 53b9018367 doc: cmake: add target comments
Add target comments to make build process more user friendly.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-14 15:47:11 +02:00
Gerard Marull-Paretas 5fe1694ec9 doc: cmake: move pristine to a separate section
Move 'pristine' target to 'others' section.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-14 15:47:11 +02:00
Gerard Marull-Paretas 0db41264f1 doc: cmake: add support for clean target
Indicate which files have to be cleaned for each target. This feature is
only supported for CMake >= 3.15 and is ignored on older CMake versions.
Build will still succeed, but the `clean` target will not clean the
additional build files.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-14 15:47:11 +02:00
Gerard Marull-Paretas 5ec8980fee doc: cmake: refactor devicetree
Simplify the devicetree generation. Most of the extra options are not
used, so they have been removed to make things easier to maintain.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-14 15:47:11 +02:00
Gerard Marull-Paretas 21c4cc829f doc: cmake: refactor kconfig
Refactor the Kconfig target. Mostly formatting in this case. The Kconfig
script is also added as a dependency of the CMake configuration step, so
that if it is changed, the Kconfig generation step will be re-run.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-14 15:47:11 +02:00
Gerard Marull-Paretas f865ca33c5 doc: cmake: remove RST_OUT redundant variable
DOCS_SRC_DIR is used instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-14 15:47:11 +02:00
Gerard Marull-Paretas cd555711a8 doc: cmake: remove unused version include
version.cmake is not being used.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-14 15:47:11 +02:00
Gerard Marull-Paretas 35f44788ca doc: cmake: move environment, paths and functions
Move environment, paths and functions before they are used. Helps on
readability.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-14 15:47:11 +02:00
Gerard Marull-Paretas dc3a290ca9 doc: cmake: refactor pdf build
Refactor the pdf build targets. The Sphinx latex build is now invoked by
the 'latex' target. The 'pdf' target can be used to build the resulting
LaTeX files.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-14 15:47:11 +02:00
Gerard Marull-Paretas 8a8b58cf33 doc: cmake: cleanup doxygen section
Cleanup doxygen section and simplify target.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-14 15:47:11 +02:00
Gerard Marull-Paretas 2f1932c5bb doc: cmake: refactor html targets
Refactor HTML targets. The 'html' target is kept as is, 'sphinx-html'
equivalent is now 'html-nodeps'.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-14 15:47:11 +02:00
Gerard Marull-Paretas a240b57405 doc: cmake: remove unused variables
Remove some unused variables.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-14 15:47:11 +02:00
Gerard Marull-Paretas e06ebed457 doc: cmake: group options
Group options all together and make them part of cache.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-14 15:47:11 +02:00
Gerard Marull-Paretas e5b7d3f49a doc: cmake: improve dependencies section
Group dependencies all together. Some have been simplified, e.g. Sphinx
and others improved, e.g. LaTeX.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-14 15:47:11 +02:00
Gerard Marull-Paretas 3ea64ce7f7 doc: cmake: remove west check
west is currently optional, however, when not found its docs will not be
available and the zephyr_module CMake utility will not be able to find
modules (unless ZEPHYR_MODULES is used). Other Python dependencies, i.e.
the ones listed in the requirements file, are not checked, so do the
same for west.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-14 15:47:11 +02:00
Torsten Rasmussen 6be1b2af9b kconfig: soc and shield cleanup
Always source the Zephyr base soc and shield (board root) Kconfigs
directly from Kconfig instead of generated Kconfig files.

This has the benefit that it is no longer necessary to generate Kconfig
files to source SoC root and shield (board root) when no custom roots
are provided.

Also this cleans up the doc/CMakeLists.txt and ensures that the
doc/CMakeLists.txt is not getting out of sync with the Kconfig.cmake.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-06-11 16:13:22 +02:00
Gerard Marull-Paretas a140a249b3 doc: only enable -W option on CI
The usage of -W may lead to the loss of the Sphinx build environment
even for small typos. Remove this option from the defaults but still
enable it on CI, where the fail-fast behavior given by -W is desired.

Fixes #36033

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-06-08 09:58:32 -05:00
Gerard Marull-Paretas 4dd15539a9 doc: use external_content
Use external_content Sphinx extensions to gather documentation sources.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-25 19:38:11 +02:00
Gerard Marull-Paretas bf5065d742 doc: improve Sphinx defaults
Make default Sphinx options more user-friendly, i.e. colored output so
that one can easily follow build progress.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-25 19:38:11 +02:00
Gerard Marull-Paretas 457f3a46d6 doc: use doxyrunner
doxyrunner plugin replaces a series of CMake+Python hacks. These include
input changes tracking and incremental build output simulation.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-06 13:19:19 +02:00
Gerard Marull-Paretas 2207c4c8e5 doc: replace restore doxygen times script
Replace the restore modification times with a new script that is more
specific to the Doxygen+Sphinx needs.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-06 13:19:19 +02:00
Gerard Marull-Paretas 96c7d10a15 doc: use warnings_filter
Replace current filter setup with the warnings_filter Sphinx extension.
Note that current regexes have been simplified to make them more
readable while keeping the most relevant information.

Sphinx warnings are now treated as errors (-W).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-07 14:15:29 +02:00
Martí Bolívar 5332847644 dts: separate DT libraries from gen_defines.py
We are now in the process of extracting edtlib and dtlib into a
standalone source code library that we intend to share with other
projects.

Links related to the work making this standalone:

    https://pypi.org/project/devicetree/
    https://python-devicetree.readthedocs.io/en/latest/
    https://github.com/zephyrproject-rtos/python-devicetree

This standalone repo includes the same features as what we have in
Zephyr, but in its own 'devicetree' python package with PyPI
integration, etc.

To avoid making this a hard fork, move the code that's being made
standalone around in Zephyr into a new scripts/dts/python-devicetree
subdirectory, and handle the package and sys.path changes in the
various places in the tree that use it.

From now on, it will be possible to update the standalone repository
by just recursively copying scripts/dts/python-devicetree's contents
into it and committing the results.

This is an interim step; do NOT 'pip install devicetree' yet.
The code in the zephyr repository is still the canonical location.

(In the long term, people will get the devicetree package from PyPI
just like they do the 'yaml' package today, but that won't happen for
the foreseeable future.)

This commit is purely intended to avoid a hard fork for the standalone
code, and no functional changes besides the package structure and
location of the code itself are expected.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-04-02 08:28:12 -05:00
Gerard Marull-Paretas 3282cf8ef2 doc: move scripts to _scripts
Move Sphinx related content to folders with underscore prefix.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-03-31 10:39:48 +02:00
Gerard Marull-Paretas b44fc8a89c doc: enable automatic parallelization
Sphinx supports parallelized build (-j) option. Setting it to `auto`
makes use of all available cores. This option seems to speed up the
build significantly on multi-core machines.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-03-29 10:59:28 -04:00
Torsten Rasmussen 11016415dd doc: supporting module Kconfig code in module ext root
Fixes: #31486

Sourcing `cmake/extensions.cmake` to have Zephyr functions available
when including Zephyr CMake files into doc build system.

This is a follow up on #30904 by supporting generated Kconfig files
that might contain lines as `osource "$(ZEPHYR_<MODULE_NAME>_KCONFIG)"`
to be properly parsed for doc building.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-01-22 15:22:32 -05:00
Fabio Utzig 4b93fdb7df doc: fix Kconfig.shield sourcing build issue
Fix documentation build issue where generating the kconfig rST was
failing due to missing Kconfig.shield* files. Add an extra step in
CMakeLists.txt to properly generate them, similarly to what is already
done for Kconfig.soc*.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-11-13 11:10:45 -05:00
Martí Bolívar 808dd9e684 doc: reference: add devicetree bindings content
Add generated documentation content for known devicetree bindings
using the Binding abstraction which was just added to edtlib. This
works similarly to the way Kconfig content is generated, so extract a
bit of common helper code for doing that out and rename the relevant
files to keep the distinction clear.

Make the documentation build system respect a preset DTS_ROOT. In this
way, out of tree bindings can be added to the generated content by
telling the documentation build system where to find them, identically
to how out of tree bindings can be added to a Zephyr application.

Similarly, make the output directory configurable.

Fixes: #28865
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-11-02 14:26:33 -05:00
Kumar Gala f80f31eb0d ci: github: reduce when we do doc builds
Rather than doing a doc build on every PR, limit it to PRs that either
touch a file in doc/, *.rst and what's listed as DOXY_SOURCES in
doc/CMakeLists.txt.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-10-21 17:40:52 +02:00
Marc Herbert e3c50af3e6 doc: restore sphinx-html and sphinx-latex shortcuts
Fixes commit 15fbf707ca ("doc: revert to copy files with
extract_content.py directly") that removed (2 years ago!) the definition
of EXTRACT_CONTENT_OUTPUTS while leaving it in use by sphinx-html and
sphinx-latex.

On my Linux box "make sphinx-html" is more than 5 times faster than
"htmldocs", likely because it does not build doxygen nor kconfig.

Also add missing WORKING_DIRECTORY for consistency with regular
targets and to fix this error:

Exception occurred:
  File "~/.local/lib/python3.8/site-packages/sphinx/
                   search/__init__.py", line 284, in __init__
    with open(scoring, 'rb') as fp:
FileNotFoundError: [Errno 2] No such file or directory: 'scorer.js'

I don't know when that second regression appeared.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-10-20 11:05:41 -04:00
Torsten Rasmussen 5f7cc8ded9 cmake: kconfig: support for multiple SOC_ROOT
This commit introduces support for multiple SOC_ROOT.

This means that additional SOC_ROOTs specified using -DSOC_ROOT as
argument to CMake will be forming a list together with ${ZEPHYR_BASE}.

This allows for greater flexibility, as developers can now specify
multiple out-of-tree SoCs and not worry about the SoC used for the
board they compile for.

Also it avoid code, such as:
if(BOARD STREQUAL my_board_using_out_of_tree_soc)
  set(SOC_ROOT some/out/of/tree/soc/path)
endif()
in application CMakeLists.txt.

Finally, allowing multiple SOC_ROOTs prepares for specifying SOC_ROOTs
in Zephyr modules.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-08-05 08:06:07 -04:00
Marc Herbert 3a04536487 doc,cmake: make find_package(Zephyr...) REQUIRED
This provides a better error message when building with CMake and
forgetting ZEPHYR_BASE or not registering Zephyr in the CMake package
registry. See parent commit for more details (split from parent for
better readability).

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-05-29 10:47:25 +02:00