summary refs log tree commit diff stats
path: root/docs/sphinx/qapidoc.py
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2025-06-18 12:53:49 -0400
committerMarkus Armbruster <armbru@redhat.com>2025-07-14 10:06:41 +0200
commit66c83cdd91c07575ebf30bb45da8cc5df8041c29 (patch)
tree582f26d84f42177e324d318eb18e72a8b1d071b0 /docs/sphinx/qapidoc.py
parent9a4e273ddec3927920c5958d2226c6b38b543336 (diff)
downloadfocaccia-qemu-66c83cdd91c07575ebf30bb45da8cc5df8041c29.tar.gz
focaccia-qemu-66c83cdd91c07575ebf30bb45da8cc5df8041c29.zip
docs/sphinx: adjust qapidoc to cope with same-line error sections
Without this, the line the new QAPI doc generator chokes on

    # Errors: some

in doc-good.json.  We still use the old doc generator for the tests,
but we're about to correct that.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-ID: <20250618165353.1980365-2-jsnow@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Fixes: e9fbf1a0c6c2 (docs/qapidoc: add visit_errors() method)
[Amend commit message to point to reproducer, and add Fixes:]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'docs/sphinx/qapidoc.py')
-rw-r--r--docs/sphinx/qapidoc.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py
index 8011ac9efa..5374dee8fa 100644
--- a/docs/sphinx/qapidoc.py
+++ b/docs/sphinx/qapidoc.py
@@ -267,10 +267,14 @@ class Transmogrifier:
         self.add_field("return", typ, section.text, section.info)
 
     def visit_errors(self, section: QAPIDoc.Section) -> None:
-        # FIXME: the formatting for errors may be inconsistent and may
-        # or may not require different newline placement to ensure
-        # proper rendering as a nested list.
-        self.add_lines(f":error:\n{section.text}", section.info)
+        # If the section text does not start with a space, it means text
+        # began on the same line as the "Error:" string and we should
+        # not insert a newline in this case.
+        if section.text[0].isspace():
+            text = f":error:\n{section.text}"
+        else:
+            text = f":error: {section.text}"
+        self.add_lines(text, section.info)
 
     def preamble(self, ent: QAPISchemaDefinition) -> None:
         """