This directory contains the documentation for zenoh-python, built using Sphinx.
- Python 3.8 or later
- zenoh-python package built and installed
- Sphinx and related packages (see
requirements.txt)
-
Build and install zenoh-python:
cd /path/to/zenoh-python pip install -e .
-
Install documentation dependencies:
cd docs pip install -r requirements.txt
The documentation build process requires converting stub files (.pyi) to source files (.py) so that Sphinx can extract API documentation.
Use the provided script to build and open documentation:
./open.shThis script:
- Converts stub files to source files
- Builds HTML documentation
- Opens the documentation in your browser
- Restores original files
If you prefer to build manually:
-
Convert stubs to sources:
python3 stubs_to_sources.py
-
Build HTML documentation:
make html
-
Restore original files:
python3 stubs_to_sources.py --recover
-
View documentation:
Open
_build/html/index.htmlin your browser.
Zenoh-python's API is implemented in Rust via PyO3. The Python type information exists in .pyi stub files. However, Sphinx's autodoc cannot read stub files directly - it needs .py files.
The stubs_to_sources.py script:
- Creates
.pyversions of.pyifiles with documentation - Backs up original
.pyfiles to_stubs_backup/ - Keeps
.pyifiles unchanged (they're ignored at runtime) - Can restore everything with
--recover
Examples in docs/examples/ are tested using pytest to ensure they run without errors:
# Test all docs examples (from project root)
python3 -m pytest tests/examples_check.py::test_docs_examples -vThis test:
- Finds all
.pyfiles indocs/examples/using glob patterns - Runs each example individually as a standalone script
- Verifies each example completes without errors (exit code 0)
- Ensures no timeouts occur (10 second limit per example)
Examplples should exercise all code paths demonstrated in the documentation to ensure they work correctly.