]> Git Repo - qemu.git/commitdiff
qapi2texi: Include member type in generated documentation
authorMarkus Armbruster <[email protected]>
Wed, 15 Mar 2017 12:57:14 +0000 (13:57 +0100)
committerMarkus Armbruster <[email protected]>
Thu, 16 Mar 2017 06:13:03 +0000 (07:13 +0100)
The recent merge of docs/qmp-commands.txt and docs/qmp-events.txt into
the schema lost type information.  Fix this documentation regression.

Example change (qemu-qmp-ref.txt):

  -- Struct: InputKeyEvent

      Keyboard input event.

      Members:
-     'button'
+     'button: InputButton'
           Which button this event is for.
-     'down'
+     'down: boolean'
           True for key-down and false for key-up events.

      Since: 2.0

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Marc-AndrĂ© Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Message-Id: <1489582656[email protected]>

scripts/qapi.py
scripts/qapi2texi.py

index 8b7377e51ea9023b4ea09cc1f38061d6409be0d0..21a15918dcc8535865bab498b872641ee1453757 100644 (file)
@@ -1105,6 +1105,11 @@ class QAPISchemaType(QAPISchemaEntity):
         }
         return json2qtype.get(self.json_type())
 
+    def doc_type(self):
+        if self.is_implicit():
+            return None
+        return self.name
+
 
 class QAPISchemaBuiltinType(QAPISchemaType):
     def __init__(self, name, json_type, c_type):
@@ -1129,6 +1134,9 @@ class QAPISchemaBuiltinType(QAPISchemaType):
     def json_type(self):
         return self._json_type_name
 
+    def doc_type(self):
+        return self.json_type()
+
     def visit(self, visitor):
         visitor.visit_builtin_type(self.name, self.info, self.json_type())
 
@@ -1188,6 +1196,12 @@ class QAPISchemaArrayType(QAPISchemaType):
     def json_type(self):
         return 'array'
 
+    def doc_type(self):
+        elt_doc_type = self.element_type.doc_type()
+        if not elt_doc_type:
+            return None
+        return 'array of ' + elt_doc_type
+
     def visit(self, visitor):
         visitor.visit_array_type(self.name, self.info, self.element_type)
 
index 3dd0146ba098485921b7ec58663a9035524d4843..993b65264f148da896305336a196441e033504eb 100755 (executable)
@@ -135,8 +135,12 @@ def texi_enum_value(value):
 
 def texi_member(member):
     """Format a table of members item for an object type member"""
-    return '@item @code{%s}%s\n' % (
-        member.name, ' (optional)' if member.optional else '')
+    typ = member.type.doc_type()
+    return '@item @code{%s%s%s}%s\n' % (
+        member.name,
+        ': ' if typ else '',
+        typ if typ else '',
+        ' (optional)' if member.optional else '')
 
 
 def texi_members(doc, what, member_func):
This page took 0.028671 seconds and 4 git commands to generate.