[EXT][DIFF] Use dev doc odoo theme ext ?
Analyze conflicts and resolve
This commit is contained in:
parent
f6d651d2db
commit
6fcd48070a
@ -1,8 +1,8 @@
|
||||
import inspect
|
||||
import importlib
|
||||
import os.path
|
||||
import werkzeug
|
||||
|
||||
from werkzeug import urls
|
||||
|
||||
"""
|
||||
* adds github_link(mode) context variable: provides URL (in relevant mode) of
|
||||
@ -22,7 +22,7 @@ Notes
|
||||
|
||||
* provided ``linkcode_resolve`` only supports Python domain
|
||||
* generates https github links
|
||||
* explicitly imports ``openerp``, so useless for anyone else
|
||||
* explicitly imports ``odoo``, so useless for anyone else
|
||||
"""
|
||||
|
||||
def setup(app):
|
||||
@ -63,9 +63,9 @@ def setup(app):
|
||||
# obj doesn't have a module, or something
|
||||
return None
|
||||
|
||||
import openerp
|
||||
import odoo
|
||||
# FIXME: make finding project root project-independent
|
||||
project_root = os.path.join(os.path.dirname(openerp.__file__), '..')
|
||||
project_root = os.path.join(os.path.dirname(odoo.__file__), '..')
|
||||
return make_github_link(
|
||||
app,
|
||||
os.path.relpath(obj_source_path, project_root),
|
||||
@ -82,25 +82,24 @@ def make_github_link(app, path, line=None, mode="blob"):
|
||||
path=path,
|
||||
mode=mode,
|
||||
)
|
||||
return werkzeug.urls.url_unparse((
|
||||
return urls.url_unparse((
|
||||
'https',
|
||||
'github.com',
|
||||
urlpath,
|
||||
'',
|
||||
'' if line is None else 'L%d' % line
|
||||
))
|
||||
|
||||
def add_doc_link(app, pagename, templatename, context, doctree):
|
||||
""" Add github_link function linking to the current page on github """
|
||||
if not app.config.github_user and app.config.github_project:
|
||||
return
|
||||
|
||||
# FIXME: find other way to recover current document's source suffix
|
||||
# in Sphinx 1.3 it's possible to have mutliple source suffixes and that
|
||||
# may be useful in the future
|
||||
source_suffix = app.config.source_suffix
|
||||
source_suffix = next(iter(source_suffix))
|
||||
# FIXME: odoo/odoo has a doc/ prefix which is incorrect for this
|
||||
# project, how to unify? Add new setting?
|
||||
# in 1.3 source_suffix can be a list
|
||||
# in 1.8 source_suffix can be a mapping
|
||||
# FIXME: will break if we ever add support for !rst markdown documents maybe
|
||||
if not isinstance(source_suffix, str):
|
||||
source_suffix = next(iter(source_suffix))
|
||||
# can't use functools.partial because 3rd positional is line not mode
|
||||
context['github_link'] = lambda mode='edit': make_github_link(
|
||||
app, '%s%s' % (pagename, source_suffix), mode=mode)
|
||||
app, 'doc/%s%s' % (pagename, source_suffix), mode=mode)
|
||||
|
@ -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,9 +32,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):
|
||||
@ -107,13 +111,7 @@ if toctree:
|
||||
def resolve(old_resolve, tree, docname, *args, **kwargs):
|
||||
if docname == tree.env.config.master_doc:
|
||||
return resolve_content_toctree(tree.env, docname, *args, **kwargs)
|
||||
toc = old_resolve(tree, docname, *args, **kwargs)
|
||||
if toc is None:
|
||||
return None
|
||||
|
||||
navbarify(toc[0], navbar=kwargs.pop('navbar', None))
|
||||
return toc
|
||||
|
||||
return old_resolve(tree, docname, *args, **kwargs)
|
||||
|
||||
@monkey(sphinx.environment.BuildEnvironment)
|
||||
def resolve_toctree(old_resolve, self, docname, *args, **kwargs):
|
||||
|
@ -1,7 +1,7 @@
|
||||
{# warning: if doc structure change, these rules may have to change as well #}
|
||||
|
||||
{# ===== VARIABLES ====== #}
|
||||
{% set master_doc_short_name = 'User Doc' %}
|
||||
{% set master_doc_short_name = 'Developer Doc' %}
|
||||
|
||||
{% if pagename == master_doc %}
|
||||
<li><a href="{{ pathto(master_doc) }}" class="active">{{ master_doc_short_name }}</a></li>
|
||||
|
@ -1,13 +1,4 @@
|
||||
{% extends "basic/layout.html" %}
|
||||
{% set html5_doctype = True %}
|
||||
|
||||
{%- block scripts %}
|
||||
{{ super() }}
|
||||
<script type="text/javascript" src="{{ pathto('_static/jquery.min.js', 1) }}"></script>
|
||||
<script type="text/javascript" src="{{ pathto('_static/bootstrap.js', 1) }}"></script>
|
||||
<script type="text/javascript" src="{{ pathto('_static/doc.js', 1) }}"></script>
|
||||
<script type="text/javascript" src="{{ pathto('_static/jquery.noconflict.js', 1) }}"></script>
|
||||
{%- endblock %}
|
||||
|
||||
{% set classes = [] %}
|
||||
{% if pagename == master_doc %}
|
||||
@ -18,18 +9,16 @@
|
||||
{% set classes = classes + ['has_code_col'] %}
|
||||
{% endif %}
|
||||
|
||||
{% if 'classes' in meta %}
|
||||
{% set classes = classes + meta['classes'].split() %}
|
||||
{% endif %}
|
||||
|
||||
{%- block linktags -%}
|
||||
{% for code, url in language_codes %}
|
||||
<link rel="alternate" hreflang="{{ code }}" href="{{ url }}" />
|
||||
{%- endfor %}
|
||||
<link rel="canonical" href="{{ canonical }}" />
|
||||
{{ super() }}
|
||||
{%- block doctype -%}
|
||||
<!doctype html>
|
||||
{%- endblock -%}
|
||||
|
||||
{%- block linktags %}
|
||||
<link href="https://fonts.googleapis.com/css?family=Work+Sans:500,600" rel="stylesheet">
|
||||
<link rel="canonical" href="{{ canonical }}" />
|
||||
{{- super() }}
|
||||
{%- endblock %}
|
||||
|
||||
{%- block sidebar1 -%}{%- endblock -%}
|
||||
{%- block sidebar2 -%}{%- endblock -%}
|
||||
{%- block relbar1 -%}{%- endblock -%}
|
||||
@ -44,7 +33,6 @@
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', '{{ google_analytics_key }}', 'auto');
|
||||
ga('set', 'anonymizeIp', true);
|
||||
ga('send','pageview');
|
||||
</script>
|
||||
{%- endif -%}
|
||||
@ -77,8 +65,8 @@
|
||||
<li><a href="https://www.odoo.com/page/e-commerce">eCommerce</a></li>
|
||||
<li><a href="https://www.odoo.com/page/blog-engine">Blogs</a></li>
|
||||
<li><a href="https://www.odoo.com/page/community-builder">Forums</a></li>
|
||||
<li><a href="https://www.odoo.com/page/learning-management-system">eLearning</a></li>
|
||||
<li><a href="https://www.odoo.com/page/live-chat">Live Chat</a></li>
|
||||
<li><a href="https://www.odoo.com/page/slides">Slides</a></li>
|
||||
<li><a href="https://adspike.odoo.com">SEA</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-sm-3 o_sale_apps">
|
||||
@ -95,12 +83,10 @@
|
||||
<ul>
|
||||
<li><a href="https://www.odoo.com/page/point-of-sale">Shops</a></li>
|
||||
<li><a href="https://www.odoo.com/page/pos-restaurant">Restaurants</a></li>
|
||||
<li><a href="https://www.odoo.com/page/point-of-sale-hardware">Hardware</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="https://www.odoo.com/page/subscriptions">Subscriptions</a></li>
|
||||
<li><a href="https://www.odoo.com/page/sign">Sign</a></li>
|
||||
<li><a href="https://www.odoo.com/page/rental">Rental</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-sm-3 o_operation_apps">
|
||||
@ -109,17 +95,17 @@
|
||||
<div>It's all about efficiency</div>
|
||||
</div>
|
||||
<ul>
|
||||
<li><a href="https://www.odoo.com/page/accounting/">Accounting</a></li>
|
||||
<li><a href="https://www.odoo.com/page/project-management/">Project</a></li>
|
||||
<li><a href="https://www.odoo.com/page/accounting">Accounting</a></li>
|
||||
<li><a href="https://www.odoo.com/page/project-management">Project</a></li>
|
||||
<li class="dropdown">
|
||||
<a href="#0" class="dropdown-toggle">Human Resources</a>
|
||||
<ul>
|
||||
<li><a href="https://www.odoo.com/page/referral">Referral</a></li>
|
||||
<li><a href="https://www.odoo.com/page/recruitment">Recruitment</a></li>
|
||||
<li><a href="https://www.odoo.com/page/employees">Employees</a></li>
|
||||
<li><a href="https://www.odoo.com/page/expenses">Expenses</a></li>
|
||||
<li><a href="https://www.odoo.com/page/appraisal">Appraisal</a></li>
|
||||
<li><a href="https://www.odoo.com/page/fleet">Fleet</a></li>
|
||||
<li><a href="https://www.odoo.com/page/leaves">Time Off</a></li>
|
||||
<li><a href="https://www.odoo.com/page/leaves">Leaves</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="https://www.odoo.com/page/warehouse">Inventory</a></li>
|
||||
@ -133,8 +119,6 @@
|
||||
<li><a href="https://www.odoo.com/page/quality">Quality</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="https://www.odoo.com/page/helpdesk">Helpdesk</a></li>
|
||||
<li><a href="https://www.odoo.com/page/field-service-management">Field Service</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-sm-3 o_productivity_apps">
|
||||
@ -149,23 +133,15 @@
|
||||
<li><a href="https://www.odoo.com/page/discuss">Discuss</a></li>
|
||||
<li><a href="https://www.odoo.com/page/discuss-groups">Mailing Lists</a></li>
|
||||
<li><a href="https://www.odoo.com/page/notes">Notes</a></li>
|
||||
<li><a href="#">Help desk</a></li>
|
||||
<li><a href="#">Appointment</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="https://www.odoo.com/page/timesheet">Timesheet</a></li>
|
||||
<li><a href="https://www.odoo.com/page/email-marketing">Email Marketing</a></li>
|
||||
<li><a href="https://www.odoo.com/page/events">Events</a></li>
|
||||
<li class="dropdown">
|
||||
<a href="#0" class="dropdown-toggle">Marketing</a>
|
||||
<ul>
|
||||
<li><a href="https://www.odoo.com/page/marketing-automation">Automation</a></li>
|
||||
<li><a href="https://www.odoo.com/page/email-marketing">Email</a></li>
|
||||
<li><a href="https://www.odoo.com/page/social-marketing">Social</a></li>
|
||||
<li><a href="https://www.odoo.com/page/sms-marketing">SMS</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="https://www.odoo.com/page/survey">Survey</a></li>
|
||||
<li><a href="https://www.odoo.com/page/approval-workflow">Approvals</a></li>
|
||||
<li><a href="https://www.odoo.com/page/appointments">Appointments</a></li>
|
||||
<li><a href="https://www.odoo.com/page/documents">Documents</a></li>
|
||||
<li><a href="https://www.odoo.com/page/live-chat">Live Chat</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -198,6 +174,16 @@
|
||||
<a href="http://www.odoo.com/trial" class="btn btn-primary">Start Now</a>
|
||||
</div>
|
||||
|
||||
<ul class="navbar-nav navbar-right nav o_sub_nav_actions">
|
||||
{% if pagename != master_doc %}
|
||||
<li class="divider"></li>
|
||||
{% endif%}
|
||||
|
||||
{% block switchers_desktop %}
|
||||
{% include "switchers_list.html" %}
|
||||
{% endblock %}
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{% if languages or versions %}
|
||||
<li class="divider"></li>
|
||||
@ -211,16 +197,6 @@
|
||||
<li class="divider"></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
<ul class="navbar-nav navbar-right nav o_sub_nav_actions">
|
||||
{% if pagename != master_doc %}
|
||||
<li class="divider"></li>
|
||||
{% endif%}
|
||||
|
||||
{% block switchers_desktop %}
|
||||
{% include "switchers_list.html" %}
|
||||
{% endblock %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@ -361,4 +337,3 @@
|
||||
</div>
|
||||
</footer>
|
||||
{%- endblock -%}
|
||||
|
||||
|
@ -118,9 +118,9 @@ class OdooStyle(Style):
|
||||
Generic.Traceback: "",
|
||||
}
|
||||
|
||||
import imp
|
||||
import types
|
||||
import sys
|
||||
modname = 'pygments.styles.odoo'
|
||||
m = imp.new_module(modname)
|
||||
m = types.ModuleType(modname)
|
||||
m.OdooStyle = OdooStyle
|
||||
sys.modules[modname] = m
|
||||
|
@ -124,7 +124,6 @@ article.doc-body .code-fields {
|
||||
margin: 0;
|
||||
padding: 0 0 2%;
|
||||
.transform-origin(50% 0px 0px);
|
||||
.o-gradient();
|
||||
|
||||
@media screen and (min-width: @screen-sm-min) {
|
||||
padding: 12% 0 5%;
|
||||
|
@ -403,4 +403,3 @@
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
|
@ -109,12 +109,6 @@ main.index {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9384,6 +9384,16 @@ h6 {
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
.footnote-ref {
|
||||
vertical-align: super;
|
||||
font-size: 1ex;
|
||||
}
|
||||
.footnote-ref:before {
|
||||
content: '[';
|
||||
}
|
||||
.footnote-ref:after {
|
||||
content: ']';
|
||||
}
|
||||
article.doc-body > section {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
@ -9665,12 +9675,6 @@ article.doc-body .code-fields ul em {
|
||||
-moz-transform-origin: 50% 0px 0px;
|
||||
-ms-transform-origin: 50% 0px 0px;
|
||||
transform-origin: 50% 0px 0px;
|
||||
background: #75526b;
|
||||
background: -webkit-linear-gradient(99deg, #875A7B 10%, #62495B 90%);
|
||||
background: -moz-linear-gradient(99deg, #875A7B 10%, #62495B 90%);
|
||||
background: -ms-linear-gradient(99deg, #875A7B 10%, #62495B 90%);
|
||||
background: -o-linear-gradient(99deg, #875A7B 10%, #62495B 90%);
|
||||
background: linear-gradient(99deg, #875A7B 10%, #62495B 90%);
|
||||
}
|
||||
@media screen and (min-width: 768px) {
|
||||
.card.top {
|
||||
@ -10310,12 +10314,6 @@ main.index .card figcaption {
|
||||
.toctree-wrapper > ul li.toctree-l2 > ul:empty {
|
||||
display: none;
|
||||
}
|
||||
.toctree-wrapper > ul li.toctree-l2 a {
|
||||
text-decoration: none;
|
||||
}
|
||||
.toctree-wrapper > ul li.toctree-l2 a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
#oe_main_menu_navbar ~ #wrapwrap .o_main_header.o_has_sub_nav.o_scrolled {
|
||||
top: -17px;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
background-color: @footer-bg-color;
|
||||
color: @gray-lighter;
|
||||
}
|
||||
|
||||
|
||||
> .o_sub_nav #o_sub-menu #searchbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
@ -33,6 +33,13 @@ h1, h2, h3, h4, h5, h6 {
|
||||
border-bottom: 2px solid #f4f6f7;
|
||||
}
|
||||
|
||||
.footnote-ref {
|
||||
&:before {content: '[';}
|
||||
&:after {content: ']';}
|
||||
vertical-align: super;
|
||||
font-size: 1ex;
|
||||
}
|
||||
|
||||
article.doc-body {
|
||||
|
||||
// Vertical rhythm
|
||||
|
@ -2,9 +2,8 @@
|
||||
|
||||
<li><a href="https://www.odoo.com/documentation/user/13.0/index.html">User</a></li>
|
||||
<li><a href="https://www.odoo.com/documentation/13.0/index.html">Developer</a></li>
|
||||
<li><a href="https://odoo.com/slides">eLearning</a></li>
|
||||
<li><a href="https://www.odoo.com/documentation/13.0/webservices/odoo.html">API</a></li>
|
||||
<li><a href="https://www.odoo.com/documentation/13.0/setup/install.html">Installation</a></li>
|
||||
<li><a href="https://odoo.com/slides">eLearning</a></li>
|
||||
<li><a href="https://www.odoo.com/page/odoo-white-paper">White Papers</a></li>
|
||||
<li><a href="https://www.odoo.com/page/legal">Legal</a></li>
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
from docutils import nodes, utils
|
||||
from docutils.parsers.rst import Directive
|
||||
|
||||
from pygments.lexers import get_lexer_by_name
|
||||
from pygments.lexers import get_lexer_by_name, PythonLexer
|
||||
PythonLexer.name = 'Python 2'
|
||||
|
||||
def setup(app):
|
||||
app.add_directive('switcher', SwitcherDirective)
|
||||
|
@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function
|
||||
|
||||
import os.path
|
||||
import posixpath
|
||||
import re
|
||||
@ -6,7 +8,6 @@ import re
|
||||
from docutils import nodes
|
||||
from sphinx import addnodes, util, builders
|
||||
from sphinx.locale import admonitionlabels
|
||||
|
||||
from urllib.request import url2pathname
|
||||
|
||||
|
||||
@ -31,9 +32,8 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
||||
html_title = 'html_title'
|
||||
html_subtitle = 'html_subtitle'
|
||||
|
||||
# <meta> tags
|
||||
|
||||
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):
|
||||
@ -42,10 +42,12 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
||||
super(BootstrapTranslator, self).__init__(document)
|
||||
self.builder = builder
|
||||
self.meta = [
|
||||
# HTMLWriter strips out the first two items from Translator.meta
|
||||
# with no explanation
|
||||
'', '',
|
||||
'\n <meta http-equiv="X-UA-Compatible" content="IE=edge">',
|
||||
'\n <meta name="viewport" content="width=device-width, initial-scale=1">'
|
||||
]
|
||||
self.add_meta('<meta http-equiv="X-UA-Compatible" content="IE=edge">')
|
||||
self.add_meta('<meta name="viewport" content="width=device-width, initial-scale=1">')
|
||||
self.body = []
|
||||
self.fragment = self.body
|
||||
self.html_body = self.body
|
||||
@ -57,7 +59,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
||||
self.context = []
|
||||
self.section_level = 0
|
||||
|
||||
self.config = builder.config
|
||||
self.config = self.builder.config
|
||||
self.highlightlang = self.highlightlang_base = self.builder.config.highlight_language
|
||||
self.highlightopts = getattr(builder.config, 'highlight_options', {})
|
||||
|
||||
@ -67,7 +69,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
||||
self.param_separator = ','
|
||||
|
||||
def encode(self, text):
|
||||
return text.translate({
|
||||
return str(text).translate({
|
||||
ord('&'): u'&',
|
||||
ord('<'): u'<',
|
||||
ord('"'): u'"',
|
||||
@ -79,7 +81,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
||||
self.meta.append('\n ' + meta)
|
||||
|
||||
def starttag(self, node, tagname, **attributes):
|
||||
tagname = tagname.lower()
|
||||
tagname = str(tagname).lower()
|
||||
|
||||
# extract generic attributes
|
||||
attrs = {name.lower(): value for name, value in attributes.items()}
|
||||
@ -113,8 +115,8 @@ 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' ', str(value)))
|
||||
def attval(self, value, whitespace=re.compile(u'[ \t\n\f\r]+')):
|
||||
return self.encode(whitespace.sub(' ', str(value)))
|
||||
|
||||
def astext(self):
|
||||
return u''.join(self.body)
|
||||
@ -137,6 +139,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
||||
def visit_meta(self, node):
|
||||
if node.hasattr('lang'):
|
||||
node['xml:lang'] = node['lang']
|
||||
# del(node['lang'])
|
||||
meta = self.starttag(node, 'meta', **node.non_default_attributes())
|
||||
self.add_meta(meta)
|
||||
def depart_meta(self, node):
|
||||
@ -156,6 +159,11 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
||||
if not self.section_level:
|
||||
self.body.append(u'</section>')
|
||||
|
||||
def visit_topic(self, node):
|
||||
self.body.append(self.starttag(node, 'nav'))
|
||||
def depart_topic(self, node):
|
||||
self.body.append(u'</nav>')
|
||||
|
||||
def is_compact_paragraph(self, node):
|
||||
parent = node.parent
|
||||
if isinstance(parent, (nodes.document, nodes.compound,
|
||||
@ -197,6 +205,18 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
||||
def depart_compact_paragraph(self, node):
|
||||
pass
|
||||
|
||||
def visit_problematic(self, node):
|
||||
if node.hasattr('refid'):
|
||||
self.body.append('<a href="#%s">' % node['refid'])
|
||||
self.context.append('</a>')
|
||||
else:
|
||||
self.context.append('')
|
||||
self.body.append(self.starttag(node, 'span', CLASS='problematic'))
|
||||
|
||||
def depart_problematic(self, node):
|
||||
self.body.append('</span>')
|
||||
self.body.append(self.context.pop())
|
||||
|
||||
def visit_literal_block(self, node):
|
||||
if node.rawsource != node.astext():
|
||||
# most probably a parsed-literal block -- don't highlight
|
||||
@ -215,7 +235,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
||||
else:
|
||||
opts = {}
|
||||
|
||||
def warner(msg):
|
||||
def warner(msg, **kw):
|
||||
self.builder.warn(msg, (self.builder.current_docname, node.line))
|
||||
highlighted = self.builder.highlighter.highlight_block(
|
||||
node.rawsource, lang, opts=opts, warn=warner, linenos=linenos,
|
||||
@ -319,9 +339,9 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
||||
|
||||
def visit_title(self, node):
|
||||
parent = node.parent
|
||||
closing = u'</p>'
|
||||
closing = u'</h3>'
|
||||
if isinstance(parent, nodes.Admonition):
|
||||
self.body.append(self.starttag(node, 'p', CLASS='alert-title'))
|
||||
self.body.append(self.starttag(node, 'h3', CLASS='alert-title'))
|
||||
elif isinstance(node.parent, nodes.document):
|
||||
self.body.append(self.starttag(node, 'h1'))
|
||||
closing = u'</h1>'
|
||||
@ -388,11 +408,11 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
||||
"Unsupported alignment value \"%s\"" % node['align'],
|
||||
location=doc
|
||||
)
|
||||
attrs['style'] = '; '.join(
|
||||
'%s:%s' % (name, node[name] + ('px' if re.match(r'^[0-9]+$', node[name]) else ''))
|
||||
for name in ['width', 'height']
|
||||
if name in node
|
||||
)
|
||||
elif 'align' in node.parent and node.parent['align'] == 'center':
|
||||
# figure > image
|
||||
attrs['class'] += ' center-block'
|
||||
|
||||
# todo: explicit width/height/scale?
|
||||
self.body.append(self.starttag(node, 'img', **attrs))
|
||||
def depart_image(self, node): pass
|
||||
def visit_figure(self, node):
|
||||
@ -443,12 +463,7 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
||||
tagname = 'th'
|
||||
else:
|
||||
tagname = 'td'
|
||||
attrs = {}
|
||||
if 'morerows' in node:
|
||||
attrs['rowspan'] = node['morerows']+1
|
||||
if 'morecols' in node:
|
||||
attrs['colspan'] = node['morecols']+1
|
||||
self.body.append(self.starttag(node, tagname, **attrs))
|
||||
self.body.append(self.starttag(node, tagname))
|
||||
self.context.append(tagname)
|
||||
def depart_entry(self, node):
|
||||
self.body.append(u'</{}>'.format(self.context.pop()))
|
||||
@ -500,20 +515,6 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
||||
self.body.append(self.starttag(node, 'a', **attrs))
|
||||
def depart_reference(self, node):
|
||||
self.body.append(u'</a>')
|
||||
def visit_download_reference(self, node):
|
||||
# type: (nodes.Node) -> None
|
||||
if node.hasattr('filename'):
|
||||
self.body.append(
|
||||
'<a class="reference download internal" href="%s" download="">' %
|
||||
posixpath.join(self.builder.dlpath, node['filename']))
|
||||
self.body.append(node.astext())
|
||||
self.body.append('</a>')
|
||||
raise nodes.SkipNode
|
||||
else:
|
||||
self.context.append('')
|
||||
def depart_download_reference(self, node):
|
||||
# type: (nodes.Node) -> None
|
||||
self.body.append(self.context.pop())
|
||||
def visit_target(self, node): pass
|
||||
def depart_target(self, node): pass
|
||||
def visit_footnote(self, node):
|
||||
@ -659,11 +660,11 @@ class BootstrapTranslator(nodes.NodeVisitor, object):
|
||||
classes = env.metadata[ref].get('types', 'tutorials')
|
||||
classes += ' toc-single-entry' if not toc else ' toc-section'
|
||||
self.body.append(self.starttag(node, 'div', CLASS="row " + classes))
|
||||
self.body.append(u'<h2 class="col-sm-12">')
|
||||
self.body.append(u'<div class="col-sm-12"><h2>')
|
||||
self.body.append(title if title else util.nodes.clean_astext(env.titles[ref]))
|
||||
self.body.append(u'</h2>')
|
||||
self.body.append(u'</h2></div>')
|
||||
|
||||
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'])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user