Sphinx:未知指令类型"toctree".Pycharm中的错误,但index.html有效

Wou*_*ter 11 preview pycharm python-sphinx autodoc

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

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

Unknown directive type "toctree".

..toctree::
  :maxdepth: 2

  file1
  file2
Run Code Online (Sandbox Code Playgroud)

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

mzj*_*zjn 6

Sphinx建立在Docutils库的顶部。该toctree指令可用于Sphinx,但Docutils无法识别。

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

此邮件列表线程大约具有相同的错误:https : //mail.python.org/pipermail/python-list/2008-June/493826.html