Autodoc-Style Directives#

You can opt to write API documentation yourself using autodoc style directives. These directives work similarly to autodoc, but docstrings are retrieved through static analysis instead of through imports.

See also

When transitioning to autodoc-style documentation, you may want to turn the autoapi_generate_api_docs option off so that automatic API documentation is no longer generated.

To use these directives you will need to enable the autodoc extension in your Sphinx project’s

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

For Python, all directives have an autodoc equivalent and accept the same options. The following directives are available:

.. autoapimodule::#
.. autoapiclass::#
.. autoapiexception::#

Equivalent to automodule, autoclass, and autoexception respectively. autodoc_inherit_docstrings does not currently work.

.. autoapifunction::#
.. autoapidata::#
.. autoapimethod::#
.. autoapiattribute::#

Equivalent to autofunction, autodata, automethod, and autoattribute respectively.

Inheritance Diagrams#

.. autoapi-inheritance-diagram::#

This directive uses the sphinx.ext.inheritance_diagram extension to create inheritance diagrams for classes.

For example:

Inheritance diagram of autoapi.mappers.python.objects.PythonModule, autoapi.mappers.python.objects.PythonPackage

sphinx.ext.inheritance_diagram makes use of the sphinx.ext.graphviz extension, and therefore it requires Graphviz to be installed.

The directive can be configured using the same options as sphinx.ext.inheritance_diagram.