]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
docs/sphinx: remove special parsing for freeform sections
authorJohn Snow <jsnow@redhat.com>
Wed, 18 Jun 2025 16:53:52 +0000 (12:53 -0400)
committerMarkus Armbruster <armbru@redhat.com>
Mon, 14 Jul 2025 08:08:27 +0000 (10:08 +0200)
Remove the QAPI doc section heading syntax, use plain rST section
headings instead.

Tests and documentation are updated to match.

Interestingly, Plain rST headings work fine before this patch, except
for over- and underlining with '=', which the doc parser rejected as
invalid QAPI doc section heading in free-form comments.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-ID: <20250618165353.1980365-5-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Add more detail to commit message]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
48 files changed:
docs/devel/qapi-code-gen.rst
docs/interop/firmware.json
docs/interop/vhost-user.json
docs/sphinx/qapidoc.py
qapi/acpi.json
qapi/audio.json
qapi/authz.json
qapi/block-core.json
qapi/block-export.json
qapi/block.json
qapi/char.json
qapi/common.json
qapi/compat.json
qapi/control.json
qapi/crypto.json
qapi/cryptodev.json
qapi/cxl.json
qapi/dump.json
qapi/ebpf.json
qapi/error.json
qapi/introspect.json
qapi/job.json
qapi/machine-common.json
qapi/machine.json
qapi/migration.json
qapi/misc.json
qapi/net.json
qapi/pci.json
qapi/qapi-schema.json
qapi/qdev.json
qapi/qom.json
qapi/replay.json
qapi/rocker.json
qapi/run-state.json
qapi/sockets.json
qapi/stats.json
qapi/tpm.json
qapi/trace.json
qapi/transaction.json
qapi/uefi.json
qapi/ui.json
qapi/vfio.json
qapi/virtio.json
qapi/yank.json
scripts/qapi/parser.py
storage-daemon/qapi/qapi-schema.json
tests/qapi-schema/doc-good.json
tests/qapi-schema/doc-good.out

index 231cc0fecf79bd04c3bab901ceccec5e716308c7..dfdbeac5a5a7fb7661b560e0baa813a4fef6c00c 100644 (file)
@@ -876,25 +876,35 @@ structuring content.
 Headings and subheadings
 ~~~~~~~~~~~~~~~~~~~~~~~~
 
-A free-form documentation comment containing a line which starts with
-some ``=`` symbols and then a space defines a section heading::
+Free-form documentation does not start with ``@SYMBOL`` and can contain
+arbitrary rST markup. Headings can be marked up using the standard rST
+syntax::
 
     ##
-    # = This is a top level heading
+    # *************************
+    # This is a level 2 heading
+    # *************************
     #
     # This is a free-form comment which will go under the
     # top level heading.
     ##
 
     ##
-    # == This is a second level heading
+    # This is a third level heading
+    # ==============================
+    #
+    # Level 4
+    # _______
+    #
+    # Level 5
+    # ^^^^^^^
+    #
+    # Level 6
+    # """""""
     ##
 
-A heading line must be the first line of the documentation
-comment block.
-
-Section headings must always be correctly nested, so you can only
-define a third-level heading inside a second-level heading, and so on.
+Level 1 headings are reserved for use by the generated documentation
+page itself, leaving level 2 as the highest level that should be used.
 
 
 Documentation markup
index 745d21d8223298c37826ca9cd18e669abab85086..f46fdedfa8936fb3b67eab2a6657b864306db20b 100644 (file)
@@ -11,7 +11,9 @@
 # later. See the COPYING file in the top-level directory.
 
 ##
-# = Firmware
+# ********
+# Firmware
+# ********
 ##
 
 { 'pragma': {
index b6ade9e49315dd138680e4208533e6e97a2f2a97..095eb99cf794ecfbb2d774f569d8f4a2975fa0d7 100644 (file)
@@ -10,7 +10,9 @@
 # later. See the COPYING file in the top-level directory.
 
 ##
-# = vhost user backend discovery & capabilities
+# *******************************************
+# vhost user backend discovery & capabilities
+# *******************************************
 ##
 
 ##
index d5d2b5eeb50659741389732abe26421cfb796420..b794cde697166985cd715a082a81c5886c3d7c26 100644 (file)
@@ -399,44 +399,9 @@ class Transmogrifier:
         self.ensure_blank_line()
 
     def visit_freeform(self, doc: QAPIDoc) -> None:
-        # TODO: Once the old qapidoc transformer is deprecated, freeform
-        # sections can be updated to pure rST, and this transformed removed.
-        #
-        # For now, translate our micro-format into rST. Code adapted
-        # from Peter Maydell's freeform().
-
         assert len(doc.all_sections) == 1, doc.all_sections
         body = doc.all_sections[0]
-        text = self.reformat_arobase(body.text)
-        info = doc.info
-
-        if re.match(r"=+ ", text):
-            # Section/subsection heading (if present, will always be the
-            # first line of the block)
-            (heading, _, text) = text.partition("\n")
-            (leader, _, heading) = heading.partition(" ")
-            # Implicit +1 for heading in the containing .rst doc
-            level = len(leader) + 1
-
-            # https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#sections
-            markers = ' #*=_^"'
-            overline = level <= 2
-            marker = markers[level]
-
-            self.ensure_blank_line()
-            # This credits all 2 or 3 lines to the single source line.
-            if overline:
-                self.add_line(marker * len(heading), info)
-            self.add_line(heading, info)
-            self.add_line(marker * len(heading), info)
-            self.ensure_blank_line()
-
-            # Eat blank line(s) and advance info
-            trimmed = text.lstrip("\n")
-            text = trimmed
-            info = info.next_line(len(text) - len(trimmed) + 1)
-
-        self.add_lines(text, info)
+        self.add_lines(self.reformat_arobase(body.text), doc.info)
         self.ensure_blank_line()
 
     def visit_entity(self, ent: QAPISchemaDefinition) -> None:
index 2d53b823656e6966dffb5a0566478168c1938eb7..90f8f564fda4070c8eecf45490c960c12abc47a1 100644 (file)
@@ -6,7 +6,9 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 
 ##
-# = ACPI
+# ****
+# ACPI
+# ****
 ##
 
 ##
index 16de231f6d8c7d22f1580d950de8042e61f7f129..6a22ca384aa274abd80e2d83432421f35f51357a 100644 (file)
@@ -7,7 +7,9 @@
 # See the COPYING file in the top-level directory.
 
 ##
-# = Audio
+# *****
+# Audio
+# *****
 ##
 
 ##
index 7fc6e3032ea63bbcb0ebc6b9a0f3a7f3581e7310..ad1b4b3af0c3ac27a2e3c21eb1f6a6de4fd66015 100644 (file)
@@ -2,7 +2,9 @@
 # vim: filetype=python
 
 ##
-# = User authorization
+# ******************
+# User authorization
+# ******************
 ##
 
 ##
index 1df6644f0de286f629d70360ad91b9715f794644..8b413946ff840185784bfacfb7d4d473e4874b09 100644 (file)
@@ -2,7 +2,8 @@
 # vim: filetype=python
 
 ##
-# == Block core (VM unrelated)
+# Block core (VM unrelated)
+# =========================
 ##
 
 { 'include': 'common.json' }
index ed4deb54db2156458295fbcd870be2f56a180320..2241bfecf2585550b8fb59cf05e4abd949a8c9d6 100644 (file)
@@ -2,7 +2,8 @@
 # vim: filetype=python
 
 ##
-# == Block device exports
+# Block device exports
+# ====================
 ##
 
 { 'include': 'sockets.json' }
index 1490a1a17f85a757d75b17a19e03c58065f379dc..2d54a81c366cf25982ccfbbc72a3b999540feb2a 100644 (file)
@@ -2,13 +2,16 @@
 # vim: filetype=python
 
 ##
-# = Block devices
+# *************
+# Block devices
+# *************
 ##
 
 { 'include': 'block-core.json' }
 
 ##
-# == Additional block stuff (VM related)
+# Additional block stuff (VM related)
+# ===================================
 ##
 
 ##
index df6e325e2e15573deddafa4565d32c4c041e551b..f38d04986dd5bc37089d2809471cd57e32356625 100644 (file)
@@ -3,7 +3,9 @@
 #
 
 ##
-# = Character devices
+# *****************
+# Character devices
+# *****************
 ##
 
 { 'include': 'sockets.json' }
index 0e3a0bbbfb0b8b6590f128482a86e0ee2dc46a90..af7e3d618a7c801b62ebd263ebe48107bb7d2e51 100644 (file)
@@ -2,7 +2,9 @@
 # vim: filetype=python
 
 ##
-# = Common data types
+# *****************
+# Common data types
+# *****************
 ##
 
 ##
index 42034d9368c066d42b5e205851ccd9354cdea192..90b8d51cf27e574a2fb481838219f2678efe78af 100644 (file)
@@ -2,7 +2,9 @@
 # vim: filetype=python
 
 ##
-# = Compatibility policy
+# ********************
+# Compatibility policy
+# ********************
 ##
 
 ##
index 34b733f63b6c989495ca0925a78216a8da2d8e1f..ab0b3a3bbe560195388d32c8359b16519c613448 100644 (file)
@@ -3,7 +3,9 @@
 #
 
 ##
-# = QMP monitor control
+# *******************
+# QMP monitor control
+# *******************
 ##
 
 ##
index 9ec6301e1889647fef6a954ff431d58e0bf09545..21006de36c4e328e7b1793e7acfce0d38bbb2828 100644 (file)
@@ -3,7 +3,9 @@
 #
 
 ##
-# = Cryptography
+# ************
+# Cryptography
+# ************
 ##
 
 ##
index b13db264034649ea164c718135016fe5151380f0..1f49e1822c0b2905672d5452d29e9787aefb8c39 100644 (file)
@@ -5,7 +5,9 @@
 # See the COPYING file in the top-level directory.
 
 ##
-# = Cryptography devices
+# ********************
+# Cryptography devices
+# ********************
 ##
 
 ##
index 8f2e9237b1948850095c4ed5f0e311fdb37e12ff..52cc5d4f336c4b49645b1b1ca063a330d3ede368 100644 (file)
@@ -2,7 +2,9 @@
 # vim: filetype=python
 
 ##
-# = CXL devices
+# ***********
+# CXL devices
+# ***********
 ##
 
 ##
index d0ba1f0596fd601296d47aa4ed6fc6b020cf749f..0642ca157b8a750af6aace4195165a2e8980cd58 100644 (file)
@@ -5,7 +5,9 @@
 # See the COPYING file in the top-level directory.
 
 ##
-# = Dump guest memory
+# *****************
+# Dump guest memory
+# *****************
 ##
 
 ##
index db19ae850fcc2412e59a77921dae8c5b5ba780e6..d45054e6663994a4415f24ce7ccce7c32fbddc18 100644 (file)
@@ -5,7 +5,9 @@
 # See the COPYING file in the top-level directory.
 
 ##
-# = eBPF Objects
+# ************
+# eBPF Objects
+# ************
 #
 # eBPF object is an ELF binary that contains the eBPF program and eBPF
 # map description(BTF).  Overall, eBPF object should contain the
index 135c1e823197217df3c13b0abb306370adbc210a..54cb02fb880b3ef069f7dbae52c5f36d8b66754c 100644 (file)
@@ -2,7 +2,9 @@
 # vim: filetype=python
 
 ##
-# = QMP errors
+# **********
+# QMP errors
+# **********
 ##
 
 ##
index e9e02972821602474bf6d0bd9c6829204e7ed21b..26d8839f19c4a26ce1d8ce5be884d050b4ba5ee7 100644 (file)
@@ -10,7 +10,9 @@
 # See the COPYING file in the top-level directory.
 
 ##
-# = QMP introspection
+# *****************
+# QMP introspection
+# *****************
 ##
 
 ##
index 126fa5ce6021d3bf7e66f517fa61b19173851adf..16b280f52f8ff097729ca0367427f9d4cf60a232 100644 (file)
@@ -2,7 +2,9 @@
 # vim: filetype=python
 
 ##
-# = Background jobs
+# ***************
+# Background jobs
+# ***************
 ##
 
 ##
index 298e51f373a3cfa29d7a78cbd84ad5643ab040a3..0f01599130c14394d27fb6aea7dd9b8677d4dda9 100644 (file)
@@ -5,7 +5,9 @@
 # See the COPYING file in the top-level directory.
 
 ##
-# = Common machine types
+# ********************
+# Common machine types
+# ********************
 ##
 
 ##
index f712e7da6d6b8d082990552b13b1f759cd41d78e..af00a20b1fc833cbf7d06004ac00cb7fcec26124 100644 (file)
@@ -5,7 +5,9 @@
 # See the COPYING file in the top-level directory.
 
 ##
-# = Machines
+# ********
+# Machines
+# ********
 ##
 
 { 'include': 'common.json' }
index 2d39a8f7483b433d5ac27359d3881cd94a6adc68..3bf97df5d89a856191dd77e1897265e303d0bc23 100644 (file)
@@ -3,7 +3,9 @@
 #
 
 ##
-# = Migration
+# *********
+# Migration
+# *********
 ##
 
 { 'include': 'common.json' }
index 4b9e601cfa5b5cb59e6d109fcbef887b51abe234..a180c16db25d44aec15278558e256efd93141594 100644 (file)
@@ -3,7 +3,9 @@
 #
 
 ##
-# = Miscellanea
+# ***********
+# Miscellanea
+# ***********
 ##
 
 { 'include': 'common.json' }
index 97ea1839813b58133e4761f060ac312a0ec4df3d..3b03843c1650774c3bedc927ad2ea23d71bebe5d 100644 (file)
@@ -3,7 +3,9 @@
 #
 
 ##
-# = Net devices
+# ***********
+# Net devices
+# ***********
 ##
 
 { 'include': 'sockets.json' }
index dc85a41d28bc8edf13ce571b39a6203dae14bd69..a8671cd9ac32285612ae3a41a548674f34ea95b0 100644 (file)
@@ -6,7 +6,9 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 
 ##
-# = PCI
+# ***
+# PCI
+# ***
 ##
 
 ##
index a8f66163cb7086f78bd7c69313ae0523f6490459..49b9a0267d3e3e00b6bb12bba8b1766002ddf85f 100644 (file)
@@ -1,7 +1,9 @@
 # -*- Mode: Python -*-
 # vim: filetype=python
 ##
-# = Introduction
+# ************
+# Introduction
+# ************
 #
 # This manual describes the commands and events supported by the QEMU
 # Monitor Protocol (QMP).
index 32c7d1004639474f8b3a5dc77b380fe0831d1c10..441ed518b878be3640f321e051a0ef504d55cee1 100644 (file)
@@ -5,7 +5,9 @@
 # See the COPYING file in the top-level directory.
 
 ##
-# = Device infrastructure (qdev)
+# ****************************
+# Device infrastructure (qdev)
+# ****************************
 ##
 
 { 'include': 'qom.json' }
index b133b064471bcfebe984220b2f83e589d8d9681f..f68f72fbbce294092b8524d5778500b6c3b1bf43 100644 (file)
@@ -10,7 +10,9 @@
 { 'include': 'crypto.json' }
 
 ##
-# = QEMU Object Model (QOM)
+# ***********************
+# QEMU Object Model (QOM)
+# ***********************
 ##
 
 ##
index 35e0c4a6926a9403822ce7ea4d9764fbd8373321..e46c5c1d3f32b0febd6f24fef990f34b88718a83 100644 (file)
@@ -3,7 +3,9 @@
 #
 
 ##
-# = Record/replay
+# *************
+# Record/replay
+# *************
 ##
 
 { 'include': 'common.json' }
index 0c7ef1f77c8491f2323d829777754e155dca5a5f..e4949649526def4e653e9001e12cf600b9d5b469 100644 (file)
@@ -2,7 +2,9 @@
 # vim: filetype=python
 
 ##
-# = Rocker switch device
+# ********************
+# Rocker switch device
+# ********************
 ##
 
 ##
index fd09beb35cbb6678defe2890fdcf555f5e944db4..083a3c5eb30b05a3a4e8d083e937fd60481470e1 100644 (file)
@@ -3,7 +3,9 @@
 #
 
 ##
-# = VM run state
+# ************
+# VM run state
+# ************
 ##
 
 ##
index f9f559dabae7cfd1b1f9b3572586f03c8526d70f..b5f4a8fecdab19451cc5d512aa0aff1f13ecd17c 100644 (file)
@@ -2,7 +2,9 @@
 # vim: filetype=python
 
 ##
-# = Socket data types
+# *****************
+# Socket data types
+# *****************
 ##
 
 ##
index 8902ef94e08d041f5345f5a251bd5e5e71bdfc32..78b88881eabfe15ac9ffd183cec3504850a57288 100644 (file)
@@ -9,7 +9,9 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 
 ##
-# = Statistics
+# **********
+# Statistics
+# **********
 ##
 
 ##
index a16a72edb980181161e762ab44441e5e2b154438..e66b107f1d07cc6e100b359794fedb4354bdb434 100644 (file)
@@ -3,7 +3,9 @@
 #
 
 ##
-# = TPM (trusted platform module) devices
+# *************************************
+# TPM (trusted platform module) devices
+# *************************************
 ##
 
 ##
index eb5f63f5135241f9da45050a0ce7112fa960ab0b..d08c9c6a8897adfbbcccb2b489698dbaa1de9a73 100644 (file)
@@ -7,7 +7,9 @@
 # See the COPYING file in the top-level directory.
 
 ##
-# = Tracing
+# *******
+# Tracing
+# *******
 ##
 
 ##
index 9d9e7af26cbfd7493e7ef3bb0873bd0495bd24ef..927035f5a7e520e25514e8ba0033d3a454910001 100644 (file)
@@ -3,7 +3,9 @@
 #
 
 ##
-# = Transactions
+# ************
+# Transactions
+# ************
 ##
 
 { 'include': 'block-core.json' }
index 6592183d6cfa344d65c07f095d509bfda9a50346..a206c2e95399738114eb519e82aaea2fc03177f3 100644 (file)
@@ -3,7 +3,9 @@
 #
 
 ##
-# = UEFI Variable Store
+# *******************
+# UEFI Variable Store
+# *******************
 #
 # The QEMU efi variable store implementation (hw/uefi/) uses this to
 # store non-volatile variables in json format on disk.
index 514fa159b1058cfe5e7e095894b4740e9cc088dc..f5e77ae19d715dcc5429138d942fb0269f7bb275 100644 (file)
@@ -3,7 +3,9 @@
 #
 
 ##
-# = Remote desktop
+# **************
+# Remote desktop
+# **************
 ##
 
 { 'include': 'common.json' }
   'if': 'CONFIG_PIXMAN' }
 
 ##
-# == Spice
+# Spice
+# =====
 ##
 
 ##
   'if': 'CONFIG_SPICE' }
 
 ##
-# == VNC
+# VNC
+# ===
 ##
 
 ##
   'if': 'CONFIG_VNC' }
 
 ##
-# = Input
+# *****
+# Input
+# *****
 ##
 
 ##
index b53b7caecd71710c295a38d2a106d0f983df1aca..a1a9c5b673d8e2f9a1a7e5cc7ad518639320e976 100644 (file)
@@ -3,7 +3,9 @@
 #
 
 ##
-# = VFIO devices
+# ************
+# VFIO devices
+# ************
 ##
 
 ##
index 73df718a261dcc0993474de8109f5511637d52f9..3cac0774f7af2abb5a5be1fd50ec1fdc2d07a7ab 100644 (file)
@@ -3,7 +3,9 @@
 #
 
 ##
-# = Virtio devices
+# **************
+# Virtio devices
+# **************
 ##
 
 ##
index 30f46c97c988f3155c3da108949f16d4a9b389c5..d13a8e911714fa4f791e738234cce6095a38b849 100644 (file)
@@ -3,7 +3,9 @@
 #
 
 ##
-# = Yank feature
+# ************
+# Yank feature
+# ************
 ##
 
 ##
index 949d9e8bff72235057873402b13c412ad2962863..aad7e249f867ed3bdc93e806ec41b58056d9002b 100644 (file)
@@ -597,22 +597,15 @@ class QAPISchemaParser:
             # Free-form documentation
             doc = QAPIDoc(info)
             doc.ensure_untagged_section(self.info)
-            first = True
             while line is not None:
                 if match := self._match_at_name_colon(line):
                     raise QAPIParseError(
                         self,
                         "'@%s:' not allowed in free-form documentation"
                         % match.group(1))
-                if line.startswith('='):
-                    if not first:
-                        raise QAPIParseError(
-                            self,
-                            "'=' heading must come first in a comment block")
                 doc.append_line(line)
                 self.accept(False)
                 line = self.get_doc_line()
-                first = False
 
         self.accept()
         doc.end()
index 0427594c984b62aea598573441f428dfe4c3eccd..478e7a92b21a8e389665d741a85cff48947fc3a0 100644 (file)
@@ -14,7 +14,9 @@
 # storage daemon.
 
 ##
-# = Introduction
+# ************
+# Introduction
+# ************
 #
 # This manual describes the commands and events supported by the QEMU
 # storage daemon QMP.
@@ -51,7 +53,9 @@
 { 'include': '../../qapi/job.json' }
 
 ##
-# = Block devices
+# *************
+# Block devices
+# *************
 ##
 { 'include': '../../qapi/block-core.json' }
 { 'include': '../../qapi/block-export.json' }
index 14b808f90905bdc7973ef27fb9d514bc4e807f34..fac13425b72b2cb1685770750e2005e659d6ae4b 100644 (file)
@@ -8,7 +8,9 @@
     'documentation-exceptions': [ 'Enum', 'Variant1', 'Alternate', 'cmd' ] } }
 
 ##
-# = Section
+# *******
+# Section
+# *******
 ##
 
 ##
@@ -16,7 +18,8 @@
 ##
 
 ##
-# == Subsection
+# Subsection
+# ==========
 #
 # *with emphasis*
 # @var {in braces}
   'if': { 'not': { 'any': [ 'IFONE', 'IFTWO' ] } } }
 
 ##
-# == Another subsection
+# Another subsection
+# ==================
 ##
 
 ##
index dc8352eed4f339cf3a8345afd4e8eace6d730fac..04a550726462a472e661943c674e00733c337a14 100644 (file)
@@ -55,13 +55,16 @@ event EVT_BOXED Object
     feature feat3
 doc freeform
     body=
-= Section
+*******
+Section
+*******
 doc freeform
     body=
 Just text, no heading.
 doc freeform
     body=
-== Subsection
+Subsection
+==========
 
 *with emphasis*
 @var {in braces}
@@ -155,7 +158,8 @@ description starts on the same line
 a feature
 doc freeform
     body=
-== Another subsection
+Another subsection
+==================
 doc symbol=cmd
     body=