Skip to content

Add GDExtension C++ code snippets to GettingStarted #9821

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dementive
Copy link
Contributor

I have been writing a project entirely in GDExtension C++ and I noticed the Godot 3.6 documentation had C++ snippets all over but there are still not any C++ snippets for anything in the 4.0 docs.

So I'd like to start an effort to get all of these filled out because GDExtension is extremely usable at this point in my opinion. Unfortunately it is not very accessible to most due to the current lack of documentation (unless you are sadistic and actually enjoy reading C++ source code to find out how to do things like me).

I figured it would be best to start at the beginning of the docs with the first place code blocks found in scripting_first_script.rst. I want to get some feedback on this and if the way I am doing it is acceptable I can go through and do a lot more of them, transcribing Gdscript to C++ is a pretty trivial and mindless task for me at this point so I can get through a lot of them pretty quickly I feel, especially with some help from other C++ fellas.

To ensure the documentation I am writing is both consistently formatted and actually correct. I have a specific setup to make sure I'm not writing nonsense code that doesn't work.

  1. Setting up a basic GDExtension project to write the documentation in so I can use clangd to ensure all the code I'm writing and adding to the docs will actually compile without benign easy to find errors.

  2. Compiling my code, testing it in the editor (if possible) and making sure it is actually doing what the documentation describes.

  3. Before I add any of my code to the documentation blocks I run clang-format -i ./File.cpp from inside the Godot repository to ensure the formatting uses the exact same rules Godot source code would. There are some formatting things clang-format won't enforce, so I'm also comparing my style to the code style of godot-cpp's header files and trying to make sure they are always the exact same.

  4. Building the docs and testing that my changes actually did what they were supposed to.

If I am doing anything wrong here or you think my process could be improved let me know! If everything here looks good let me know and I'll keep working through these to add C++ code blocks everywhere.

@AThousandShips AThousandShips added enhancement area:getting started Issues and PRs related to the Getting Started section of the documentation topic:gdextension labels Aug 23, 2024
@dementive
Copy link
Contributor Author

Should be all good now. I worked through everything you mentioned, thanks for the detailed feedback!

I am going to try to finish up the "Listening to player input" section over the weekend. Also will add a info box to the top of the "Using Signals" article with a link to the bottom of the "GDExtension Example" documentation that discussed signals. This seems like it will be sufficient since the articles are both basically identical, I don't see a point in filling out the "Using Signals" article with C++ snippets when the same info is in another place.

Looking forward I don't really see a point in adding C++ snippets to either of the "Your first X game" sections because if it is a users first attempt at using Godot they really shouldn't use C++ (in my opinion) since they will need to know a good amount of gdscript to effectively use GDExtension anyway.

So I'm thinking this will be good to merge once I finish up "Listening to player input" and "Using Signals".

@AThousandShips AThousandShips dismissed their stale review August 24, 2024 09:11

Will go over the code and test it but looks good!

@Maarrk
Copy link
Contributor

Maarrk commented Jan 29, 2025

This is absolutely lovely, I wish knew about this and #9837 when learning GDExtension!

I wonder how to link this best from the GDExtension tutorial? I only found out by browsing PR list, after I already went through the path of reading source code and error traces.

@AThousandShips AThousandShips requested a review from a team January 29, 2025 11:50
Copy link
Contributor

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

For the most part this looks really good, and would be nice to have, just to show people it's possible and what it looks like.

@dementive
Copy link
Contributor Author

Merged in your changes and squashed, should be good to go now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:getting started Issues and PRs related to the Getting Started section of the documentation enhancement topic:gdextension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants