[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 02/23] qapi/parser: adjust info location for doc body section
From: |
John Snow |
Subject: |
[PATCH v2 02/23] qapi/parser: adjust info location for doc body section |
Date: |
Tue, 14 Jan 2025 13:58:19 -0500 |
Instead of using the info object for the doc block as a whole (which
always points to the very first line of the block), update the info
pointer for each call to ensure_untagged_section when the existing
section is otherwise empty. This way, Sphinx error information will
match precisely to where the text actually starts.
For example, this patch will move the info pointer for the "Hello!"
untagged section ...
> ## <-- from here ...
> # Hello! <-- ... to here.
> ##
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/qapi/parser.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index adc85b5b394..36cb64a677a 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -687,7 +687,11 @@ def end(self) -> None:
def ensure_untagged_section(self, info: QAPISourceInfo) -> None:
if self.all_sections and not self.all_sections[-1].tag:
# extend current section
- self.all_sections[-1].text += '\n'
+ section = self.all_sections[-1]
+ if not section.text:
+ # Section is empty so far; update info to start *here*.
+ section.info = info
+ section.text += '\n'
return
# start new section
section = self.Section(info)
--
2.47.1
- [PATCH v2 00/23] docs: add basic sphinx-domain rST generator to qapidoc, John Snow, 2025/01/14
- [PATCH v2 01/23] docs/qapidoc: support header-less freeform sections, John Snow, 2025/01/14
- [PATCH v2 08/23] docs/qapidoc: add visit_module() method, John Snow, 2025/01/14
- [PATCH v2 02/23] qapi/parser: adjust info location for doc body section,
John Snow <=
- [PATCH v2 13/23] docs/qapidoc: add visit_errors() method, John Snow, 2025/01/14
- [PATCH v2 15/23] docs/qapidoc: add add_field() and generate_field() helper methods, John Snow, 2025/01/14
- [PATCH v2 14/23] docs/qapidoc: add format_type() method, John Snow, 2025/01/14
- [PATCH v2 06/23] docs/qapidoc: add transmogrifier stub, John Snow, 2025/01/14
- [PATCH v2 04/23] qapi: expand tags to all doc sections, John Snow, 2025/01/14
- [PATCH v2 09/23] qapi/source: allow multi-line QAPISourceInfo advancing, John Snow, 2025/01/14
- [PATCH v2 11/23] docs/qapidoc: add preamble() method, John Snow, 2025/01/14
- [PATCH v2 19/23] docs/qapidoc: add visit_member() method, John Snow, 2025/01/14
- [PATCH v2 05/23] qapi/schema: add __repr__ to QAPIDoc.Section, John Snow, 2025/01/14
- [PATCH v2 12/23] docs/qapidoc: add visit_paragraph() method, John Snow, 2025/01/14