]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qapi/parser: add undocumented stub members to all_sections
authorJohn Snow <jsnow@redhat.com>
Tue, 11 Mar 2025 03:42:57 +0000 (23:42 -0400)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 11 Mar 2025 09:26:52 +0000 (10:26 +0100)
Parser and doc generator cooperate on generating stub documentation for
undocumented members.  The parser makes up an ArgSection with an empty
description, and the doc generator makes up a description.

Right now, the made-up ArgSections go into doc.args.  However, the new
doc generator uses .all_sections, not .args.  So put them into
.all_sections, too.

Insert them right after existing 'member' sections.  If there are none,
insert directly after the leading section.

Doesn't affect the old generator, because that one doesn't use
.all_sections.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-ID: <20250311034303.75779-60-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Commit message rewritten]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
scripts/qapi/parser.py

index 11c11bb09e5e61345ac7290da6b1e9ebc7191ba4..949d9e8bff72235057873402b13c412ad2962863 100644 (file)
@@ -789,8 +789,23 @@ class QAPIDoc:
                 raise QAPISemError(member.info,
                                    "%s '%s' lacks documentation"
                                    % (member.role, member.name))
-            self.args[member.name] = QAPIDoc.ArgSection(
+            # Insert stub documentation section for missing member docs.
+            # TODO: drop when undocumented members are outlawed
+
+            section = QAPIDoc.ArgSection(
                 self.info, QAPIDoc.Kind.MEMBER, member.name)
+            self.args[member.name] = section
+
+            # Determine where to insert stub doc - it should go at the
+            # end of the members section(s), if any. Note that index 0
+            # is assumed to be an untagged intro section, even if it is
+            # empty.
+            index = 1
+            if len(self.all_sections) > 1:
+                while self.all_sections[index].kind == QAPIDoc.Kind.MEMBER:
+                    index += 1
+            self.all_sections.insert(index, section)
+
         self.args[member.name].connect(member)
 
     def connect_feature(self, feature: 'QAPISchemaFeature') -> None: