[PATCH v2 27/34] scripts: apibuild: parse 'Since' for typedefs

Victor Toso victortoso at redhat.com
Thu Apr 14 20:47:38 UTC 2022


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 at redhat.com>
---
 scripts/apibuild.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/scripts/apibuild.py b/scripts/apibuild.py
index 5335670c1c..da70d67fa6 100755
--- a/scripts/apibuild.py
+++ b/scripts/apibuild.py
@@ -2296,9 +2296,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))):
@@ -2321,12 +2323,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")
-- 
2.35.1



More information about the libvir-list mailing list