首页 > 解决方案 > 狮身人面像:modules.rst:警告:文档不包含在任何目录树中

问题描述

尝试使用 Sphinx 生成文档。

首先使用:sphinx-apidoc 然后使用:sphinx-build html

我收到了有关该modules.rst文件的警告。文件存在,html也生成了,看起来肯定是目录。

我阅读了我能找到的关于该主题的所有主题,没有一个能解决问题(index.rst使用指令在文件中正确定位模块 delation .. include::...)

我不知道该怎么做才能让它工作

这是我的index.rst文件的副本,也许你会看到我没有看到的东西。生成的 rst 文件位于sources文件夹中

Welcome to documentation!
=====================================
    
.. toctree::
   :maxdepth: 4
   :caption: Contents:

   modules

   
Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

我也收到此消息:

..\doc\sphinx\index.rst:4: WARNING: toctree contains reference to nonexisting document u'modules'

如果我用另一个文档替换模块,我会得到以下信息:

\doc\sphinx\index.rst:4: WARNING: toctree contains reference to nonexisting document u'opsimtest'
looking for now-outdated files... none found
pickling environment... done
checking consistency... \doc\sphinx\_apidocs\modules.rst: WARNING: document isn't included in any toctree

所以看起来即使我在 toctree 中命名了另一个文档,它仍在寻找 modules.rst (并且没有看到另一个文档,但是它被构建到一个 html 文件中)

在本主题中:Can't get sphinx to link under toctree to another document the error message states intro.rstinstead of modules.rst. 编辑:正如我所说,不幸的是我已经阅读了其他线程并且他们没有解决我的问题。它还是坏了。

标签: pythonpython-sphinxtoctree

解决方案


在 reST 中,空白是有意义的。指令及其选项必须用空行与其内容隔开。

.. toctree::
    :maxdepth: 4
    :caption: Contents:

    _apidocs/modules

推荐阅读