Sphinx文档中的条件输出 [英] Conditional output in Sphinx Documentation

查看:159
本文介绍了Sphinx文档中的条件输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用狮身人面像写一些文档,我想打印出一些文字仅适用于HTML文档,不适用于LaTeX文档。有东西告诉我,我应该可以用 sphinx.ext.ifconfig 这样做,但是我无法弄清楚如何。有没有人知道如何做?

解决方案

不需要扩展名。只需使用只有指令 。它的工作原理如下:

 
.. only :: latex

这里的东西只出现在乳胶输出。

.. only :: html

此块中的内容仅显示在HTML输出中。它是
通常有用的使用这个指令:

.. raw :: html

这是很好嵌入的东西,如视频。


I'm writing some documentation with Sphinx and I'd like to print out a certain block of text only for HTML documentation, not for LaTeX documentation. Something tells me I should be able to do this with sphinx.ext.ifconfig but I can't figure out how. Does anyone know how to do this?

解决方案

No extension is required. Just use the only directive. It works like this:

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

这篇关于Sphinx文档中的条件输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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