sphinx-autopackagesummary
This is a Sphinx extension that makes it possible to automatically generate API documentation for deeply nested Python packages using the built-in autosummary extension.
The problem with the built-in autosummary directive is that it does not automatically pick up nested sub-modules, requiring tedious manual work to specify the entire module tree.
Instead of this:
.. autosummary::
:toctree: _autosummary
mypackage.submodule1
mypackage.submodule2
mypackage.submodule3
You can now simply use this:
.. autopackagesummary:: mypackage
:toctree: _autosummary
Usage
To make use of this extension, the following steps are needed:
- Install the module using pip.
pip install sphinx-autopackagesummary
- Enable it in
conf.py.
extensions = ['sphinx.ext.autosummary', 'sphinx_autopackagesummary']
autosummary_generate = True
- Make use of the new syntax
Configuration
The autopackagesummary directive accepts all options that are supported by
autosummary, which are simply passed on.
To exclude packages from being imported, add them to the config setting
autosummary_mock_imports.
Recursive generation
If your packages have subpackages, it is possible to use this recursively by customizing the autosummary template. For example, you could have your root package documented like so:
.. py:package:: mypackage
This is my package.
.. autopackagesummary:: mypackage
:toctree: _autosummary
:template: autosummary/package.rst
And then create a _templates/autosummary/package.rst like so:
{{ fullname | escape | underline }}
.. automodule:: {{ fullname }}
.. autopackagesummary:: {{ fullname }}
:toctree: .
:template: autosummary/package.rst
Alternatively, you can override the default module.rst template.
Note the use of . for the toctree setting: otherwise, the _autosummary
directories would keep nesting, like _autosummary/_autosummary/module.rst.
License
This extension has been placed into the public domain. If you make a contribution to this repository, you are placing your modifications into the public domain as well.
Metadata
Release files for sphinx-autopackagesummary 1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sphinx_autopackagesummary-1.4.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sphinx_autopackagesummary-1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.1 kB
Release files / sphinx_autopackagesummary-1.4.tar.gz
| Download URL | sphinx_autopackagesummary-1.4.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
74addecd928b938311326c98a5f8c82d0780c56148d3bfff1bd7d4fdf056fda6
|
|
BLAKE2b-256 checksum How to use checksums |
ce988d0c9229f990bcd4763e903c919aa535115dfc0394ffbb2aa1ff2e10cca3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / sphinx_autopackagesummary-1.4-py3-none-any.whl
| Download URL | sphinx_autopackagesummary-1.4-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed8f76b9e5face77db07dd3934099402a91f9a0d1069b4d9bd39519c19555be3
|
|
BLAKE2b-256 checksum How to use checksums |
11f0f878ce9c5d23a25c2b4177000bfc911ce5f92fb272ba5b659e494d891fdd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|