]> git.ipfire.org Git - thirdparty/qemu.git/commit
docs/qapi-domain: Fix error context reporting in Sphinx 5.x and 6.x
authorJohn Snow <jsnow@redhat.com>
Tue, 11 Mar 2025 03:42:29 +0000 (23:42 -0400)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 11 Mar 2025 09:10:57 +0000 (10:10 +0100)
commit707f2bbb7899297884095a76a1237c8dbfce09fd
treed18c2cb499d5f865b5c809b6e05570f20b12f92c
parentd48a8f8de3f2c5609ecd362f1d1c5c1ba60161fc
docs/qapi-domain: Fix error context reporting in Sphinx 5.x and 6.x

Sphinx 5.3.0 to Sphinx 6.2.0 has a bug where nested content in an
ObjectDescription content block has its error position reported
incorrectly due to an oversight when they added nested section support
to this directive.

(This bug is present in Sphinx's own Python and C domains; test it
yourself by creating a py:func directive and creating a syntax error in
the directive's content block. The reporting will be incorrect.)

To avoid overriding and re-implementing the entirety of the run()
method, a workaround is employed where we parse the content block
ourselves in before_content(), then null the content block to make
Sphinx's own parsing a no-op. Then, in transform_content (which occurs
after Sphinx's nested parse), we simply swap our own parsed content tree
back in for Sphinx's.

It appears a little tricky, but it's the nicest solution I can find.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-ID: <20250311034303.75779-32-jsnow@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
docs/sphinx/compat.py
docs/sphinx/qapi_domain.py