Sphinx文档中的条件输出

时间:2010-02-07 01:29:35

标签: python documentation python-sphinx

我正在用Sphinx编写一些文档,我想打印出一些仅用于HTML文档的文本块,而不是用于LaTeX文档。有些东西告诉我,我应该能够用sphinx.ext.ifconfig做到这一点,但我无法弄清楚如何做到这一点。有谁知道怎么做?

1 个答案:

答案 0 :(得分:27)

无需延期。只需使用only directive即可。它的工作原理如下:

.. 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.