Skip to main content

Sphinx extension to auto-generate API tree.

Project description

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

  • Theme
  • Auto-generate the API tree, with better features
    • Do not require __all__ (smart detect of which symbols are documented)
    • Add expandable toc tree with all symbols
  • ...

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinx_apitree-1.4.0.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

sphinx_apitree-1.4.0-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_apitree-1.4.0.tar.gz.

File metadata

  • Download URL: sphinx_apitree-1.4.0.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for sphinx_apitree-1.4.0.tar.gz
Algorithm Hash digest
SHA256 a1c9f068f1e45169012aa394f3ca7714cbc1da0be8822a1139acdadeeda4dde8
MD5 9255f6495f12c4c351c180c926f7090f
BLAKE2b-256 c225c830a1b472c0e71e86a42ce9ce208b74f0c65c4a5a707fc1ca78b0739fc1

See more details on using hashes here.

File details

Details for the file sphinx_apitree-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_apitree-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b76f8d3c0a1e0fca6e340c2d65c293558da7a350ec28222fac9076b53a27c163
MD5 c63d9ec2ec05b258ddbea06a99375253
BLAKE2b-256 dbb128f16dd4b8df7c0c014a2a8b6a6e7f64d83a01d5e94e5f7cd79dcbdd6f1f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page