diff mbox series

[09/20] qapi/parser: add undocumented stub members to all_sections

Message ID 20240514215740.940155-10-jsnow@redhat.com
State New
Headers show
Series qapi: new sphinx qapi domain pre-requisites | expand

Commit Message

John Snow May 14, 2024, 9:57 p.m. UTC
This helps simplify the doc generator if it doesn't have to check for
undocumented members.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 scripts/qapi/parser.py | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index b1794f71e12..3cd8e7ee295 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -740,8 +740,24 @@  def connect_member(self, member: 'QAPISchemaMember') -> None:
                 raise QAPISemError(member.info,
                                    "%s '%s' lacks documentation"
                                    % (member.role, member.name))
-            self.args[member.name] = QAPIDoc.ArgSection(
-                self.info, '@' + member.name, 'member')
+
+            # Insert stub documentation section for missing member docs.
+            section = QAPIDoc.ArgSection(
+                self.info, f"@{member.name}", "member")
+            self.args[member.name] = section
+
+            # Determine where to insert stub doc.
+            index = 0
+            for i, sect in enumerate(self.all_sections):
+                # insert after these:
+                if sect.kind in ('intro-paragraph', 'member'):
+                    index = i + 1
+                # but before these:
+                elif sect.kind in ('tagged', 'feature', 'outro-paragraph'):
+                    index = i
+                    break
+            self.all_sections.insert(index, section)
+
         self.args[member.name].connect(member)
 
     def connect_feature(self, feature: 'QAPISchemaFeature') -> None: