How to create proper documentation for a gdextension using godot-cpp ?

Godot Version

4.6.dev3

Question

Hi, I am creating a gdextension plugin in c++. I am now trying to add documentation to my plugin, but I can’t seem to make it work reliably.

Of course, I read this page : Adding documentation — Godot Engine (stable) documentation in English

But this does not work properly for me. The methods that I have bind don’t appear in the doc (except one that was there the first time I created the doc ?!) and when I add content, it is consistently erased by the doctool …

What am I missing? Is there another place where I can read some doc on how to add doc ?

Thanks,

atn

It seems that functions starting with get or set are not added to the doc.

And any function starting with “_” , neither.

This means I cannot document callbacks created in my plugin, as far as I understand.

For what it’s worth, I solved my problem.

In godot’s source code, the doc is not created if the method starts with ‘_’ AND the method is not virtual
Therefore, it is needed to declare and bind your function as virtual.

To do so, do not declare your method in the header and cpp file as usual. Just use:
in the header : GDVIRTUAL1(_your_method, Variant);
in the cpp file : GDVIRTUAL_BIND(_your_method, "_args");

And that’s it !!!

and there are more functions, some of them:
GDVIRTUAL3R_REQUIRED(int, _mix, GDExtensionPtr, float, int);
GDVIRTUAL2(_set_parameter, const StringName &, const Variant &);
GDVIRTUAL1(_set_paused, bool);
GDVIRTUAL1RC(Variant, _get_script_method_argument_count, const StringName &);
GDVIRTUAL1RC_REQUIRED(Dictionary, _get_method_info, const StringName &);
GDVIRTUAL0(_tag_used_streams)
GDVIRTUAL0RC(bool, _is_playing);

1 Like