Sphinx Contrib Apidoc

0.6.0 · maintenance · verified Thu Apr 16

sphinxcontrib-apidoc is a Sphinx extension designed to automate the process of running `sphinx-apidoc` on each build, thereby generating API documentation from Python packages. It streamlines the integration of API documentation into Sphinx projects. The current version is 0.6.0. This project is in maintenance mode, as Sphinx 8.2.0 and newer include a built-in extension offering similar functionality, and new users are encouraged to use the native Sphinx extension instead. [1, 9]

Common errors

Warnings

Install

Imports

Quickstart

To quickly integrate `sphinxcontrib-apidoc`, first ensure it's installed. Then, edit your Sphinx `conf.py` file to add `'sphinxcontrib.apidoc'` to your `extensions` list. Crucially, configure `apidoc_module_dir` to point to the root of your Python package, relative to `conf.py`. You should also specify `apidoc_output_dir` for where the generated reStructuredText files will reside, and optionally, `apidoc_excluded_paths` to skip unwanted modules or directories. Finally, include the generated TOC file (e.g., 'api_reference/index') in your main documentation's `toctree`. [9]

import os
import sys

sys.path.insert(0, os.path.abspath('.'))

# conf.py in your Sphinx documentation source directory

project = 'MyProject'
copyright = '2023, MyAuthor'
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.napoleon',
    'sphinxcontrib.apidoc'
]

# --- sphinxcontrib-apidoc specific configuration ---
# Path to the Python package to document (relative to conf.py)
apidoc_module_dir = '../../my_python_package'
# Output directory for generated API docs (relative to conf.py)
apidoc_output_dir = 'api_reference'
# Exclude 'tests' directory from API generation
apidoc_excluded_paths = ['tests']
# Put documentation for each module on its own page
apidoc_separate_modules = True
# Filename for a table of contents file (defaults to 'modules')
apidoc_toc_file = 'index'
# End of sphinxcontrib-apidoc specific configuration ---

html_theme = 'alabaster'

view raw JSON →