Sphinx: Unknown directive type “toctree”. error in

2020-03-09 08:54发布

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

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?

1条回答
狗以群分
2楼-- · 2020-03-09 09:19

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

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.

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

查看更多
登录 后发表回答