指令¶
Autodoc 风格指令¶
您可以选择使用 autodoc 风格的指令自行编写 API 文档。这些指令的工作方式与 autodoc 类似,但文档字符串是通过静态分析而不是通过导入来获取的。
参见
当过渡到 autodoc 风格的文档时,您可能希望关闭 autoapi_generate_api_docs
选项,以便不再自动生成 API 文档。
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
, andautoexception
respectively.autodoc_inherit_docstrings
does not currently work.
- .. autoapifunction::¶
- .. autoapidata::¶
- .. autoapimethod::¶
- .. autoapiattribute::¶
Equivalent to
autofunction
,autodata
,automethod
, andautoattribute
respectively.
Inheritance Diagrams¶
- .. autoapi-inheritance-diagram::¶
This directive uses the
sphinx.ext.inheritance_diagram
extension to create inheritance diagrams for classes.For example:
sphinx.ext.inheritance_diagram
makes use of thesphinx.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
.