scripts: apibuild: parse 'Since' for typedefs

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>
This commit is contained in:
Victor Toso 2022-04-22 21:23:40 +02:00 committed by Andrea Bolognani
parent 2f1c01e672
commit 8be766e39c

View File

@ -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")