Skip to main content
 首页 » 编程设计

python-sphinx之禁用单个 Sphinx 警告消息

2024年11月24日25arxive

我有很多 .rst我的 Sphinx 树中有意从任何索引树中排除的文件。我收到类似的警告

 /filename.rst:: WARNING: document isn't included in any toctree 

如何抑制 Sphinx 中的特定警告?

请您参考如下方法:

  • 您的 Sphinx 项目中是否有 .rst 文件,您不希望其内容出现在输出中?
    使用 exclude_patterns配置变量。对于与指定模式匹配的文件,不会生成任何输出(也不会生成警告消息)。见 http://www.sphinx-doc.org/en/master/usage/configuration.html#confval-exclude_patterns .
  • 您的 Sphinx 项目中是否有不属于任何目录树但其内容应在输出中的 .rst 文件?
    添加 :orphan:在每个 .rst 文件的顶部以禁止显示警告消息。见 http://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html#file-wide-metadata