My current pipeline looks something like the following:
sphinx-build -b doctest -d docs/build/doctrees docs docs/build/doctest
sphinx-apidoc -f -o docs/ src/my_package
sphinx-build -b html -d docs/build/doctrees docs docs/build/html
The index.rst
file contains my_package
in the toctree to include the generated API docs. The generated API docs are not under version control and get freshly generated with every pipeline run.
I would like to add the -W
option to the sphinx-build
calls to turn warnings into errors. However, I get the warning index.rst:5:toctree contains reference to nonexisting document 'my_package'
on the doctest call. I can run sphinx-apidoc
first but then the doctest call raises docs/modules.rst:document isn't included in any toctree
. I can add the --no-toc
option to sphinx-apidoc but then the doctests fail because they apparently also run on the .rst files generated by sphinx-apidoc and can not find imported functions if modules.rst
is missing. Excluding modules.rst
via exclude_patterns
in my conf.py
also breaks the doctest call.
How can I configure my pipeline so that I can call both sphinx-build
calls with -W
and still get the auto-generated API docs?