Verification · Static analysis · Documentation build
Doctests
Run code examples in documentation as tests.
How to build it
- Enable doctest collection, such as pytest --doctest-modules or cargo test for Rust doc comments.
- Write examples as runnable snippets with the expected output.
- Run the doctest step in the same CI job as the unit tests.
Signals in a repository
- A pytest configuration with doctest_modules or doctest_glob set.
- Code examples in docstrings or doc comments that include expected output.
In practice
106 repositories run a tool for this check in the scanned set.
pytest· 77 reposcargo-test· 44 repos
Examples
-
facebook/react ·
cargo-testcargo test --workspace -
nousresearch/hermes-agent ·
pytestpytest ${args[@]} -
TheAlgorithms/Python ·
pytestpytest --iterations=8 --parallel-threads=auto --ignore-gil-enabled --ignore=computer_vision/flip_augmentation.py --ignore=computer_vision/harris_corner.py --ign -
microsoft/vscode ·
cargo-testcargo test ${args[@]} -
langchain-ai/langchain ·
pytestpytest -m compile tests/integration_tests