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


76

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

当我配置我的项目时,我选择选项“ extension 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`

我需要有人告诉我如何解决该问题。

谢谢


13
conf.py的extensions配置变量中是否包含“ sphinx.ext.autodoc” ?
mzjn 2012年

Answers:


122

这样的事情我也经历过!要解决此问题,请转至conf.py中的行,内容如下:

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

您的外观可能会有所不同。无论如何,添加'sphinx.ext.autodoc'到列表中。例如

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

如果它是:

extensions = []

然后将其更改为:

extensions = ['sphinx.ext.autodoc']

来源:Sphinx文档:错误:未知的指令类型“程序输出”

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.