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

Victor Toso posted 4 patches 3 years, 10 months ago
There is a newer version of this series
[PATCH v1 2/4] scripts: apibuild: parse 'Since' for typedefs
Posted by Victor Toso 3 years, 10 months ago
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@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
Re: [PATCH v1 2/4] scripts: apibuild: parse 'Since' for typedefs
Posted by Michal Prívozník 3 years, 10 months ago
On 4/5/22 13:43, Victor Toso wrote:
> 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>
> ```
> 

I'm not exactly sure why, but this diff in commit message causes my git
to think this is a broken patch. Maybe it's trying to parse it as an
actual patch? Funnily enough, there's no problem with 1/4.

Michal
Re: [PATCH v1 2/4] scripts: apibuild: parse 'Since' for typedefs
Posted by Victor Toso 3 years, 10 months ago
Hi,

On Tue, Apr 05, 2022 at 04:52:09PM +0200, Michal Prívozník wrote:
> On 4/5/22 13:43, Victor Toso wrote:
> > 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>
> > ```
> > 
> 
> I'm not exactly sure why, but this diff in commit message causes my git
> to think this is a broken patch. Maybe it's trying to parse it as an
> actual patch? Funnily enough, there's no problem with 1/4.
> 
> Michal

When I send a v2, I'll make both examples above quoted, that is,
prefixed with: " > ". Not sure why I actually used ```diff and
```xml, gitlab does nothing with it x)

Cheers,
Victor
Re: [PATCH v1 2/4] scripts: apibuild: parse 'Since' for typedefs
Posted by Andrea Bolognani 3 years, 10 months ago
On Tue, Apr 05, 2022 at 05:36:51PM +0200, Victor Toso wrote:
> On Tue, Apr 05, 2022 at 04:52:09PM +0200, Michal Prívozník wrote:
> > On 4/5/22 13:43, Victor Toso wrote:
> > > 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;
> > > ```
> >
> > I'm not exactly sure why, but this diff in commit message causes my git
> > to think this is a broken patch. Maybe it's trying to parse it as an
> > actual patch? Funnily enough, there's no problem with 1/4.
>
> When I send a v2, I'll make both examples above quoted, that is,
> prefixed with: " > ". Not sure why I actually used ```diff and
> ```xml, gitlab does nothing with it x)

I think you can leave the examples out entirely. The "Since x.y.z"
comments are already a known quantity, and you're just extending
their applicability to more public symbols.

-- 
Andrea Bolognani / Red Hat / Virtualization