[FIX] 1.2 compatibility

app.add_node doesn't work right for custom translators in 1.2, since
mementos are using ``h:div`` reimplement that in the
BootstrapTranslator.

Alternative would be to monkeypatch app.add_node for Sphinx 1.2, but
let's not do that...
This commit is contained in:
Xavier Morel 2015-11-20 11:37:18 +01:00
parent fbea64a257
commit e2204cdd72
2 changed files with 16 additions and 1 deletions

View File

@ -8,7 +8,10 @@ import sphinx.environment
import sphinx.builders.html
from docutils import nodes
def setup(app):
app.set_translator('html', translator.BootstrapTranslator)
if getattr(app.config, 'html_translator_class', None):
app.warn("Overriding the explicitly set html_translator_class setting",
location="odoo extension")
app.config.html_translator_class = 'odoo.translator.BootstrapTranslator'
switcher.setup(app)
app.add_config_value('odoo_cover_default', None, 'env')

View File

@ -677,3 +677,15 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
# internal node
def visit_substitution_definition(self, node): raise nodes.SkipNode
# without set_translator, add_node doesn't work correctly, so the
# serialization of html_domain nodes needs to be embedded here
def visit_div(self, node):
self.body.append(self.starttag(node, 'div'))
def depart_div(self, node):
self.body.append(u'</div>\n')
def visit_address(self, node):
self.body.append(self.starttag(node, 'address'))
def depart_address(self, node):
self.body.append(u'</address>')
# TODO: inline elements