diff --git a/content/contributing/documentation.rst b/content/contributing/documentation.rst index a168b5e12..81b3bef70 100644 --- a/content/contributing/documentation.rst +++ b/content/contributing/documentation.rst @@ -1,5 +1,5 @@ -:empty_page: +:show_content: ================================= Contributing to the documentation diff --git a/extensions/odoo_theme/__init__.py b/extensions/odoo_theme/__init__.py index 83346e06b..6348cf97f 100644 --- a/extensions/odoo_theme/__init__.py +++ b/extensions/odoo_theme/__init__.py @@ -1,18 +1,14 @@ -from . import pygments_override -from . import translator - -import sphinx.builders.html +from docutils import nodes from sphinx import addnodes from sphinx.environment.adapters import toctree -from docutils import nodes + +from . import pygments_override, translator def setup(app): app.set_translator('html', translator.BootstrapTranslator) - # VFE TODO check if default meta initialization is necessary. - # If not, remove update_meta method - app.connect('html-page-context', update_meta) + app.connect('html-page-context', set_missing_meta) app.add_js_file('js/utils.js') # Keep in first position app.add_js_file('js/layout.js') @@ -20,14 +16,12 @@ def setup(app): app.add_js_file('js/page_toc.js') -def update_meta(app, pagename, templatename, context, doctree): - meta = context.get('meta') - if meta is None: - meta = context['meta'] = {} - -# TODO VFE detailed explanation of the patch logic and use. +def set_missing_meta(app, pagename, templatename, context, doctree): + if context.get('meta') is None: # Pages without title (used with `include::`) have no meta + context['meta'] = {} class Monkey(object): + """ Replace patched method of an object by a new method receiving the old one in argument. """ def __init__(self, obj): self.obj = obj def __call__(self, fn): @@ -37,40 +31,57 @@ class Monkey(object): @Monkey(toctree.TocTree) def resolve(old_resolve, tree, docname, *args, **kwargs): + + def _clear_empty_pages_reference(_node) -> None: + """ Disable references to 'empty' toctree pages. + + Inspect node's children to determine whether the page is a toc and, if so, clear its + reference URL. () + If the page has the `show_content` metadata, don't clear the reference. + + Internal structure of nodes: +