Skip to content
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

Add fallback argument hints for default values #88211

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

bitwise-aiden
Copy link
Contributor

@bitwise-aiden bitwise-aiden commented Feb 11, 2024

Closes: #78191

In lieu of having constexpr, this solution proposes a fallback to provide a better hint to developers about what the default value of a method is.

I've used a similar approach to generating a default as GDScriptDocGen::_docvalue_from_variant, but assuming recursion depth is always met.

This provides value to developers by now being able to know if there is an array to be expected and if it is empty or not at a glance instead of going to look at the source for a method.

It could possibly be extended a little to include a small recursion depth, but I think that this is a good first step towards QOL.

Screen.Recording.2024-02-11.at.10.08.38.AM.mov

^ All forms of defaults are now in line with how constant and variable defaults are created.

Copy link
Member

@dalexeev dalexeev left a comment

Choose a reason for hiding this comment

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

Looks good to me. In the future we may replace _docvalue_from_variant() with a hint_from_expression() and use this in both DocGen and the editor, but for now it looks like a small and fine change.

@akien-mga akien-mga merged commit c8b3e39 into godotengine:master Feb 12, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks! And congrats for your first merged Godot contribution 🎉

@bitwise-aiden
Copy link
Contributor Author

In the future we may replace _docvalue_from_variant() with a hint_from_expression() and use this in both DocGen and the editor

When I get the chance I'll have a look into it.

Thanks! And congrats for your first merged Godot contribution 🎉

Thank you! First of many I hope ;p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants