godot-docs
godot-docs copied to clipboard
Add GDExtension C++ snippets to tutorials/best_practices
C++ documentation for tutorials/best_practices. I mostly have this done but it definitely needs some feedback/review/testing.
General question about the rest of the cpp documentation going forward: Should I add the GDCLASS, empty constructor, and _bind_methods to every class?
These are technically required for the C++ code to compile. However, adding these makes it harder for the reader to get the point the documentation is actually trying to make because they have to parse through a lot more boilerplate code. So im not sure it is actually useful to include in snippets outside of the initial tutorial documentation.
Progress
-
scene_organization.rst - Done
-
scenes_versus_scripts.rst - Decided writing these snippets in C++ isn't really relevant. GDExtension doesn't really have a concept of "scripts" since everything is an actual Node/Object.
-
godot_interfaces.rst - TODO
-
godot_notifications.rst - Done, some of the code in the first block isn't correct. Might want to check how I did the
_unhandled_inputto make sure it is ideal, this is how I've been doing it in my code but not sure if it is necessarily the "correct" way to do it even though it does work. -
data_preferences.rst - This isn't really entirely relevant to C++ either. Should probably be a separate GDExtension article for this that explains all the data structures in godot-cpp/templates and this article should link to that new article. Since a majority of the time (at least in my code) you are using the template data structures instead of the Variant one's unless you are exporting the code to gdscript.
-
logic_preferences.rst - Done
-
autoloads_versus_internal_nodes.rst - There should probably be a note that GDExtension actually does use singletons via
Engine::get_singleton()->register_singleton. Maybe a new GDExtension example page on how to create singletons because its pretty common.
I can get the new singleton and data structures articles started if we think they would be good to add, but might want to do it in a separate PR idk what would be best.
I think this should be all good to merge now on my end unless someone finds more problems with it in review. I was planning to do godot_interfaces.rst but lost motivation to chug through the example snippets by myself.
Same with https://github.com/godotengine/godot-docs/pull/9821. I believe they should both be ready to merge once reviewed.
Will go over this again today
Thanks, these changes seem good to me!
However, this'll need to be squashed to a single commit in order to be merged. See https://docs.godotengine.org/en/latest/contributing/workflow/pr_workflow.html#the-interactive-rebase
I rebased/squashed all the commits from this PR and did the same for https://github.com/godotengine/godot-docs/pull/9821, both PRs should both be good to go now.
Merged. Thanks and congrats on your first merged contribution! Amazing work :)