From 1f22d544891adbeb717f5a8dac3e814b8e521a14 Mon Sep 17 00:00:00 2001 From: CGMossa Date: Tue, 1 Nov 2022 23:44:55 +0000 Subject: [PATCH] Fixed docs for `derive(WorldQuery)`. (#5283) For `derive(WorldQuery)`, there are three structs generated, `Item`, `Fetch` and `State`. These inherit the visibility of the derived structure, thus `#![warn(missing_docs)]` would warn about missing documentation for these structures. - [ ] I'd like some advice on what to write here, as I personally don't really understand `Fetch` nor `State`. --- crates/bevy_ecs/macros/src/fetch.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/bevy_ecs/macros/src/fetch.rs b/crates/bevy_ecs/macros/src/fetch.rs index 8d2c48bf4104b..7965c8ce2def2 100644 --- a/crates/bevy_ecs/macros/src/fetch.rs +++ b/crates/bevy_ecs/macros/src/fetch.rs @@ -180,6 +180,9 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream { quote! { #derive_macro_call + #[doc = "Automatically generated [`WorldQuery`] item type for [`"] + #[doc = stringify!(#struct_name)] + #[doc = "`], returned when iterating over query results."] #[automatically_derived] #visibility struct #item_struct_name #user_impl_generics_with_world #user_where_clauses_with_world { #(#(#field_attrs)* #field_visibilities #field_idents: <#field_types as #path::query::WorldQueryGats<'__w>>::Item,)* @@ -187,6 +190,10 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream { } #[doc(hidden)] + #[doc = "Automatically generated internal [`WorldQuery`] fetch type for [`"] + #[doc = stringify!(#struct_name)] + #[doc = "`], used to define the world data accessed by this query."] + #[automatically_derived] #visibility struct #fetch_struct_name #user_impl_generics_with_world #user_where_clauses_with_world { #(#field_idents: <#field_types as #path::query::WorldQueryGats<'__w>>::Fetch,)* #(#ignored_field_idents: #ignored_field_types,)* @@ -331,6 +338,10 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream { let readonly_impl = if fetch_struct_attributes.is_mutable { let world_query_impl = impl_fetch(true); quote! { + #[doc(hidden)] + #[doc = "Automatically generated internal [`WorldQuery`] type for [`"] + #[doc = stringify!(#struct_name)] + #[doc = "`], used for read-only access."] #[automatically_derived] #visibility struct #read_only_struct_name #user_impl_generics #user_where_clauses { #( #field_idents: #read_only_field_types, )* @@ -369,6 +380,10 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream { #readonly_impl #[doc(hidden)] + #[doc = "Automatically generated internal [`WorldQuery`] state type for [`"] + #[doc = stringify!(#struct_name)] + #[doc = "`], used for caching."] + #[automatically_derived] #visibility struct #state_struct_name #user_impl_generics #user_where_clauses { #(#field_idents: <#field_types as #path::query::WorldQuery>::State,)* #(#ignored_field_idents: #ignored_field_types,)*