-
-
Notifications
You must be signed in to change notification settings - Fork 200
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 a doc to point users to kwarg builders #876
Add a doc to point users to kwarg builders #876
Conversation
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-876 |
Maybe we should also link the book? https://godot-rust.github.io/book/godot-api/functions.html?highlight=default#default-parameters |
23ecd15
to
c07ed2b
Compare
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.
Thanks, great idea! 🙂
Please also indent the attributes.
CI blocked by upstream godotengine/godot#96406.
#[doc = "To set the default parameters, use [`"] | ||
#[doc = stringify!(Self::#extended_fn_name)] | ||
#[doc = "`] and its builder methods. See"] | ||
#[doc = " [the book](https://godot-rust.github.io/book/godot-api/functions.html?highlight=default#default-parameters) for"] |
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.
The ?highlight=default
is distracting and shouldn't be part of the link.
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.
fixed
@@ -97,6 +97,11 @@ pub fn make_function_definition_with_defaults( | |||
}; | |||
|
|||
let functions = quote! { | |||
#[doc = "To set the default parameters, use [`"] | |||
#[doc = stringify!(Self::#extended_fn_name)] |
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.
This generates code containing a macro, which then again needs to be expanded by the compiler. Could you not create the entire doc-string at proc-macro time?
Then you could just have #[doc = #link_to_ex_function]
.
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.
Any comment on this one? Why not generate the whole string at macro time and have a single #[doc]
attribute? Would help readability and make it easier to change the text in the future than distributing it over 5 #[doc = ...]
lines.
And who knows, maybe it helps with the rustfmt issue, too 😉
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.
Ah sorry, I should've commented. This is fixed in the version I pushed yesterday. Unfortunately, no help with the rustfmt issue.
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.
I looked at the diff, but the current code is still
#[doc = "To set the default parameters, use [`"]
#[doc = #qualified_extended_fn_name_str]
#[doc = "`] and its builder methods. See"]
#[doc = " [the book](https://godot-rust.github.io/book/godot-api/functions.html#default-parameters) for"]
#[doc = " detailed usage instructions."]
So I was wondering why not a single #[doc]
attribute, and do the concatenation outside, so the generated code sees only one string literal.
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.
Ah that's what you mean, ok. I'll see if I can do that this weekend.
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.
fixed
rustfmt won't allow that.
Possibly related to rust-lang/rustfmt#6233, but only in that it's incorrect formatting around macros. |
7753722
to
6a198ca
Compare
6a198ca
to
8a2d4a5
Compare
Not sure if you've seen id, I added a comment here 🙂 |
A frequent issue that comes up with people that are first using the library is that they don't know about gdext's unique model for Gdscript's default function arguments. This gently points users to the builder functions. Documenting every method this way is a little spammy since users only need to learn about this API once, but it's only one line, so I don't think it impacts scrolling distances much on the doc site.
8a2d4a5
to
a763f14
Compare
Thank you! 🙂 |
A frequent issue that comes up with people that are first using the library is that they don't know about gdext's unique model for Gdscript's default function arguments. This gently points users to the builder functions.
Documenting every method this way is a little spammy since users only need to learn about this API once, but it's only one line, so I don't think it impacts scrolling distances much on the doc site.