gtk-rs / gir

Tool to generate rust bindings and user API for glib-based libraries
https://gtk-rs.org/gir/book/
MIT License
237 stars 107 forks source link

Omit user_data & user_destroy from docs of functions parameters #1115

Closed bilelmoussaoui closed 3 years ago

bilelmoussaoui commented 3 years ago

They are generated for functions that takes a callback, they can be omitted as they are not really useful

image

cc @MarijnS95

MarijnS95 commented 3 years ago

There are many, many things from the C docs that are irrelevant or useless for Rust docs. We should probably set up a set of rules somewhere to omit certain parameters and functions, I guess?

bilelmoussaoui commented 3 years ago

Indeed. I'm going through the gtk4-rs docs, if i find more stuff I will open an issue. Maybe we can have some kind of labels here on gir to differentiate docs issues from code generation ones. What do you think @sdroege @GuillaumeGomez ?

GuillaumeGomez commented 3 years ago

You mean parsing doc comments in gir binary? If so, I don't think it's a good idea...

bilelmoussaoui commented 3 years ago

There's no parsing of the docs required :)

Those docs comes from

          <parameter name="user_data" transfer-ownership="none" nullable="1" allow-none="1">
            <doc xml:space="preserve">user data to pass to @match_func</doc>
            <type name="gpointer" c:type="gpointer"/>
          </parameter>
          <parameter name="user_destroy" transfer-ownership="none" scope="async">
            <doc xml:space="preserve">destroy notify for @user_data</doc>
            <type name="GLib.DestroyNotify" c:type="GDestroyNotify"/>
          </parameter>

It would just need a condition when generating a function documentation from gir to omit some specific parameter names that are C only.

bilelmoussaoui commented 3 years ago

Btw, the cc was about adding issues labels to gir so we can find stuff more easily

GuillaumeGomez commented 3 years ago

Oh I see. Much simpler indeed! Then yes, it's totally doable and would improve the documentation!

PS: I also added a label. :)

bilelmoussaoui commented 3 years ago

Thanks a lot! :D