docs/sphinx: remove special parsing for freeform sections

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>
This commit is contained in:
John Snow
2025-07-14 10:08:27 +02:00
committed by Markus Armbruster
parent 8d789c8cdb
commit 6c10778826
48 changed files with 173 additions and 106 deletions
+19 -9
View 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
+3 -1
View File
@@ -11,7 +11,9 @@
# later. See the COPYING file in the top-level directory.
##
# = Firmware
# ********
# Firmware
# ********
##
{ 'pragma': {
+3 -1
View 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
# *******************************************
##
##
+1 -36
View 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:
+3 -1
View File
@@ -6,7 +6,9 @@
# SPDX-License-Identifier: GPL-2.0-or-later
##
# = ACPI
# ****
# ACPI
# ****
##
##
+3 -1
View File
@@ -7,7 +7,9 @@
# See the COPYING file in the top-level directory.
##
# = Audio
# *****
# Audio
# *****
##
##
+3 -1
View File
@@ -2,7 +2,9 @@
# vim: filetype=python
##
# = User authorization
# ******************
# User authorization
# ******************
##
##
+2 -1
View File
@@ -2,7 +2,8 @@
# vim: filetype=python
##
# == Block core (VM unrelated)
# Block core (VM unrelated)
# =========================
##
{ 'include': 'common.json' }
+2 -1
View File
@@ -2,7 +2,8 @@
# vim: filetype=python
##
# == Block device exports
# Block device exports
# ====================
##
{ 'include': 'sockets.json' }
+5 -2
View 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)
# ===================================
##
##
+3 -1
View File
@@ -3,7 +3,9 @@
#
##
# = Character devices
# *****************
# Character devices
# *****************
##
{ 'include': 'sockets.json' }
+3 -1
View File
@@ -2,7 +2,9 @@
# vim: filetype=python
##
# = Common data types
# *****************
# Common data types
# *****************
##
##
+3 -1
View File
@@ -2,7 +2,9 @@
# vim: filetype=python
##
# = Compatibility policy
# ********************
# Compatibility policy
# ********************
##
##
+3 -1
View File
@@ -3,7 +3,9 @@
#
##
# = QMP monitor control
# *******************
# QMP monitor control
# *******************
##
##
+3 -1
View File
@@ -3,7 +3,9 @@
#
##
# = Cryptography
# ************
# Cryptography
# ************
##
##
+3 -1
View File
@@ -5,7 +5,9 @@
# See the COPYING file in the top-level directory.
##
# = Cryptography devices
# ********************
# Cryptography devices
# ********************
##
##
+3 -1
View File
@@ -2,7 +2,9 @@
# vim: filetype=python
##
# = CXL devices
# ***********
# CXL devices
# ***********
##
##
+3 -1
View File
@@ -5,7 +5,9 @@
# See the COPYING file in the top-level directory.
##
# = Dump guest memory
# *****************
# Dump guest memory
# *****************
##
##
+3 -1
View 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
+3 -1
View File
@@ -2,7 +2,9 @@
# vim: filetype=python
##
# = QMP errors
# **********
# QMP errors
# **********
##
##

Some files were not shown because too many files have changed in this diff Show More