-
-
Notifications
You must be signed in to change notification settings - Fork 229
try to add doc comments to functions #1207
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
base: master
Are you sure you want to change the base?
Conversation
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1207 |
1 similar comment
This comment was marked as duplicate.
This comment was marked as duplicate.
Well, I noticed something weird: the 4 properties limit_bottom, limit_left, limit_right, limit_top all refer to the same two methods: set_limit and get_limit.
In the C++ implementation, they do pass the SIDE as the last parameter of the macro: ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit_left", PROPERTY_HINT_NONE, "suffix:px"), "set_limit", "get_limit", SIDE_LEFT);
ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit_top", PROPERTY_HINT_NONE, "suffix:px"), "set_limit", "get_limit", SIDE_TOP);
ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit_right", PROPERTY_HINT_NONE, "suffix:px"), "set_limit", "get_limit", SIDE_RIGHT);
ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit_bottom", PROPERTY_HINT_NONE, "suffix:px"), "set_limit", "get_limit", SIDE_BOTTOM); So at least in some cases I'd need to keep the documentation for the function, even if it is part of a property. |
Thanks for the contribution!
To be honest I don't think the boilerplate is very useful. This reminds me of the "Javadoc best practice" 🙂 /**
* Get the position.
*
* Returns the position of the object as a 2D vector.
*
* @return position of the object.
*/
Vector2 getPosition(); If we change docs, we should rather go the full mile and import the real docs from Godot. See also #584 (this extends to classes and utilitiy functions, not just builtin types). This would also obviate the need for per-method links, and messing with properties. We still have the class link on the top of each page.
It's even better, this is now available in the JSON, when invoking Godot with We could maybe start supporting it in |
I agree! Depending on how complex ingesting the actual docs is, I would still see some value in relatively quickly adding the link to the online docs though. |
I'm attempting to add more documentation to the API and opened the PR relatively early to gather feedback.
Currently, there is no documentation on the autogenerated functions from the godot API:
Example:
https://godot-rust.github.io/docs/gdext/master/godot/classes/struct.Camera2D.html
This PR adds some boilerplate text, and a link to the godot online docs:
At minimum I'll need to properly detect properties by reading the field from the json (https://raw.githubusercontent.com/godot-rust/godot4-prebuilt/refs/heads/4.4/res/extension_api.json), in the rust code it's currently commented out:
gdext/godot-codegen/src/models/json.rs
Line 63 in 20cd346
This is relevant for link generation, and I'm trying to auto-detect it by the
get_ / set_
prefixes, but there are godot methods with aget_
prefix, for example Camera2D.get_limit, which now falsely get detected as a property.Additionally it would be great to verbatim include the documentation, and this is available in XML format here.