未知的指令类型“ toctree”。 Pycharm中的错误,但是index.html可以工作 [英] Unknown directive type "toctree". Error in Pycharm, but index.html works

查看:381
本文介绍了未知的指令类型“ toctree”。 Pycharm中的错误,但是index.html可以工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When working in PyCharm, the preview mode of the document I am creating in Sphinx shows:


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文件就可以预览文档?

I have included the autodoc extension in my conf.py file. When I open the /build/index.html file, it works fine however. My question thus is: How can I remove this error from the PyCharm preview mode, so that I can preview my document without having to open the /build/index.html file all the time?

推荐答案

Sphinx构建在Docutils库的顶部。 toctree 指令可与Sphinx一起使用,但Docutils无法识别。

Sphinx is built on top of the Docutils library. The toctree directive works with Sphinx, but it is not recognized by Docutils.

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

The PyCharm previewer does not use Sphinx (this is true for the free community edition and for Professional editions as of 2019); it likely uses rst2html.py from Docutils.

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

This mailing list thread is about the same error: https://web.archive.org/web/20180715103227/https://mail.python.org/pipermail/python-list/2008-June/493826.html

这篇关于未知的指令类型“ toctree”。 Pycharm中的错误,但是index.html可以工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆