禁用单个Sphinx警告消息

时间:2012-10-17 09:23:58

标签: python-sphinx

我的Sphinx树中有很多.rst个文件,故意从任何索引树中排除。我得到像

这样的警告
 /filename.rst:: WARNING: document isn't included in any toctree

如何在Sphinx中禁止特定警告?

1 个答案:

答案 0 :(得分:33)

  1. 您的Sphinx项目中是否存在您不希望输出内容的.rst文件?

    使用exclude_patterns配置变量。对于与指定模式匹配的文件,不会生成输出(也没有警告消息)。请参阅http://sphinx-doc.org/config.html#confval-exclude_patterns

  2. 您的Sphinx项目中是否有.rst文件不属于任何toctree,但其内容应该在输出中?

    在每个.rst文件的顶部添加:orphan:以禁止显示警告消息。请参阅http://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html#file-wide-metadata