如何在sphinx.writers.html使用与Sphinx sphinx.writers.html ?
具体来说,我想修改方法depart_desc_signature 。 我无法修改Sphinx本身,因为帮助文件正在与其他人一起开发,需要使用标准Sphinx正确编译。
我知道Sphinx支持:
扩展模块: http : //sphinx-doc.org/ext/appapi.html 自定义构建器: http : //sphinx-doc.org/ext/builderapi.htmlHow can I use a different HTMLTranslator than the one that ships with Sphinx in sphinx.writers.html?
Specifically, I want to modify the method depart_desc_signature. I can't modify Sphinx itself because the help files are being developed with others and need to compile correctly with standard Sphinx.
I know Sphinx supports:
extension modules: http://sphinx-doc.org/ext/appapi.html custom builders: http://sphinx-doc.org/ext/builderapi.html最满意答案
通过在conf.py定义html_translator_class来指定html转换conf.py 。
例如,
html_translator_class = 'html2.HTMLTranslator'这对mathjax来说效果不好,所以如果html2是html2的副本,你需要显式地将对mathjax的调用添加到HTMLTranslator:
def visit_displaymath(self, node): import sphinx.ext.mathjax sphinx.ext.mathjax.html_visit_displaymath(self, node) def depart_displaymath(self, node): return def visit_math(self, node): import sphinx.ext.mathjax sphinx.ext.mathjax.html_visit_math(self, node) def depart_math(self, node): returnSpecify an html translator by defining an html_translator_class in conf.py.
For example,
html_translator_class = 'html2.HTMLTranslator'This does not play nice with mathjax though, so if html2 is otherwise a copy of sphinx.writers.html, you need to explicitly add calls to mathjax to HTMLTranslator:
def visit_displaymath(self, node): import sphinx.ext.mathjax sphinx.ext.mathjax.html_visit_displaymath(self, node) def depart_displaymath(self, node): return def visit_math(self, node): import sphinx.ext.mathjax sphinx.ext.mathjax.html_visit_math(self, node) def depart_math(self, node): return更多推荐
发布评论