Sphinx 错误: 未知指令类型“ automodule”或“ autoclass”

我需要使用 Sphinx 来记录我的 Python 项目,但是我不能使用 autodoc

当我配置我的项目时,我选择了“扩展 autodoc”选项,但是现在如果我使用

.. autoclass:: Class

我得到一个错误:

ERROR: Unknown directive type "autoclass"

我配置了 PYTHONPATH,现在它很好。但是我已经有这个问题了。

我的索引文件是:

.. ATOM documentation master file, created by
sphinx-quickstart on Thu Nov 22 15:24:42 2012.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.


Welcome to ATOM's documentation!
================================


Contents:


.. toctree::
:maxdepth: 2


.. automodule:: atom


Indices and tables
==================


* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
41207 次浏览

The same thing happened to me! To fix it, go to the line in conf.py that says something like this:

extensions = ['sphinx.ext.todo', 'sphinx.ext.viewcode']

Yours will probably look different. Anyway, add 'sphinx.ext.autodoc' to the list. e.g.

extensions = ['sphinx.ext.todo', 'sphinx.ext.viewcode', 'sphinx.ext.autodoc']

If it was:

extensions = []

then you'd change it to:

extensions = ['sphinx.ext.autodoc']

Sources: Sphinx documentation: ERROR: Unknown directive type "program-output"