[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/13] docs/qapidoc: fix nested parsing under untagged sections
From: |
Markus Armbruster |
Subject: |
[PULL 06/13] docs/qapidoc: fix nested parsing under untagged sections |
Date: |
Sat, 6 Jul 2024 09:24:09 +0200 |
From: John Snow <jsnow@redhat.com>
Sphinx does not like sections without titles, because it wants to
convert every section into a reference. When there is no title, it
struggles to do this and transforms the tree inproperly.
Depending on the rST used, this may result in an assertion error deep in
the docutils HTMLWriter.
(Observed when using ".. admonition:: Notes" under such a section - When
this is transformed with its own <title> element, Sphinx is fooled into
believing this title belongs to the section and incorrect mutates the
docutils tree, leading to errors during rendering time.)
When parsing an untagged section (free paragraphs), skip making a hollow
section and instead append the parse results to the prior section.
Many Bothans died to bring us this information.
The resulting output changes are basically invisible.
Signed-off-by: John Snow <jsnow@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20240626222128.406106-8-jsnow@redhat.com>
[Mention output changes in commit message]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
docs/sphinx/qapidoc.py | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py
index f9683444b1..efcd84656f 100644
--- a/docs/sphinx/qapidoc.py
+++ b/docs/sphinx/qapidoc.py
@@ -272,14 +272,20 @@ def _nodes_for_sections(self, doc):
if section.tag and section.tag == 'TODO':
# Hide TODO: sections
continue
+
+ if not section.tag:
+ # Sphinx cannot handle sectionless titles;
+ # Instead, just append the results to the prior section.
+ container = nodes.container()
+ self._parse_text_into_node(section.text, container)
+ nodelist += container.children
+ continue
+
snode = self._make_section(section.tag)
- if section.tag and section.tag.startswith('Example'):
+ if section.tag.startswith('Example'):
snode += self._nodes_for_example(dedent(section.text))
else:
- self._parse_text_into_node(
- dedent(section.text) if section.tag else section.text,
- snode,
- )
+ self._parse_text_into_node(dedent(section.text), snode)
nodelist.append(snode)
return nodelist
--
2.45.0
- [PULL 00/13] QAPI patches patches for 2024-07-06, Markus Armbruster, 2024/07/06
- [PULL 02/13] docs/qapidoc: remove unused intersperse function, Markus Armbruster, 2024/07/06
- [PULL 04/13] qapi/parser: preserve indentation in QAPIDoc sections, Markus Armbruster, 2024/07/06
- [PULL 10/13] qapi: update prose in note blocks, Markus Armbruster, 2024/07/06
- [PULL 03/13] docs/qapidoc: delint a tiny portion of the module, Markus Armbruster, 2024/07/06
- [PULL 09/13] qapi: convert "Note" sections to plain rST, Markus Armbruster, 2024/07/06
- [PULL 06/13] docs/qapidoc: fix nested parsing under untagged sections,
Markus Armbruster <=
- [PULL 05/13] qapi/parser: fix comment parsing immediately following a doc block, Markus Armbruster, 2024/07/06
- [PULL 11/13] qapi: add markup to note blocks, Markus Armbruster, 2024/07/06
- [PULL 08/13] qapi: nail down convention that Errors sections are lists, Markus Armbruster, 2024/07/06
- [PULL 13/13] sphinx/qapidoc: Fix to generate doc for explicit, unboxed arguments, Markus Armbruster, 2024/07/06
- [PULL 01/13] qapi: linter fixups, Markus Armbruster, 2024/07/06
- [PULL 07/13] qapi: fix non-compliant JSON examples, Markus Armbruster, 2024/07/06
- [PULL 12/13] qapi/parser: don't parse rST markup as section headers, Markus Armbruster, 2024/07/06
- Re: [PULL 00/13] QAPI patches patches for 2024-07-06, Richard Henderson, 2024/07/08