Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditionally include extensions?

There's a ifconfig sphinx extension -- and it allows for conditional inclusion of content. I'm looking for a way to conditionally include extensions. My best try is just to give a list of extensions with a -D option to 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

but it doesn't work.

The problem is to conditionally include sphinx.ext.htmlmath or sphinxcontrib.mathml.

like image 560
Adobe Avatar asked May 31 '13 18:05

Adobe


1 Answers

Use -t <tag> http://sphinx-doc.org/invocation.html#cmdoption-sphinx-build-t

e.g. Invoke sphinx like this (See -t use_htmlmath):

sphinx-build -b singlehtml -d _build/doctrees \
   -D html_theme=empty -t use_htmlmath . _build/wkA

Have this code in conf.py

if tags.has('use_htmlmath'):
    # use supplied =t use_htmlmath
    extensions.append('sphinx.ext.htmlmath')
else:
    #fall back
    extensions.append('sphinxcontrib-mathml')
like image 166
purnank Avatar answered Sep 24 '22 02:09

purnank