Python sphinx 什么';斯芬克斯与x27的区别是什么;s";只有";及;ifconfig";指令?

Python sphinx 什么';斯芬克斯与x27的区别是什么;s";只有";及;ifconfig";指令?,python-sphinx,restructuredtext,conditional-compilation,Python Sphinx,Restructuredtext,Conditional Compilation,Sphinx知道条件内容的两个指令: 仅=> ifconfig=> 它们之间有什么区别?仅此而已 only指令用于基于标记包含/排除内容标记: 在conf.py中(此用法使仅与ifconfig非常相似) 将-t标志用于sphinx build(不能用作make的标志,因为-t是-触摸make的标志) 例如:rst .. only:: draft This message only appears in drafts. .. only:: html This message

Sphinx知道条件内容的两个指令:

  • 仅=>
  • ifconfig=>
它们之间有什么区别?

仅此而已
only
指令用于基于
标记包含/排除内容<可以指定代码>标记

  • 在conf.py中(此用法使
    ifconfig
    非常相似)
  • -t
    标志用于
    sphinx build
    (不能用作
    make
    的标志,因为
    -t
    -触摸
    make
    标志)

    例如:rst

    .. only:: draft
    
       This message only appears in drafts.
    
    .. only:: html
    
       This message only appears in HTML output.
    
    命令

    $ sphinx-build  -t draft  -b html -d _build/doctrees . _build/html
    
    $ make html
    
  • 生成器的格式或名称这是
    唯一发光的地方
    <代码>。。仅当您使用
    makehtml
    等时,才会生成::html
    内容

    例如:rst

    .. only:: draft
    
       This message only appears in drafts.
    
    .. only:: html
    
       This message only appears in HTML output.
    
    命令

    $ sphinx-build  -t draft  -b html -d _build/doctrees . _build/html
    
    $ make html
    
  • ifconfig
    ifconfig
    使您能够灵活地根据任何Python表达式的真实性包含内容,该表达式涉及在conf.py中注册的配置变量。但是,这意味着您必须编辑conf.py以更改内容是包含还是排除

    结论 如果您希望在不编辑conf.py的情况下更改内容,则只需
    。 例如,我仅使用
    将目录(
    contents
    directive)包含在HTML文档中,而不包含在pdf文档中(因为LaTeX自己生成目录)