【问题标题】:Unknown directive type "toctree". Error in Pycharm, but index.html works未知指令类型“toctree”。 Pycharm 中的错误,但 index.html 有效
【发布时间】:2019-04-07 09:58:00
【问题描述】:

在 PyCharm 中工作时,我在 Sphinx 中创建的文档的预览模式显示:

System Message: ERROR/3 (<stdin>, line 9)

Unknown directive type "toctree".

..toctree::
 :maxdepth: 2

file1
file2

我在我的 conf.py 文件中包含了 autodoc 扩展名。当我打开 /build/index.html 文件时,它工作正常。因此,我的问题是:如何从 PyCharm 预览模式中删除此错误,以便无需一直打开 /build/index.html 文件即可预览文档?

【问题讨论】:

  • Sphinx 构建在 Docutils 库之上。 toctree 指令适用于 Sphinx,但不仅仅适用于 Docutils。 PyCharm 预览器不使用 Sphinx;它可能使用 Docutils rst2html.py 工具。见grokbase.com/t/python/python-list/086kaqv52v/…
  • @mzjn 谢谢,遇到了类似的问题,后来发现社区版没有这个功能。

标签: pycharm python-sphinx preview autodoc toctree


【解决方案1】:

Sphinx 构建在 Docutils 库之上。 toctree 指令适用于 Sphinx,但 Docutils 无法识别。

PyCharm 预览器不使用 Sphinx(免费社区版和 2019 年的专业版都是如此);它可能使用来自 Docutils 的rst2html.py

这个邮件列表线程也出现了同样的错误:https://web.archive.org/web/20180715103227/https://mail.python.org/pipermail/python-list/2008-June/493826.html

【讨论】:

    猜你喜欢
    • 2012-11-11
    • 2012-10-02
    • 2011-02-16
    • 1970-01-01
    • 2011-12-12
    • 1970-01-01
    • 2017-07-13
    • 2017-12-27
    • 1970-01-01
    相关资源
    最近更新 更多