]> xenbits.xensource.com Git - libvirt.git/commitdiff
scripts: apibuild: parse 'Since' for typedefs
authorVictor Toso <victortoso@redhat.com>
Fri, 22 Apr 2022 19:23:40 +0000 (21:23 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Tue, 26 Apr 2022 15:54:25 +0000 (17:54 +0200)
This patch adds 'version' parameter to the generated XML API for
typedefs

It'll require, for new additions, to add a comment with the version
that the typedef value was added. An example bellow of code diff and
the change in the generated XML.

Note that the Since tag is removed from the comment as there is a
proper field for it in the XML.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
scripts/apibuild.py

index dd82974c122d4a014c8b77d1e96fe14288bf223e..116ea9fe5f7615730d33a8e2705bbf26aef60733 100755 (executable)
@@ -2297,9 +2297,11 @@ class docBuilder:
 
     def serialize_typedef(self, output, name):
         id = self.idx.typedefs[name]
+        (since, comment) = self.retrieve_comment_tags(name, id.extra)
+        version_tag = len(since) > 0 and f" version='{since}'" or ""
         if id.info[0:7] == 'struct ':
-            output.write("    <struct name='%s' file='%s' type='%s'" % (
-                name, self.modulename_file(id.header), id.info))
+            output.write("    <struct name='%s' file='%s' type='%s'%s" % (
+                name, self.modulename_file(id.header), id.info, version_tag))
             name = id.info[7:]
             if (name in self.idx.structs and
                     isinstance(self.idx.structs[name].info, (list, tuple))):
@@ -2322,12 +2324,11 @@ class docBuilder:
             else:
                 output.write("/>\n")
         else:
-            output.write("    <typedef name='%s' file='%s' type='%s'" % (
-                         name, self.modulename_file(id.header), id.info))
+            output.write("    <typedef name='%s' file='%s' type='%s'%s" % (
+                         name, self.modulename_file(id.header), id.info, version_tag))
             try:
-                desc = id.extra
-                if desc is not None and desc != "":
-                    output.write(">\n      <info><![CDATA[%s]]></info>\n" % (desc))
+                if comment is not None and comment != "":
+                    output.write(">\n      <info><![CDATA[%s]]></info>\n" % (comment))
                     output.write("    </typedef>\n")
                 else:
                     output.write("/>\n")