Skip to content

Commit 8a2d4a5

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 7634fe7 commit 8a2d4a5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

godot-codegen/src/generator/default_parameters.rs

+6
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 qualified_extended_fn_name_str = format!("Self::{}", 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);
@@ -97,6 +98,11 @@ pub fn make_function_definition_with_defaults(
9798
};
9899

99100
let functions = quote! {
101+
#[doc = "To set the default parameters, use [`"]
102+
#[doc = #qualified_extended_fn_name_str]
103+
#[doc = "`] and its builder methods. See"]
104+
#[doc = " [the book](https://godot-rust.github.io/book/godot-api/functions.html#default-parameters) for"]
105+
#[doc = " detailed usage instructions."]
100106
#[inline]
101107
#vis fn #simple_fn_name(
102108
#receiver_param

0 commit comments

Comments
 (0)