Directives#

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 conf.py:

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:

digraph inheritance22e02630af { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "PythonMapperBase" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Base object for JSON -> Python object mapping."]; "PythonModule" [URL="templates.html#autoapi.mappers.python.objects.PythonModule",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="The representation of a module."]; "TopLevelPythonPythonMapper" -> "PythonModule" [arrowsize=0.5,style="setlinewidth(0.5)"]; "PythonPackage" [URL="templates.html#autoapi.mappers.python.objects.PythonPackage",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="The representation of a package."]; "TopLevelPythonPythonMapper" -> "PythonPackage" [arrowsize=0.5,style="setlinewidth(0.5)"]; "PythonPythonMapper" [URL="templates.html#autoapi.mappers.python.objects.PythonPythonMapper",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A base class for all types of representations of Python objects."]; "PythonMapperBase" -> "PythonPythonMapper" [arrowsize=0.5,style="setlinewidth(0.5)"]; "TopLevelPythonPythonMapper" [URL="templates.html#autoapi.mappers.python.objects.TopLevelPythonPythonMapper",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A common base class for modules and packages."]; "PythonPythonMapper" -> "TopLevelPythonPythonMapper" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

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.