diff --git a/_extensions/odoo/__init__.py b/_extensions/odoo/__init__.py
index e3473c996..e02deaaff 100644
--- a/_extensions/odoo/__init__.py
+++ b/_extensions/odoo/__init__.py
@@ -28,9 +28,9 @@ def setup(app):
app.connect('html-page-context', update_meta)
def update_meta(app, pagename, templatename, context, doctree):
- if not context.get('meta'): # context['meta'] can be None
- context['meta'] = {}
- meta = context.setdefault('meta', {}) # we want {} by default
+ meta = context.get('meta')
+ if meta is None:
+ meta = context['meta'] = {}
meta.setdefault('banner', app.config.odoo_cover_default)
def navbarify(node, navbar=None):
diff --git a/_extensions/odoo/layout.html b/_extensions/odoo/layout.html
index 4c80ed1a3..6eba82ada 100644
--- a/_extensions/odoo/layout.html
+++ b/_extensions/odoo/layout.html
@@ -1,11 +1,11 @@
{% extends "basic/layout.html" %}
-{%- block scripts %}
- {{ super() }}
-
-
-
-
-{%- endblock %}
+
+{% 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 %}
diff --git a/_extensions/odoo/pycompat.py b/_extensions/odoo/pycompat.py
new file mode 100644
index 000000000..804a2a0ba
--- /dev/null
+++ b/_extensions/odoo/pycompat.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+import sys
+
+PY2 = sys.version_info[0] == 2
+
+if PY2:
+ text_type = unicode
+else:
+ text_type = str
+
+def to_text(source):
+ """ Generates a text value (an instance of text_type) from an arbitrary
+ source.
+
+ * False and None are converted to empty strings
+ * text is passed through
+ * bytes are decoded as UTF-8
+ * rest is textified via the current version's relevant data model method
+ """
+ if source is None or source is False:
+ return u''
+
+ if isinstance(source, bytes):
+ return source.decode('utf-8')
+
+ return text_type(source)
+
diff --git a/_extensions/odoo/translator.py b/_extensions/odoo/translator.py
index e2c3710ed..769496f8a 100644
--- a/_extensions/odoo/translator.py
+++ b/_extensions/odoo/translator.py
@@ -2,11 +2,14 @@
import os.path
import posixpath
import re
+import urllib
from docutils import nodes
-from sphinx import addnodes, util, builders
+from sphinx import addnodes, util
from sphinx.locale import admonitionlabels
+from . import pycompat
+
try:
from urllib import url2pathname
except ImportError:
@@ -42,11 +45,6 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
]
def __init__(self, builder, document):
- # 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 = []
@@ -60,7 +58,6 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
self.context = []
self.section_level = 0
- self.config = builder.config
self.highlightlang = self.highlightlang_base = self.builder.config.highlight_language
self.highlightopts = getattr(builder.config, 'highlight_options', {})
@@ -70,7 +67,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
self.param_separator = ','
def encode(self, text):
- return text.strip().translate({
+ return pycompat.to_text(text).translate({
ord('&'): u'&',
ord('<'): u'<',
ord('"'): u'"',
@@ -79,7 +76,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
})
def starttag(self, node, tagname, **attributes):
- tagname = tagname.strip().lower()
+ tagname = pycompat.to_text(tagname).lower()
# extract generic attributes
attrs = {name.lower(): value for name, value in attributes.items()}
@@ -114,7 +111,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
# only "space characters" SPACE, CHARACTER TABULATION, LINE FEED,
# FORM FEED and CARRIAGE RETURN should be collapsed, not al White_Space
def attval(self, value, whitespace=re.compile(u'[ \t\n\f\r]')):
- return self.encode(whitespace.sub(u' ', value.strip()))
+ return self.encode(whitespace.sub(u' ', pycompat.to_text(value)))
def astext(self):
return u''.join(self.body)
@@ -650,7 +647,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
self.body.append(title if title else util.nodes.clean_astext(env.titles[ref]))
self.body.append(u'')
- entries = [(title, ref)] if not toc else ((e[0], e[1]) for e in list(toc)[0]['entries'])
+ entries = [(title, ref)] if not toc else ((e[0], e[1]) for e in toc[0]['entries'])
for subtitle, subref in entries:
baseuri = self.builder.get_target_uri(node['parent'])
diff --git a/requirements.txt b/requirements.txt
index 95726293f..71121d994 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1 @@
-Sphinx>=2.4.0
-Werkzeug==0.14.1
\ No newline at end of file
+Sphinx<2
\ No newline at end of file