qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 03/14] qapi/doc.py: Add assertion on section.member


From: John Snow
Subject: [PATCH 03/14] qapi/doc.py: Add assertion on section.member
Date: Tue, 22 Sep 2020 17:17:51 -0400

Similarly to other cases, we lack the power at the moment to express
that a specific member is constrained to a certain containing type. Add
an assertion before we use properties specific to that type.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 scripts/qapi/doc.py | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py
index 66333629d6..c645876b24 100644
--- a/scripts/qapi/doc.py
+++ b/scripts/qapi/doc.py
@@ -5,9 +5,10 @@
 """This script produces the documentation of a qapi schema in texinfo format"""
 
 import re
+from typing import Optional
+
 from .gen import QAPIGenDoc
-from .schema import QAPISchemaVisitor
-
+from .schema import QAPISchemaVisitor, QAPISchemaObjectTypeMember
 
 MSG_FMT = """
 @deftypefn {type} {{}} {name}
@@ -155,14 +156,17 @@ def texi_members(doc, what, base=None, variants=None,
     items = ''
     for section in doc.args.values():
         # TODO Drop fallbacks when undocumented members are outlawed
+        desc: Optional[str] = None
+
         if section.text:
             desc = texi_format(section.text)
-        elif (variants and variants.tag_member == section.member
-              and not section.member.type.doc_type()):
-            values = section.member.type.member_names()
-            members_text = ', '.join(['@t{"%s"}' % v for v in values])
-            desc = 'One of ' + members_text + '\n'
-        else:
+        elif variants and variants.tag_member == section.member:
+            assert isinstance(section.member, QAPISchemaObjectTypeMember)
+            if not section.member.type.doc_type():
+                values = section.member.type.member_names()
+                members_text = ', '.join(['@t{"%s"}' % v for v in values])
+                desc = 'One of ' + members_text + '\n'
+        if desc is None:
             desc = 'Not documented\n'
 
         items += member_func(section.member, desc, '')
-- 
2.26.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]