From af5bbb433afca3bb600bd409c7421d33c3552aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pa=C4=8Dek?= Date: Wed, 20 Jul 2022 17:57:17 +0200 Subject: [PATCH 1/2] Support docutils 0.14+dfsg-4 Ancient versions of docutils cannot cope with bare text inside a table cell. Wrap text in a paragraph to work around that. --- doc/arm/_ext/iscconf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/arm/_ext/iscconf.py b/doc/arm/_ext/iscconf.py index 598fb26aa3..10c24040fe 100644 --- a/doc/arm/_ext/iscconf.py +++ b/doc/arm/_ext/iscconf.py @@ -547,7 +547,7 @@ class DictToDocutilsTableBuilder: row = nodes.row() for column in self.header: entry = nodes.entry() - entry += nodes.Text(column.description) + entry += nodes.paragraph(text=column.description) row += entry thead.append(row) @@ -562,7 +562,7 @@ class DictToDocutilsTableBuilder: entry = nodes.entry() value = obj[column.dictkey] if isinstance(value, str): - value = nodes.Text(value) + value = nodes.paragraph(text=value) else: value = value.deepcopy() entry += value From 8796ad7fe8ed24d1287bfd94ef1ee283d778c047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pa=C4=8Dek?= Date: Wed, 20 Jul 2022 18:44:48 +0200 Subject: [PATCH 2/2] Support Sphinx 1.6.7 Luckily we don't rely on SphinxDirective functionality which does not exist in 1.6.7. Replace it with docutils Directive. transform_content() callback was added only in Sphinx 3.0.0. Detect if it was not called and call it manually. The transform_content() function requires access to inner "contentnode" which is created inside run(). This workaround relies on the order of node as it was in the pre-3.0.0 versions, but it should not matter as new versions will not trigger the workaround. --- doc/arm/_ext/iscconf.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/doc/arm/_ext/iscconf.py b/doc/arm/_ext/iscconf.py index 10c24040fe..b5bd966e2a 100644 --- a/doc/arm/_ext/iscconf.py +++ b/doc/arm/_ext/iscconf.py @@ -23,7 +23,7 @@ https://www.sphinx-doc.org/en/master/development/tutorials/recipe.html from collections import namedtuple -from docutils.parsers.rst import directives +from docutils.parsers.rst import Directive, directives from docutils import nodes from sphinx import addnodes @@ -31,7 +31,6 @@ from sphinx.directives import ObjectDescription from sphinx.domains import Domain from sphinx.roles import XRefRole from sphinx.util import logging -from sphinx.util.docutils import SphinxDirective from sphinx.util.nodes import make_refnode import checkgrammar @@ -61,7 +60,7 @@ def domain_factory(domainname, domainlabel, todolist, grammar): See StatementListDirective. """ - class StatementListDirective(SphinxDirective): + class StatementListDirective(Directive): """A custom directive to generate list of statements. It only installs placeholder which is later replaced by process_statementlist_nodes() callback. @@ -229,6 +228,7 @@ def domain_factory(domainname, domainlabel, todolist, grammar): def transform_content(self, contentnode: addnodes.desc_content) -> None: """autogenerate content from structured data""" + self.workaround_transform_content = True if self.isc_short: contentnode.insert(0, self.isc_short_node) if self.isc_tags: @@ -263,6 +263,19 @@ def domain_factory(domainname, domainlabel, todolist, grammar): if len(warn): contentnode.insert(0, warn) + def __init__(self, *args, **kwargs): + """Compability with Sphinx < 3.0.0""" + self.workaround_transform_content = False + super().__init__(*args, **kwargs) + + def run(self): + """Compability with Sphinx < 3.0.0""" + nodelist = super().run() + if not self.workaround_transform_content: + # get access to "contentnode" created inside super.run() + self.transform_content(nodelist[1][-1]) + return nodelist + name = domainname label = domainlabel