Build docs without the compiled extension to test the stub
Symptom#
The docs build can break while a local Sphinx run passes. docs/source/_ext_stub.py replaces the compiled extension on a docs-only machine. A local run that puts the real built extension on PYTHONPATH does not use the stub, so a damaged stub goes unnoticed. A rename commit cut the stub from 910 to 502 lines and removed its sys.modules registration. The docs build then failed in conf.py at import dftracer.utils with ImportError: cannot import name 'dftracer_utils_ext' from partially initialized module 'dftracer.utils' (most likely due to a circular import).
Cause#
The stub is only exercised when no compiled extension is available, but local documentation builds can accidentally import the built extension instead.
Fix#
Build docs as on a docs-only machine: env -u PYTHONPATH .venv_docs/bin/sphinx-build ... with no built extension. After a mass rename or squash, check git diff --stat on the stub for unexpected deletions. When the extension API changes, update stub class and error names (DFTUtilsDuqlError) and drop stubs for removed classes (ComparatorUtility). In C++ documentation comments, escape bare angle brackets such as \<type\> and \<id\> to avoid Doxygen treating them as HTML tags; rebuild docs and compare warnings against the baseline.
Evidence#
The user's docs build failed after the stub lost its sys.modules registration; the imported real extension had hidden the problem in local runs. Doxygen also warned about bare <type> and <id> text in provenance_graph.h.
Also found by searching
- sphinx ImportError partially initialized dftracer utils extension stub
- docs build fails but local Sphinx passes with compiled extension
- how do I test docs when there is no built Python extension
- extension stub registration removed from sys.modules