AutoAPI
Generate complete API documentation without needing to load, run, or import the project being documented.
python
About this Extension
Automatically generates API documentation from your Python source code by parsing files statically. Unlike autodoc, it doesn’t import your code, making it safer and more reliable for complex projects.
Advantages over autodoc
- No imports required: Parses source code directly without importing modules
- Safer: Won’t execute code during documentation building
- Handles dependencies: Works even when dependencies aren’t installed
- Better for CI/CD: No need to install your package in the build environment
- Cross-references: Automatically links between related classes and functions
What it generates
- Full API reference with classes, functions, and modules
- Inheritance diagrams showing class relationships
- Cross-references between related code elements
- Automatic table of contents for your API
- Integration with your existing documentation structure
Configuration
# conf.py
extensions = ['autoapi.extension']
# Required: specify what to document
autoapi_dirs = ['src/mypackage']
# Optional: customize output
autoapi_type = 'python'
autoapi_file_patterns = ['*.py']
autoapi_generate_api_docs = True
autoapi_add_toctree_entry = False # Don't auto-add to main toc
# Optional: control what's included
autoapi_options = [
'members',
'undoc-members',
'show-inheritance',
'show-module-summary',
]
When to use AutoAPI vs autodoc
Use AutoAPI when:
- Your code has complex dependencies
- Building docs in CI without installing your package
- You want comprehensive API docs without manual docstring imports
- Working with large codebases
Use autodoc when:
- You need fine control over what’s documented
- Your code is simple to import
- You’re already using autodoc successfully
Particularly valuable for libraries and packages where you want complete API coverage without the complexity of managing imports during doc builds.