Skip to main content
 首页 » 编程设计

python-sphinx之警告 : document isn't included in any toctree for included file

2024年05月10日134落叶

我收到警告:

WARNING: document isn't included in any toctree 

适用于文档中存在的文件,因为它们已被明确包含。所以我有索引文件:

.. toctree:: 
    :maxdepth: 2 
 
   pages/0010-foo 
   pages/0020-bar 

在文件 0020-bar.rst 中,我特别包含了许多其他文件,如下所示:

.. contents:: :local: 
 
.. include:: /pages/reference-architecture/technical-considerations/0070-baz.rst 

但是当我构建项目时,我仍然收到一条警告,提示 0070-baz.rst 不在任何目录树中,如下所示:

/home/nick/Documents/myProject/docs/pages/reference-architecture/technical-considerations/0070-baz.rst:: WARNING: document isn't included in any toctree 

奇怪的是我可以看到输出中的内容。这是正常的吗?对于显式包含而不是通过 toctree 包含的文件,是否总是出现此警告?

请您参考如下方法:

如果您只想在另一个文档中 ..include:: 一个文档,而不让它出现在任何 toctree 中。

:orphan: 添加到文档顶部以消除警告。

这是一个文件范围元数据选项。阅读更多信息 Sphinx documentation .