Skip to content

Commit a763f14

Browse files
committed
Add a doc to point users to kwarg builders
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.
1 parent cdf6c5c commit a763f14

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

godot-codegen/src/generator/default_parameters.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub fn make_function_definition_with_defaults(
2626

2727
let simple_fn_name = safe_ident(sig.name());
2828
let extended_fn_name = format_ident!("{}_ex", simple_fn_name);
29+
let default_parameter_usage = format!("To set the default parameters, use [`Self::{}`] and its builder methods. See [the book](https://godot-rust.github.io/book/godot-api/functions.html#default-parameters) for detailed usage instructions.", extended_fn_name);
2930
let vis = functions_common::make_vis(sig.is_private());
3031

3132
let (builder_doc, surround_class_prefix) = make_extender_doc(sig, &extended_fn_name);
@@ -101,6 +102,7 @@ pub fn make_function_definition_with_defaults(
101102
};
102103

103104
let functions = quote! {
105+
#[doc = #default_parameter_usage]
104106
#[inline]
105107
#vis fn #simple_fn_name(
106108
#receiver_param

0 commit comments

Comments
 (0)