[IMP] technical: allow building with Python3 and Sphinx 2.X
Before this commit, sphinx-build could not be used with Python3 and Sphinx 2.X.
This commit is contained in:
parent
038446bae4
commit
dbba515566
@ -32,9 +32,9 @@ def setup(app):
|
|||||||
app.connect('html-page-context', update_meta)
|
app.connect('html-page-context', update_meta)
|
||||||
|
|
||||||
def update_meta(app, pagename, templatename, context, doctree):
|
def update_meta(app, pagename, templatename, context, doctree):
|
||||||
meta = context.get('meta')
|
if not context.get('meta'): # context['meta'] can be None
|
||||||
if meta is None:
|
context['meta'] = {}
|
||||||
meta = context['meta'] = {}
|
meta = context.setdefault('meta', {}) # we want {} by default
|
||||||
meta.setdefault('banner', app.config.odoo_cover_default)
|
meta.setdefault('banner', app.config.odoo_cover_default)
|
||||||
|
|
||||||
def navbarify(node, navbar=None):
|
def navbarify(node, navbar=None):
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
# -*- 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)
|
|
||||||
|
|
@ -2,14 +2,11 @@
|
|||||||
import os.path
|
import os.path
|
||||||
import posixpath
|
import posixpath
|
||||||
import re
|
import re
|
||||||
import urllib
|
|
||||||
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
from sphinx import addnodes, util, builders
|
from sphinx import addnodes, util, builders
|
||||||
from sphinx.locale import admonitionlabels
|
from sphinx.locale import admonitionlabels
|
||||||
|
|
||||||
from . import pycompat
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from urllib import url2pathname
|
from urllib import url2pathname
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -63,6 +60,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
|||||||
self.context = []
|
self.context = []
|
||||||
self.section_level = 0
|
self.section_level = 0
|
||||||
|
|
||||||
|
self.config = builder.config
|
||||||
self.highlightlang = self.highlightlang_base = self.builder.config.highlight_language
|
self.highlightlang = self.highlightlang_base = self.builder.config.highlight_language
|
||||||
self.highlightopts = getattr(builder.config, 'highlight_options', {})
|
self.highlightopts = getattr(builder.config, 'highlight_options', {})
|
||||||
|
|
||||||
@ -72,7 +70,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
|||||||
self.param_separator = ','
|
self.param_separator = ','
|
||||||
|
|
||||||
def encode(self, text):
|
def encode(self, text):
|
||||||
return pycompat.to_text(text).translate({
|
return text.strip().translate({
|
||||||
ord('&'): u'&',
|
ord('&'): u'&',
|
||||||
ord('<'): u'<',
|
ord('<'): u'<',
|
||||||
ord('"'): u'"',
|
ord('"'): u'"',
|
||||||
@ -81,7 +79,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
|||||||
})
|
})
|
||||||
|
|
||||||
def starttag(self, node, tagname, **attributes):
|
def starttag(self, node, tagname, **attributes):
|
||||||
tagname = pycompat.to_text(tagname).lower()
|
tagname = tagname.strip().lower()
|
||||||
|
|
||||||
# extract generic attributes
|
# extract generic attributes
|
||||||
attrs = {name.lower(): value for name, value in attributes.items()}
|
attrs = {name.lower(): value for name, value in attributes.items()}
|
||||||
@ -116,7 +114,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
|||||||
# only "space characters" SPACE, CHARACTER TABULATION, LINE FEED,
|
# only "space characters" SPACE, CHARACTER TABULATION, LINE FEED,
|
||||||
# FORM FEED and CARRIAGE RETURN should be collapsed, not al White_Space
|
# FORM FEED and CARRIAGE RETURN should be collapsed, not al White_Space
|
||||||
def attval(self, value, whitespace=re.compile(u'[ \t\n\f\r]')):
|
def attval(self, value, whitespace=re.compile(u'[ \t\n\f\r]')):
|
||||||
return self.encode(whitespace.sub(u' ', pycompat.to_text(value)))
|
return self.encode(whitespace.sub(u' ', value.strip()))
|
||||||
|
|
||||||
def astext(self):
|
def astext(self):
|
||||||
return u''.join(self.body)
|
return u''.join(self.body)
|
||||||
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Sphinx>=2.4.0
|
||||||
|
Werkzeug==0.14.1
|
Loading…
Reference in New Issue
Block a user