-
-
Notifications
You must be signed in to change notification settings - Fork 461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow submitting documentation to the Godot editor #1374
Conversation
9588567
to
46e595a
Compare
Alright, I've figured out a reasonably nice way for developers to use this functionality, that is as simple and automatic as I could make it. So, I'm taking this out of draft - it's ready for review! The one main thing I still need to figure out is handling CMake support, but I don't think that'll be too hard. Feedback on the overall approach would be appreciated! |
Hi @dsnopek, what about being able to read documentation for existing classes? For example, a custom extension/plug-in that may want to display the description associated with a specific Godot native, extension contributed, or script contributed class as part of their UI? |
I don't think Godot gives us an API to read documentation, unfortunately. That would be something to propose for Godot, before we could do anything in godot-cpp. If it was through classes bound in Your PR godotengine/godot#90189 is probably the closest thing that exists presently, allowing editor plugins to show particular documentation to the user, but not actually read its content. |
Tested this PR and the upstream godot one on my Threen extension: It works great, and out of the box! The instructions in the PR were clear. Some minor issues / potential future work I noticed:
|
Source compatibilityShould we consider the use case of maintaining an extension that may want to make use of this new feature for builds using 4.3+ as baseline, while still keeping the possibility to build for older Godot versions when targeting an older godot-cpp commit? This may require adding an API in the godot-cpp env like diff --git a/SConstruct b/SConstruct
index 4f19de1..781fc98 100644
--- a/SConstruct
+++ b/SConstruct
@@ -7,9 +7,10 @@ env = SConscript("godot-cpp/SConstruct")
env.Append(CPPPATH=["src/"])
sources = Glob("src/*.cpp")
-if env["target"] in ["editor", "template_debug"]:
- doc_data = env.GodotCPPDocData("src/gen/doc_data.gen.cpp", source=Glob("doc_classes/*.xml"))
- sources.append(doc_data)
+if env.has_feature("doc_data"):
+ if env["target"] in ["editor", "template_debug"]:
+ doc_data = env.GodotCPPDocData("src/gen/doc_data.gen.cpp", source=Glob("doc_classes/*.xml"))
+ sources.append(doc_data)
if env["platform"] == "macos":
platlibname = "{}.{}.{}".format(libname, env["platform"], env["target"]) Of course this wouldn't work right now for versions of godot-cpp before adding this Another approach that's already usable for this specific feature is simply a diff --git a/SConstruct b/SConstruct
index 4f19de1..e18ff0e 100644
--- a/SConstruct
+++ b/SConstruct
@@ -8,8 +8,11 @@ env.Append(CPPPATH=["src/"])
sources = Glob("src/*.cpp")
if env["target"] in ["editor", "template_debug"]:
- doc_data = env.GodotCPPDocData("src/gen/doc_data.gen.cpp", source=Glob("doc_classes/*.xml"))
- sources.append(doc_data)
+ try:
+ doc_data = env.GodotCPPDocData("src/gen/doc_data.gen.cpp", source=Glob("doc_classes/*.xml"))
+ sources.append(doc_data)
+ except AttributeError:
+ print("Not including class reference as we're targeting a pre-4.3 baseline.")
if env["platform"] == "macos":
platlibname = "{}.{}.{}".format(libname, env["platform"], env["target"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, and I tested the feature which works great.
@akien-mga Thanks for doing such extensive testing and review!
I also encountered this (but only two times), and I also suspect something with the doc cache. This needs more investigation, but I don't think the problem is on the godot-cpp side, so I think it's out-of-scope for this PR.
This turned out to be a godot-cpp bug: I've added a fix for this in my latest push!
Maybe we can recommend the As far as "recommending" the approach, I considered putting it into |
Tested and confirmed the fix, I got three methods in Threen with the
Sounds good yeah.
Yes I think we could add this to godot-cpp-template. |
Thanks! |
Godot PR godotengine/godot#83747 added support for submitting documentation to the Godot editor from a GDExtension.
This PR aims to give godot-cpp users a way to use that, ideally, in much the same way as documentation is provided by modules.
Here's how it works:
--gdextension-docs
with--doctool
godot#91518, developers can rungodot --doctool ../ --gdextension-docs
in their demo project (assuming the project is in a directory below their top-level extension code) which will generate adoc_classes/
directorydoc_classes/
directorySConstruct
:When the GDExtension is loaded into the editor, it will automatically submit the documentation XML.
I'm not totally sure how to add this in CMake, but I think we can do it in a similar way to how we run
binding_generator.py
from CMake. I'd really appreciate any help with that!Original description
I'm not entirely sure how we should expose this to developers. What I have here presently, is mostly about being able to test that the functionality from the Godot PR works. This could certainly use some design help for how to expose the build-system part (both for SCons and cmake) as well as how the developer should trigger the registration.We'll also probably need some tooling somewhere, to assist in generating the XML files for extension classes. It looks likegodot --doctool
doesn't include extension classes, so we'll either need to modify it so that it does, or come up with some other process.