[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 09/23] qapi/source: allow multi-line QAPISourceInfo advancing
From: |
John Snow |
Subject: |
[PATCH v2 09/23] qapi/source: allow multi-line QAPISourceInfo advancing |
Date: |
Tue, 14 Jan 2025 13:58:26 -0500 |
This is for the sake of the new rST generator (the "transmogrifier") so
we can advance multiple lines on occasion while keeping the
generated<-->source mappings accurate.
next_line now simply takes an optional n parameter which chooses the
number of lines to advance.
RFC: Here's the exorbitant detail on why I want this:
This is used mainly when converting section syntax in free-form
documentation to more traditional rST section header syntax, which
does not always line up 1:1 for line counts.
For example:
```
##
# = Section <-- Info is pointing here, "L1"
#
# Lorem Ipsum
##
```
would be transformed to rST as:
```
======= <-- L1
Section <-- L1
======= <-- L1
<-- L2
Lorem Ipsum <-- L3
```
After consuming the single "Section" line from the source, we want to
advance the source pointer to the next non-empty line which requires
jumping by more than one line.
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
scripts/qapi/source.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/qapi/source.py b/scripts/qapi/source.py
index 7b379fdc925..ffdc3f482ac 100644
--- a/scripts/qapi/source.py
+++ b/scripts/qapi/source.py
@@ -47,9 +47,9 @@ def set_defn(self, meta: str, name: str) -> None:
self.defn_meta = meta
self.defn_name = name
- def next_line(self: T) -> T:
+ def next_line(self: T, n: int = 1) -> T:
info = copy.copy(self)
- info.line += 1
+ info.line += n
return info
def loc(self) -> str:
--
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, 2025/01/14
- [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 <=
- [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
- [PATCH v2 17/23] docs/qapidoc: prepare to record entity being transmogrified, John Snow, 2025/01/14
- [PATCH v2 22/23] docs/qapidoc: implement transmogrify() method, John Snow, 2025/01/14
- [PATCH v2 03/23] docs/qapidoc: remove example section support, John Snow, 2025/01/14
- [PATCH v2 07/23] docs/qapidoc: add transmogrifier class stub, John Snow, 2025/01/14
- [PATCH v2 10/23] docs/qapidoc: add visit_freeform() method, John Snow, 2025/01/14
- [PATCH v2 18/23] docs/qapidoc: add visit_returns() method, John Snow, 2025/01/14