Sphinx文档中的条件输出
我正在用 Sphinx 写一些文档,我想只在HTML文档中打印出一段特定的文字,而在LaTeX文档中不打印。这让我觉得我应该可以用 sphinx.ext.ifconfig
来实现,但我不知道该怎么做。有没有人知道怎么做这个?
1 个回答
29
不需要任何扩展,只需使用 only
指令。
(这是一个旧链接,来自2010年的原始帖子)
https://web.archive.org/web/20100129001557/http://sphinx.pocoo.org/markup/misc.html#including-content-based-on-tags
它的工作原理是这样的:
.. only:: latex The stuff in here only appears in the latex output. .. only:: html The stuff in this block only appears in the HTML output. It's often useful to use this directive with it: .. raw:: html It's good for embedding stuff, like video.