Sphinx AutoAPI

3.8.0 · active · verified Thu Apr 09

Sphinx AutoAPI is an extension for Sphinx that automatically generates API documentation from your Python code, similar to `sphinx.ext.autodoc` but without needing to explicitly list every module, class, or function. It parses your source code and creates reStructuredText files. The current version is 3.8.0, and it typically releases new minor versions every few months.

Warnings

Install

Imports

Quickstart

To quickly set up Sphinx AutoAPI, first install it and Sphinx. Then, modify your `conf.py` to add `autoapi.extension` to the `extensions` list and configure `autoapi_dirs` to point to the root directory of your Python source code. Finally, reference the generated API documentation from your main `.rst` or `.md` file, typically using a `toctree` that includes `_autoapi/index`.

import os

# In conf.py
project = 'My Project'
copyright = '2024, Author'

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.napoleon',
    'autoapi.extension',
]

html_theme = 'sphinx_rtd_theme'

# Point AutoAPI to your source code directory(ies)
# Adjust '../src' to your actual project source path relative to conf.py
autoapi_dirs = [os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'src'))]

# Optional: Generate a main index file for AutoAPI
# Then, link to it in your main index.rst via: 
# .. toctree::
#    :maxdepth: 2
#    :caption: API
#    _autoapi/index

view raw JSON →