aboutsummaryrefslogtreecommitdiff
path: root/scripts/qapi
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2025-03-10 23:42:39 -0400
committerMarkus Armbruster <armbru@redhat.com>2025-03-11 10:10:57 +0100
commit36e4182f4086edf3e7bbc5202bd692678d454793 (patch)
tree904d065d7c5a7de44e539de4ace95c944bd17e2b /scripts/qapi
parent5edd7411c4f25a43400c5b8d6e5647603942f36b (diff)
downloadqemu-36e4182f4086edf3e7bbc5202bd692678d454793.zip
qemu-36e4182f4086edf3e7bbc5202bd692678d454793.tar.gz
qemu-36e4182f4086edf3e7bbc5202bd692678d454793.tar.bz2
qapi/source: allow multi-line QAPISourceInfo advancing
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. The next patch will use this 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> Message-ID: <20250311034303.75779-42-jsnow@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'scripts/qapi')
-rw-r--r--scripts/qapi/source.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/scripts/qapi/source.py b/scripts/qapi/source.py
index 7b379fd..ffdc3f4 100644
--- a/scripts/qapi/source.py
+++ b/scripts/qapi/source.py
@@ -47,9 +47,9 @@ class QAPISourceInfo:
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: