如何配置Sphinx有条件地排除某些页面? [英] How can I configure Sphinx to conditionally exclude some pages?

查看:100
本文介绍了如何配置Sphinx有条件地排除某些页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Sphinx生成文档时,我希望能够生成两个版本的文档:一个包含所有内容,一个仅包含一组特定页面。实现此目标的最佳方法是什么?

When generating documentation using Sphinx, I would like to be able to generate two versions of my documentation: one including everything, and one with only a particular set of pages. What's the best way of achieving that?

我可以编写一个构建脚本来移动文件以实现此目标,但是如果有一种方法可以告诉狮身人面像,那将非常好在特定构建期间排除或包含特定文档。

I could write a build script that moves files around to achieve this but it would be really nice if there was a way to tell sphinx to exclude or include particular documents during a particular build.

推荐答案

only ifconfig 指令可以用于在页面内应用条件。

The only and ifconfig directives can be used to apply conditions within pages.

似乎没有简单的方法可以完全排除整个页面(.rst文件)。

There does not seem to be any simple way to use conditions to completely exclude entire pages (.rst files).

以下(在index.rst中)在生成HTML输出时在index.html的toctree中排除对doc2.html的引用:

The following (in index.rst) excludes the reference to doc2.html in the toctree in index.html when generating HTML output:

.. toctree::
   doc1.rst

.. only:: latex

   .. toctree::
      doc2.rst

但这确实不起作用。仍会生成doc2.html文件,当doc1.html是当前主题时,可以通过下一个主题链接访问该文件。

But this does not really work. The doc2.html file is still generated, and it is reachable via the "Next topic" link when doc1.html is the current topic.

这篇关于如何配置Sphinx有条件地排除某些页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆