Ado*_*obe 5 python python-sphinx
有一个ifconfigsphinx扩展 - 它允许有条件地包含内容.我正在寻找一种有条件地包含扩展的方法.我最好的尝试只是提供一个扩展列表,其中包含以下-D选项sphinx-build:
sphinx-build -b singlehtml -d _build/doctrees -D html_theme=empty -D "extensions=['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.numfig', 'sphinx.ext.ifconfig', 'cloud_sptheme.ext.table_styling', 'sphinx.ext.htmlmath']" . _build/wkA
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
问题是有条件地包括sphinx.ext.htmlmath或sphinxcontrib.mathml.
小智 5
使用-t <tag> http://sphinx-doc.org/invocation.html#cmdoption-sphinx-build-t
例如像这样调用 sphinx (参见-t use_htmlmath):
sphinx-build -b singlehtml -d _build/doctrees \
-D html_theme=empty -t use_htmlmath . _build/wkA
Run Code Online (Sandbox Code Playgroud)
将此代码放入conf.py
if tags.has('use_htmlmath'):
# use supplied =t use_htmlmath
extensions.append('sphinx.ext.htmlmath')
else:
#fall back
extensions.append('sphinxcontrib-mathml')
Run Code Online (Sandbox Code Playgroud)