关于toctree引用的警告
Contents:
.. toctree::
:maxdepth: 2
foo.rst
bar.rst
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
我正在尝试使用 sphinx-build . doc
来构建它,但出现了警告:
(WARNING/2) toctree references unknown document u'bar'
这可能是什么原因呢?
2 个回答
2
我也遇到了这个错误。对我来说,问题出在缩进上。我的“toctree”缩进了3个空格,而我列出的rst文件缩进了4个空格。要解决这个问题,我们需要保持缩进的层级一致。
3
Sphinx在toctree指令中其实不需要加上.rst
这个后缀。假设你的toctree文件是在像index.rst
这样的文件里,而bar.rst
和它在同一个文件夹里,你可以试着把toctree指令中的foo.rst
和bar.rst
改成foo
和bar
,去掉后缀。
另外,要确保bar.rst
在正确的文件夹里,不要放在上级文件夹或者子文件夹里。