Skip to content

Commit 3a8d559

Browse files
authored
Interpolate WorldQuery path in docs of generated types (#14985)
# Objective Fixes #14972 ## Solution Uses the `concat!` macro to interpolate the `path` variable. ## Testing * Run `cargo doc --workspace --open` * Check functionality of `WorldQuery` links within `NodeQueryItem`, `NodeQueryReadOnly`, `NodeQueryReadOnlyItem` docs
1 parent 4147422 commit 3a8d559

File tree

3 files changed

+38
-18
lines changed

3 files changed

+38
-18
lines changed

crates/bevy_ecs/macros/src/query_data.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,13 @@ pub fn derive_query_data_impl(input: TokenStream) -> TokenStream {
250250
user_where_clauses_with_world,
251251
);
252252
let read_only_structs = quote! {
253-
#[doc = "Automatically generated [`WorldQuery`] type for a read-only variant of [`"]
254-
#[doc = stringify!(#struct_name)]
255-
#[doc = "`]."]
253+
#[doc = concat!(
254+
"Automatically generated [`WorldQuery`](",
255+
stringify!(#path),
256+
"::query::WorldQuery) type for a read-only variant of [`",
257+
stringify!(#struct_name),
258+
"`]."
259+
)]
256260
#[automatically_derived]
257261
#visibility struct #read_only_struct_name #user_impl_generics #user_where_clauses {
258262
#(
@@ -331,9 +335,13 @@ pub fn derive_query_data_impl(input: TokenStream) -> TokenStream {
331335

332336
const _: () = {
333337
#[doc(hidden)]
334-
#[doc = "Automatically generated internal [`WorldQuery`] state type for [`"]
335-
#[doc = stringify!(#struct_name)]
336-
#[doc = "`], used for caching."]
338+
#[doc = concat!(
339+
"Automatically generated internal [`WorldQuery`](",
340+
stringify!(#path),
341+
"::query::WorldQuery) state type for [`",
342+
stringify!(#struct_name),
343+
"`], used for caching."
344+
)]
337345
#[automatically_derived]
338346
#visibility struct #state_struct_name #user_impl_generics #user_where_clauses {
339347
#(#named_field_idents: <#field_types as #path::query::WorldQuery>::State,)*

crates/bevy_ecs/macros/src/query_filter.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,13 @@ pub fn derive_query_filter_impl(input: TokenStream) -> TokenStream {
145145

146146
const _: () = {
147147
#[doc(hidden)]
148-
#[doc = "Automatically generated internal [`WorldQuery`] state type for [`"]
149-
#[doc = stringify!(#struct_name)]
150-
#[doc = "`], used for caching."]
148+
#[doc = concat!(
149+
"Automatically generated internal [`WorldQuery`](",
150+
stringify!(#path),
151+
"::query::WorldQuery) state type for [`",
152+
stringify!(#struct_name),
153+
"`], used for caching."
154+
)]
151155
#[automatically_derived]
152156
#visibility struct #state_struct_name #user_impl_generics #user_where_clauses {
153157
#(#named_field_idents: <#field_types as #path::query::WorldQuery>::State,)*

crates/bevy_ecs/macros/src/world_query.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@ pub(crate) fn item_struct(
1919
user_ty_generics_with_world: &TypeGenerics,
2020
user_where_clauses_with_world: Option<&WhereClause>,
2121
) -> proc_macro2::TokenStream {
22-
let item_attrs = quote!(
23-
#[doc = "Automatically generated [`WorldQuery`](#path::query::WorldQuery) item type for [`"]
24-
#[doc = stringify!(#struct_name)]
25-
#[doc = "`], returned when iterating over query results."]
26-
#[automatically_derived]
27-
);
22+
let item_attrs = quote! {
23+
#[doc = concat!(
24+
"Automatically generated [`WorldQuery`](",
25+
stringify!(#path),
26+
"::query::WorldQuery) item type for [`",
27+
stringify!(#struct_name),
28+
"`], returned when iterating over query results."
29+
)]
30+
#[automatically_derived]
31+
};
2832

2933
match fields {
3034
Fields::Named(_) => quote! {
@@ -69,9 +73,13 @@ pub(crate) fn world_query_impl(
6973
) -> proc_macro2::TokenStream {
7074
quote! {
7175
#[doc(hidden)]
72-
#[doc = "Automatically generated internal [`WorldQuery`] fetch type for [`"]
73-
#[doc = stringify!(#struct_name)]
74-
#[doc = "`], used to define the world data accessed by this query."]
76+
#[doc = concat!(
77+
"Automatically generated internal [`WorldQuery`](",
78+
stringify!(#path),
79+
"::query::WorldQuery) fetch type for [`",
80+
stringify!(#struct_name),
81+
"`], used to define the world data accessed by this query."
82+
)]
7583
#[automatically_derived]
7684
#visibility struct #fetch_struct_name #user_impl_generics_with_world #user_where_clauses_with_world {
7785
#(#named_field_idents: <#field_types as #path::query::WorldQuery>::Fetch<'__w>,)*

0 commit comments

Comments
 (0)