diff options
author | John Snow <jsnow@redhat.com> | 2025-03-10 23:42:30 -0400 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2025-03-11 10:10:57 +0100 |
commit | faeacf858bd9529cab10a13ff9d2137c8f2ae17c (patch) | |
tree | 19e145e9fa7f242a50a58ea81d1e6c82816f5e09 /scripts | |
parent | 707f2bbb7899297884095a76a1237c8dbfce09fd (diff) | |
download | qemu-faeacf858bd9529cab10a13ff9d2137c8f2ae17c.zip qemu-faeacf858bd9529cab10a13ff9d2137c8f2ae17c.tar.gz qemu-faeacf858bd9529cab10a13ff9d2137c8f2ae17c.tar.bz2 |
qapi/parser: adjust info location for doc body section
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.
> ##
This doesn't seem to improve error reporting now. It will with the
forthcoming QAPI doc transmogrifier.
If I stick bad rST into qapi/block-core.json like this:
> ##
> # @SnapshotInfo:
> #
> +# rST syntax error: *ahh!
> +#
> # @id: unique shapshot id
> #
> # @name: user chosen name
The existing code's error message will point to the beginning of the doc
comment, which is less than helpful. The transmogrifier's message will
point to the erroneous line, but to accomplish this, it needs this
patch.
Signed-off-by: John Snow <jsnow@redhat.com>
Message-ID: <20250311034303.75779-33-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/qapi/parser.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 64f0bb8..97def9f 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -686,7 +686,11 @@ class QAPIDoc: 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) |