moonzel
January 17, 2024, 11:11pm
1
Godot Version
4.2.1 Stable
Question
Hello Godot community! I have gotten a request on my plugin that uses C++ to include documentation that would be visible in the Godot editor. Does anyone know how to create documentation for classes made in GDExtension?
1 Like
coder
January 19, 2024, 8:50am
2
This feature seems to be in the works.
godotengine:master
← akien-mga:gdextension-class-doc
opened 09:41AM - 28 Mar 23 UTC
This can be used from a GDExtension's init callback to add zlib-compressed class… reference XML data for use in the editor help.
This is a proof of concept. I'm not very familiar with GDExtension yet and there might be better ways to implement this.
Adding this data to Engine is a bit arbitrary, especially given that it's for the editor only, but I'm not sure what's a better location. We often store this in EditorNode but it's not available from GDExtension. There's EditorInterface available through EditorPlugin but that sounds like it would require a bit more boilerplate to set up just to pass some data.
I also had to use PackedByteArray to pass data through GDExtension, so it's fairly inefficient to write the data to a char buffer, copy it to a PackedByteArray to pass, and then it ends up being accessed back as a char buffer.
Here's a branch on my Threen extension where I'm using this PR to expose the docs. It requires some extra scons tooling copied from this repo to compress the XML and write it to a header, we can add it to godot-cpp's tools folder so it's available for all projects with a convenient API. https://github.com/akien-mga/threen/compare/classref
I'm a bit out of my comfort zone here, happy to get suggestions / diffs / PRs to this branch / superseding PRs.
The documentation right now doesn’t support it. However, if you’re a module developer, there is a way to add your own documentation in a similar way to the engine .
I’m working on a GDExtension and found this thread when looking up how to add docs for my classes.
Looks like https://github.com/godotengine/godot/pull/83747 is the latest work on this and has been merged. So for Godot 4.3 GDExtensions can call a function to register XML documentation.
If anyone has any more information or documentation about how to use this or how to generate XML properly please let me know. I’m assuming the right thing is to use godot --doctool
with some hacking of the configuration.
1 Like
Heza666
September 4, 2024, 4:21pm
4
You can use internal::gdextension_interface_editor_help_load_xml_from_utf8_chars_and_len
it must be called within EditorPlugin