Skip to main content

sphinx-apitree

Unittests PyPI version

apitree is a small library to generate a ready-to-use documentation with minimal friction!

apitree takes care of everything, so you can only focus on the code.

Usage

In docs/conf.py, replace everything by:

import apitree

apitree.make_project(
    # e.g. `import visu3d as v3d` -> {'v3d': 'visu3d'}
    project_name={'alias': 'my_module'},
    globals=globals(),
)

Then to generate the doc:

sphinx-build -b html docs/ docs/_build

To add api/my_module/index somewhere in your toctree, like:

..toctree:
  :caption: API

  api/my_module/index

Features

  • All included: Single function call include the theme, the API generation,...
  • Auto-generate the API tree:
    • Do not require __all__ (smart detect of which symbols are documented)
    • Add expandable toc tree with all symbols
  • Add links to GitHub.
  • Markdown (.md) / Jupyter (.ipynb) support out of the box
  • Auto-cross-references (Just annotate markdown inline-code my_symbol and links are auto-added)
  • Contrary to autodoc and apitree, it also document:
    • Type annotations (Union[], ...)
    • Attributes
  • ...

Installation in a project

  1. In pyproject.toml

    [project.optional-dependencies]
    # Installed through `pip install .[docs]`
    docs = [
        # Install `apitree` with all extensions (sphinx, theme,...)
        "sphinx-apitree[ext]",
    ]
    
  2. In .readthedocs.yaml

    sphinx:
    configuration: docs/conf.py
    
    python:
    install:
        - method: pip
        path: .
        extra_requirements:
            - docs
    

Options

By default, apitree tries to infer everything automatically. However there's sometimes times where the user want to overwrite the default choices.

  • Package vs module: By default, all __init__.py define the public API (imports documented), while the modules (module.py) define the implementation (imports not documented). You can explicitly mark a module as package, so it's import are documented, by adding in the module definition:

    __apitree__ = dict(
        is_package=True,
    )
    

Examples of projects using apitree

Generated with:

echo start \
&& cd ../visu3d          && sphinx-build -b html docs/ docs/_build \
&& cd ../dataclass_array && sphinx-build -b html docs/ docs/_build \
&& cd ../etils           && sphinx-build -b html docs/ docs/_build \
&& cd ../kauldron        && sphinx-build -b html docs/ docs/_build \
&& echo finished

Release files for sphinx-apitree 1.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphinx-apitree 1.6.2
File Size Uploaded
sphinx_apitree-1.6.2.tar.gz 20.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sphinx-apitree 1.6.2
File Interpreter ABI Platform
sphinx_apitree-1.6.2-py3-none-any.whl Python 3 none any Details

Total release size: 45.8 kB

Release files / sphinx_apitree-1.6.2.tar.gz

Download URL sphinx_apitree-1.6.2.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fa786fb4255438daf0f4644ad6b0dca0ce9b366cea3abbf11fbe946e46a99d03
BLAKE2b-256 checksum
How to use checksums
fa3c4296fc8ff1f7d86e039624f5e62f63daae9f7004a3e1c391a5a9bc03c6ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release files / sphinx_apitree-1.6.2-py3-none-any.whl

Download URL sphinx_apitree-1.6.2-py3-none-any.whl
Size 25.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
570116a420cc292c12903257222bf421f6a85e88e71919d83496de10c0a9dbd2
BLAKE2b-256 checksum
How to use checksums
680d2377dd421212fd1e83f729d417970dc976a2dbaa875ab9e6ecc8de2bfa6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release history Release notifications | RSS feed

This release

1.6.2 This release

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.3

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page