我如何使用HTMLTranslator与 Sphinx 附带的不同的sphinx.writers.html?
具体来说,我想修改方法depart_desc_signature。我无法修改 Sphinx 本身,因为帮助文件正在与其他人一起开发,并且需要使用标准 Sphinx 正确编译。
我知道 Sphinx 支持:
我如何使用HTMLTranslator与 Sphinx 附带的不同的sphinx.writers.html?
具体来说,我想修改方法depart_desc_signature。我无法修改 Sphinx 本身,因为帮助文件正在与其他人一起开发,并且需要使用标准 Sphinx 正确编译。
我知道 Sphinx 支持:
html_translator_class通过定义in来指定 html 翻译器conf.py。
例如,
html_translator_class = 'html2.HTMLTranslator'
不过,这与 mathjax 不兼容,因此如果html2是 的副本sphinx.writers.html,则需要显式添加对 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):
return