This directory contains the Sphinx documentation for TranPy.
Install documentation dependencies:
pip install -e ".[docs]"
Or with uv:
uv pip install -e ".[docs]"
cd docs
make html
sphinx-build -M html docs docs/_build
/Users/mahmouddraz/code/tranpy/.venv/bin/sphinx-build -M html docs docs/_build
After building, open the documentation in your browser:
# Mac
open docs/_build/html/index.html
# Linux
xdg-open docs/_build/html/index.html
# Windows
start docs/_build/html/index.html
To remove all built documentation:
cd docs
make clean
Or manually:
rm -rf docs/_build
docs/
├── conf.py # Sphinx configuration
├── index.rst # Main documentation page
├── Makefile # Build automation
├── installation.rst # Installation guide
├── quickstart.rst # Quick start guide
├── api/ # API reference
│ ├── datasets.rst
│ ├── models.rst
│ ├── explainers.rst
│ ├── simulation.rst
│ ├── data.rst
│ └── utils.rst
└── _build/ # Generated documentation (gitignored)
└── html/ # HTML output
.rst file in the appropriate directoryindex.rstExample:
.. toctree::
:maxdepth: 2
new_page
api/New Module
==========
.. automodule:: tranpy.new_module
:members:
:undoc-members:
:show-inheritance:
api/ toctree in index.rstIf Sphinx can’t find tranpy modules:
pip install -e .conf.py has correct path: sys.path.insert(0, os.path.abspath('../src'))Most warnings about missing references can be ignored. To suppress specific warnings, update conf.py.
If the Read the Docs theme doesn’t load:
pip install sphinx-rtd-theme
Install sphinx-autobuild:
pip install sphinx-autobuild
Run:
sphinx-autobuild docs docs/_build/html
Then open http://127.0.0.1:8000 in your browser.
The documentation is ready to be published on Read the Docs:
docs/conf.pyTo publish on GitHub Pages:
# Build documentation
make html
# Copy to gh-pages branch
git checkout -b gh-pages
cp -r _build/html/* .
git add .
git commit -m "Update documentation"
git push origin gh-pages
Use Google or NumPy style docstrings:
def my_function(param1: int, param2: str) -> bool:
"""
Brief description.
Longer description if needed.
Args:
param1: Description of param1
param2: Description of param2
Returns:
Description of return value
Examples:
>>> my_function(1, "test")
True
"""
pass