【问题标题】:Sphinx error: Unknown directive type "automodule" or "autoclass"Sphinx 错误:未知指令类型“automodule”或“autoclass”
【发布时间】:2012-11-11 01:41:08
【问题描述】:

我需要使用 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`

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

谢谢

【问题讨论】:

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

标签: python-sphinx autodoc


【解决方案1】:

同样的事情发生在我身上!要修复它,请转到 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 documentation: ERROR: Unknown directive type "program-output"

【讨论】:

    猜你喜欢
    • 2020-03-15
    • 2012-10-02
    • 1970-01-01
    • 1970-01-01
    • 2019-04-07
    • 1970-01-01
    • 1970-01-01
    • 2011-12-12
    • 1970-01-01
    相关资源
    最近更新 更多