Browse Source

[FIX] odoo: compatibility sphinx2

Cherry-pick of odoo/odoo@2b28dd89b8b767611
pull/359/head
Xavier Morel 3 months ago
parent
commit
da7f9932cc
3 changed files with 14 additions and 10 deletions
  1. 7
    1
      _extensions/odoo/__init__.py
  2. 0
    7
      _extensions/odoo/layout.html
  3. 7
    2
      _extensions/odoo/translator.py

+ 7
- 1
_extensions/odoo/__init__.py View File

@@ -21,6 +21,10 @@ def setup(app):
location="odoo extension")
app.config.html_translator_class = 'odoo.translator.BootstrapTranslator'

add_js_file = getattr(app, 'add_js_file', None) or app.add_javascript
for f in ['jquery.min.js', 'bootstrap.js', 'doc.js', 'jquery.noconflict.js']:
add_js_file(f)

switcher.setup(app)
app.add_config_value('odoo_cover_default', None, 'env')
app.add_config_value('odoo_cover_external', {}, 'env')
@@ -28,7 +32,9 @@ def setup(app):
app.connect('html-page-context', update_meta)

def update_meta(app, pagename, templatename, context, doctree):
meta = context.setdefault('meta', {})
meta = context.get('meta')
if meta is None:
meta = context['meta'] = {}
meta.setdefault('banner', app.config.odoo_cover_default)

def navbarify(node, navbar=None):

+ 0
- 7
_extensions/odoo/layout.html View File

@@ -1,12 +1,5 @@
{% extends "basic/layout.html" %}

{% set script_files = script_files + [
'_static/jquery.min.js',
'_static/bootstrap.js',
'_static/doc.js',
'_static/jquery.noconflict.js',
] %}

{% set classes = [] %}
{% if pagename == master_doc %}
{% set classes = classes + ['index'] %}

+ 7
- 2
_extensions/odoo/translator.py View File

@@ -5,7 +5,7 @@ import re
import urllib

from docutils import nodes
from sphinx import addnodes, util
from sphinx import addnodes, util, builders
from sphinx.locale import admonitionlabels

from . import pycompat
@@ -44,7 +44,12 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
'<meta name="viewport" content="width=device-width, initial-scale=1">'
]

def __init__(self, builder, document):
def __init__(self, document, builder):
# order of parameter swapped between Sphinx 1.x and 2.x, check if
# we're running 1.x and swap back
if not isinstance(builder, builders.Builder):
builder, document = document, builder

super(BootstrapTranslator, self).__init__(document)
self.builder = builder
self.body = []

Loading…
Cancel
Save