From 7d82513292fcb2639a70925d6fd4fca33dfa4041 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 15 Jun 2020 18:40:36 +0200 Subject: [PATCH 1/2] [IMP] odoo.sty: shorten PDF docs by moving title up on first page --- _static/latex/odoo.sty | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_static/latex/odoo.sty b/_static/latex/odoo.sty index 42431a5a6..41f4eb2e2 100644 --- a/_static/latex/odoo.sty +++ b/_static/latex/odoo.sty @@ -82,7 +82,7 @@ \renewcommand{\footrulewidth}{0.1pt} \renewcommand{\maketitle}{% - \noindent\rule{\textwidth}{1pt}\par + \vspace*{-2.5cm} \begin{flushright} \sphinxlogo \py@HeaderFamily @@ -99,7 +99,7 @@ % layout is slightly different on the titlepage \providecommand\sphinxmaketitle{} \renewcommand{\sphinxmaketitle}{% - \noindent\rule{\textwidth}{1pt}\par + \vspace*{-2.5cm} \begin{flushright} \sphinxlogo \py@HeaderFamily From e43df474d4daf6d42b6c7e47bbb64fb3a0c489a2 Mon Sep 17 00:00:00 2001 From: xmo-odoo Date: Thu, 25 Jun 2020 09:25:00 +0200 Subject: [PATCH 2/2] [ADD] support for meta directive (#708) e.g. .. meta:: :description: blah blah blah :keywords lang=en: x y z should yield Also cleaned up `layout.html` a tad while at it: * we're now properly setting the default metas via the translator so setting them in the template is unnecessary * there's a flag to use an html5 doctype (also has a few other positive side-effects with respect to the metas sphinx generates in the template) --- _extensions/odoo/layout.html | 10 +--------- _extensions/odoo/translator.py | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/_extensions/odoo/layout.html b/_extensions/odoo/layout.html index 226e65966..8663ac460 100644 --- a/_extensions/odoo/layout.html +++ b/_extensions/odoo/layout.html @@ -1,4 +1,5 @@ {% extends "basic/layout.html" %} +{% set html5_doctype = True %} {% set classes = [] %} {% if pagename == master_doc %} @@ -13,15 +14,6 @@ {% set classes = classes + meta['classes'].split() %} {% endif %} -{%- block doctype -%} - -{%- endblock -%} -{%- block htmltitle -%} - - - {{ super() }} -{%- endblock -%} - {%- block linktags -%} {% for code, url in language_codes %} diff --git a/_extensions/odoo/translator.py b/_extensions/odoo/translator.py index 3d72d12e6..569b3acba 100644 --- a/_extensions/odoo/translator.py +++ b/_extensions/odoo/translator.py @@ -36,10 +36,6 @@ class BootstrapTranslator(nodes.NodeVisitor, object): html_subtitle = 'html_subtitle' # tags - meta = [ - '', - '' - ] def __init__(self, document, builder): # order of parameter swapped between Sphinx 1.x and 2.x, check if @@ -49,6 +45,11 @@ class BootstrapTranslator(nodes.NodeVisitor, object): super(BootstrapTranslator, self).__init__(document) self.builder = builder + self.meta = [ + '', '', + '\n ', + '\n ' + ] self.body = [] self.fragment = self.body self.html_body = self.body @@ -78,6 +79,9 @@ class BootstrapTranslator(nodes.NodeVisitor, object): 0xa0: u' ' }) + def add_meta(self, meta): + self.meta.append('\n ' + meta) + def starttag(self, node, tagname, **attributes): tagname = tagname.lower() @@ -134,6 +138,14 @@ class BootstrapTranslator(nodes.NodeVisitor, object): def depart_document(self, node): pass + def visit_meta(self, node): + if node.hasattr('lang'): + node['xml:lang'] = node['lang'] + meta = self.starttag(node, 'meta', **node.non_default_attributes()) + self.add_meta(meta) + def depart_meta(self, node): + pass + def visit_section(self, node): # close "parent" or preceding section, unless this is the opening of # the first section