[PATCH v1 2/4] scripts: apibuild: parse 'Since' for typedefs

Victor Toso victortoso at redhat.com
Tue Apr 5 11:43:21 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.

```diff
--- a/include/libvirt/libvirt-host.h
+++ b/include/libvirt/libvirt-host.h
@@ -41,6 +41,8 @@ typedef struct _virConnect virConnect;
  *
  * a virConnectPtr is pointer to a virConnect private structure, this is the
  * type used to reference a connection to the Hypervisor in the API.
+ *
+ * Since 0.0.1
  */
 typedef virConnect *virConnectPtr;
```

```xml
    <typedef name='virConnectPtr'
             file='libvirt-host'
             type='virConnect *'
             version='0.0.1'>
      <info><![CDATA[a virConnectPtr is pointer to a virConnect private
 structure, this is the type used to reference a connection to the
 Hypervisor in the API.]]></info>
    </typedef>
```

Signed-off-by: Victor Toso <victortoso at redhat.com>
---
 scripts/apibuild.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/scripts/apibuild.py b/scripts/apibuild.py
index cb68d1b970..bafde0e0ab 100755
--- a/scripts/apibuild.py
+++ b/scripts/apibuild.py
@@ -2324,9 +2324,11 @@ class docBuilder:
             output.write("    <typedef name='%s' file='%s' type='%s'" % (
                          name, self.modulename_file(id.header), id.info))
             try:
-                desc = id.extra
-                if desc is not None and desc != "":
-                    output.write(">\n      <info><![CDATA[%s]]></info>\n" % (desc))
+                (comment, since) = self.retrieve_comment_tags(name, id.extra)
+                if len(since) > 0:
+                    output.write(" version='%s'" % escape(since))
+                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