diff --git a/crates/macros/cgp-macro-core/src/types/cgp_component/preprocessed/item.rs b/crates/macros/cgp-macro-core/src/types/cgp_component/preprocessed/item.rs index 8ae224192..f665f1eb1 100644 --- a/crates/macros/cgp-macro-core/src/types/cgp_component/preprocessed/item.rs +++ b/crates/macros/cgp-macro-core/src/types/cgp_component/preprocessed/item.rs @@ -17,9 +17,11 @@ impl PreprocessedCgpComponent { /// Build the zero-sized `{Provider}Component` marker struct. pub fn to_component_struct(&self) -> EmptyStruct { let component_name = &self.args.component_name; + let consumer_trait = &self.item_trait.ident; EmptyStruct { ident: component_name.ident.clone(), generics: component_name.type_generics.to_generics(), + doc: Some(format!("Component marker for [`{consumer_trait}`].")), } } diff --git a/crates/macros/cgp-macro-core/src/types/cgp_data/derive_builder/builder_struct.rs b/crates/macros/cgp-macro-core/src/types/cgp_data/derive_builder/builder_struct.rs index 5913ee51d..20debb057 100644 --- a/crates/macros/cgp-macro-core/src/types/cgp_data/derive_builder/builder_struct.rs +++ b/crates/macros/cgp-macro-core/src/types/cgp_data/derive_builder/builder_struct.rs @@ -13,6 +13,14 @@ pub fn derive_builder_struct( builder_struct.attrs.clear(); builder_struct.ident = builder_ident.clone(); + // The companion type carries a doc line, so a crate that enables + // `missing_docs` does not report it. + let context_ident = &context_struct.ident; + let builder_doc = format!("The partial builder for [`{context_ident}`]."); + builder_struct + .attrs + .push(syn::parse_quote!(#[doc = #builder_doc])); + let generics = &mut builder_struct.generics; for (i, field) in builder_struct.fields.iter_mut().enumerate() { diff --git a/crates/macros/cgp-macro-core/src/types/cgp_data/derive_extractor/extractor_enum.rs b/crates/macros/cgp-macro-core/src/types/cgp_data/derive_extractor/extractor_enum.rs index e180ae0f0..8c74e1890 100644 --- a/crates/macros/cgp-macro-core/src/types/cgp_data/derive_extractor/extractor_enum.rs +++ b/crates/macros/cgp-macro-core/src/types/cgp_data/derive_extractor/extractor_enum.rs @@ -20,6 +20,14 @@ pub fn derive_extractor_enum( extractor_enum.ident = extractor_ident.clone(); + // The companion type carries a doc line, so a crate that enables + // `missing_docs` does not report it. + let context_ident = &context_enum.ident; + let extractor_doc = format!("The partial extractor for [`{context_ident}`]."); + extractor_enum + .attrs + .push(syn::parse_quote!(#[doc = #extractor_doc])); + let generics = &mut extractor_enum.generics; for (i, variant) in extractor_enum.variants.iter_mut().enumerate() { @@ -59,6 +67,14 @@ pub fn derive_extractor_enum_ref( extractor_enum.ident = extractor_ident.clone(); + // The companion type carries a doc line, so a crate that enables + // `missing_docs` does not report it. + let context_ident = &context_enum.ident; + let extractor_doc = format!("The borrowed partial extractor for [`{context_ident}`]."); + extractor_enum + .attrs + .push(syn::parse_quote!(#[doc = #extractor_doc])); + // A variantless enum borrows nothing, so the `'__a__` lifetime and the // `__R__: MapTypeRef` selector would be unused parameters (`E0392`). Emit the // borrowed partial enum as a bare empty enum instead, and the impls that diff --git a/crates/macros/cgp-macro-core/src/types/cgp_fn/preprocessed.rs b/crates/macros/cgp-macro-core/src/types/cgp_fn/preprocessed.rs index fab6ff052..2c98e8004 100644 --- a/crates/macros/cgp-macro-core/src/types/cgp_fn/preprocessed.rs +++ b/crates/macros/cgp-macro-core/src/types/cgp_fn/preprocessed.rs @@ -2,7 +2,7 @@ use syn::punctuated::Punctuated; use syn::token::Plus; use syn::{ Generics, Ident, Item, ItemFn, ItemImpl, ItemTrait, TraitItemFn, Type, TypeParamBound, - Visibility, + Visibility, parse_quote, }; use crate::functions::parse_internal; @@ -37,8 +37,26 @@ impl PreprocessedItemCgpFn { .. } = self; + // The function's doc comment describes the operation, so it stays on the + // method, where the function's body lands. The trait gets a line of its + // own, and the method gets one when the function carries no doc, so a + // crate that enables `missing_docs` reports neither. + let (doc_attrs, other_attrs): (Vec<_>, Vec<_>) = attributes + .raw_attributes + .iter() + .cloned() + .partition(|attr| attr.path().is_ident("doc")); + + let mut method_attrs = item_fn.attrs.clone(); + method_attrs.extend(doc_attrs); + if !method_attrs.iter().any(|attr| attr.path().is_ident("doc")) { + let fn_ident = &item_fn.sig.ident; + let method_doc = format!("The `{fn_ident}` operation."); + method_attrs.push(parse_quote!(#[doc = #method_doc])); + } + let trait_item_fn = TraitItemFn { - attrs: item_fn.attrs.clone(), + attrs: method_attrs, sig: item_fn.sig.clone(), default: None, semi_token: None, @@ -65,7 +83,10 @@ impl PreprocessedItemCgpFn { attributes.use_type.transform_item_trait(&mut item_trait)?; - item_trait.attrs.extend(attributes.raw_attributes.clone()); + item_trait.attrs.extend(other_attrs); + let fn_ident = &item_fn.sig.ident; + let trait_doc = format!("The trait for the `{fn_ident}` operation."); + item_trait.attrs.push(parse_quote!(#[doc = #trait_doc])); item_trait.vis = visibility.clone(); Ok(item_trait) diff --git a/crates/macros/cgp-macro-core/src/types/cgp_provider/item.rs b/crates/macros/cgp-macro-core/src/types/cgp_provider/item.rs index 14e50e038..bc4fe5e90 100644 --- a/crates/macros/cgp-macro-core/src/types/cgp_provider/item.rs +++ b/crates/macros/cgp-macro-core/src/types/cgp_provider/item.rs @@ -80,9 +80,22 @@ impl ItemCgpProvider { let provider_type: IdentWithTypeGenerics = parse_internal!( #impl_self_type ); + let provider_trait = provider_impl + .trait_ + .as_ref() + .and_then(|(_, path, _)| path.segments.last().map(|s| s.ident.to_string())) + .unwrap_or_default(); + let provider_ident = &provider_type.ident; + let doc = if provider_trait.is_empty() { + format!("Provider `{provider_ident}`.") + } else { + format!("Provider `{provider_ident}` for [`{provider_trait}`].") + }; + let provider_struct = EmptyStruct { ident: provider_type.ident.clone(), generics: provider_type.type_generics.to_generics(), + doc: Some(doc), }; Ok(Some(provider_struct)) diff --git a/crates/macros/cgp-macro-core/src/types/delegate_component/table/inner.rs b/crates/macros/cgp-macro-core/src/types/delegate_component/table/inner.rs index 0cbe6b821..c649b6ab3 100644 --- a/crates/macros/cgp-macro-core/src/types/delegate_component/table/inner.rs +++ b/crates/macros/cgp-macro-core/src/types/delegate_component/table/inner.rs @@ -55,7 +55,12 @@ impl InnerDelegateTable { let ident = self.table_ident.clone(); let generics = self.table_generics.generics.clone(); - EmptyStruct { ident, generics } + let doc = Some(format!("Wiring table `{ident}`.")); + EmptyStruct { + ident, + generics, + doc, + } } pub fn build_impls(&self) -> syn::Result> { diff --git a/crates/macros/cgp-macro-core/src/types/delegate_component/table/main.rs b/crates/macros/cgp-macro-core/src/types/delegate_component/table/main.rs index ae05aae2d..0f7bb8f96 100644 --- a/crates/macros/cgp-macro-core/src/types/delegate_component/table/main.rs +++ b/crates/macros/cgp-macro-core/src/types/delegate_component/table/main.rs @@ -91,9 +91,11 @@ impl DelegateTable { } } + let doc = Some(format!("Wiring table `{}`.", struct_type.ident)); item_structs.push(EmptyStruct { ident: struct_type.ident, generics, + doc, }); } diff --git a/crates/macros/cgp-macro-core/src/types/empty_struct.rs b/crates/macros/cgp-macro-core/src/types/empty_struct.rs index 53c33a117..5bb5a7868 100644 --- a/crates/macros/cgp-macro-core/src/types/empty_struct.rs +++ b/crates/macros/cgp-macro-core/src/types/empty_struct.rs @@ -8,6 +8,9 @@ use crate::exports::Life; pub struct EmptyStruct { pub ident: Ident, pub generics: Generics, + /// The doc line emitted above the struct, so a crate that enables + /// `missing_docs` does not report the generated item. + pub doc: Option, } impl EmptyStruct { @@ -20,6 +23,10 @@ impl ToTokens for EmptyStruct { fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { let struct_ident = &self.ident; let struct_generics = &self.generics; + let struct_doc = self + .doc + .as_ref() + .map(|doc| quote_spanned! { struct_ident.span() => #[doc = #doc] }); // Stamp the synthesized `pub struct … ;` tokens with the struct ident's // span rather than the macro `call_site`, so a redefinition error @@ -30,6 +37,7 @@ impl ToTokens for EmptyStruct { if struct_generics.params.is_empty() { tokens.extend(quote_spanned! { span => + #struct_doc pub struct #struct_ident; }); } else { @@ -68,6 +76,7 @@ impl ToTokens for EmptyStruct { }; tokens.extend(quote_spanned! { span => + #struct_doc pub struct #struct_ident < #generic_params > ( pub ::core::marker::PhantomData< #phantom_type > ); diff --git a/crates/macros/cgp-macro-core/src/types/namespace/table.rs b/crates/macros/cgp-macro-core/src/types/namespace/table.rs index db22b3a76..391c39923 100644 --- a/crates/macros/cgp-macro-core/src/types/namespace/table.rs +++ b/crates/macros/cgp-macro-core/src/types/namespace/table.rs @@ -106,8 +106,14 @@ impl NamespaceTable { let namespace_trait = self.build_namespace_trait()?; let item_trait: Option = if self.new.is_some() { + let namespace_ident = &self.namespace.ident; + let trait_doc = format!("The `{namespace_ident}` namespace's wiring table."); + let delegate_doc = + format!("The provider table the `{namespace_ident}` namespace delegates to."); let item_trait = parse_internal! { + #[doc = #trait_doc] pub trait #namespace_trait { + #[doc = #delegate_doc] type Delegate; } }; @@ -153,7 +159,9 @@ impl NamespaceTable { namespace_ident.span(), ); + let namespace_doc = format!("Wiring table for the `{namespace_ident}` namespace."); let namespace_struct: ItemStruct = parse_internal! { + #[doc = #namespace_doc] pub struct #namespace_struct_ident; }; diff --git a/crates/tests/README.md b/crates/tests/README.md index 8b4eb5917..34ae2c92b 100644 --- a/crates/tests/README.md +++ b/crates/tests/README.md @@ -45,7 +45,13 @@ getters, field access, extensible records, extensible variants, checking, dispatching, namespaces, handlers, monadic handlers, async and Send bounds, blanket traits, and the standalone error backends (`error_backends`). The crate's build script turns the example in each error backend's README into a test module, which the `readme_*.rs` files -in `error_backends` include, so those examples are tested without being copied. The set grows and subdivides over time. `cgp-macro-tests` follows +in `error_backends` include, so those examples are tested without being copied. + +The library crate's `generated_docs` module denies `missing_docs` while using every macro, so a +generated item that loses its doc line fails the build. The `implicit_arguments` and +`basic_delegation` targets pin where a user's own doc comment lands. + +The set grows and subdivides over time. `cgp-macro-tests` follows the same shape, with `ident_with_type_params` and `shape_macro_parsing` for parser corner cases, `companion_attrs` for the attributes the data derives copy onto their companion types, and the failure-case targets `parser_rejections` and `invalid_expansion`. diff --git a/crates/tests/cgp-tests/src/generated_docs.rs b/crates/tests/cgp-tests/src/generated_docs.rs new file mode 100644 index 000000000..004f65b59 --- /dev/null +++ b/crates/tests/cgp-tests/src/generated_docs.rs @@ -0,0 +1,115 @@ +//! Every macro that declares a public item documents it. +//! +//! The module denies `missing_docs`, so this file fails to compile if a macro +//! stops emitting a doc line for an item it generates. It lives in the library +//! crate rather than an integration target because `missing_docs` only fires on +//! items exported from a library; a test binary exports nothing. The snapshot +//! modules pin the text of the generated docs, and this pins their presence. + +#![deny(missing_docs)] +// A doc comment on a macro invocation is consumed by the macro, which emits it on +// the generated items, so rustdoc never sees it here. +#![allow(unused_doc_comments)] + +use cgp::core::error::ErrorTypeProviderComponent; +use cgp::prelude::*; + +/// A component, whose marker struct the macro documents. +#[cgp_component(Greeter)] +pub trait CanGreet { + /// Greets. + fn greet(&self) -> String; +} + +/// A provider, whose struct the macro documents. +#[cgp_impl(new GreetHello)] +impl Greeter { + fn greet(&self) -> String { + "Hello".to_owned() + } +} + +/// A generic provider, whose struct and `PhantomData` field the macro documents. +#[cgp_impl(new GreetWith)] +impl Greeter +where + Name: Send + Sync, +{ + fn greet(&self) -> String { + "Hello".to_owned() + } +} + +/// A function-style trait, whose trait and method the macro documents. +#[cgp_fn] +pub fn greet_fn(&self, #[implicit] name: &str) -> String { + name.to_owned() +} + +/// An abstract type, whose marker struct the macro documents. +#[cgp_type] +pub trait HasProbeType { + /// The probe type. + type Probe; +} + +/// A getter, whose component the macro documents. +#[cgp_getter] +pub trait HasProbeGetter { + /// Reads the probe. + fn probe(&self) -> &str; +} + +/// An auto getter, whose blanket impl the macro documents. +#[cgp_auto_getter] +pub trait HasProbeField { + /// Reads the field. + fn probe_field(&self) -> &str; +} + +/// A computer, whose provider struct the macro documents. +#[cgp_computer] +pub fn probe_computer(input: u32) -> u32 { + input +} + +/// A producer, whose provider struct the macro documents. +#[cgp_producer] +pub fn probe_producer() -> u32 { + 1 +} + +/// A dispatch trait, whose provider struct the macro documents. +#[cgp_auto_dispatch] +pub trait CanProbeDispatch { + /// Dispatches. + fn dispatch(&self) -> u32; +} + +/// A namespace, whose struct, trait, and associated type the macro documents. +cgp_namespace! { + new ProbeNamespace: DefaultNamespace { + @cgp.core.error.ErrorTypeProviderComponent: UseType, + } +} + +/// A wiring table, whose struct the macro documents. +delegate_components! { + new ProbeTable { + GreeterComponent: GreetHello, + } +} + +/// A record, whose partial builder the derive documents. +#[derive(CgpData)] +pub struct ProbeRecord { + /// A field. + pub field: u32, +} + +/// A variant, whose partial extractor the derive documents. +#[derive(CgpData)] +pub enum ProbeVariant { + /// A variant. + A(u32), +} diff --git a/crates/tests/cgp-tests/src/lib.rs b/crates/tests/cgp-tests/src/lib.rs index 6ffc931be..d74598082 100644 --- a/crates/tests/cgp-tests/src/lib.rs +++ b/crates/tests/cgp-tests/src/lib.rs @@ -2,6 +2,9 @@ //! //! All tests live in the integration targets under `tests/`, organized by CGP //! concept (one target per concept, one file per unit test). This library crate -//! holds only shared support code; today there is none, so it is intentionally -//! empty. See `../README.md` and `../AGENTS.md` for the organization and the +//! holds the one check that needs a library: `generated_docs`, which denies +//! `missing_docs` so a macro that stops documenting a generated item fails the +//! build. See `../README.md` and `../AGENTS.md` for the organization and the //! rules for maintaining the suite. + +pub mod generated_docs; diff --git a/crates/tests/cgp-tests/tests/abstract_types/cgp_type_bounded.rs b/crates/tests/cgp-tests/tests/abstract_types/cgp_type_bounded.rs index d844f55a8..007a8b618 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/cgp_type_bounded.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/cgp_type_bounded.rs @@ -52,6 +52,7 @@ snapshot_cgp_type! { TypesTypeProviderComponent, >>::Delegate as TypesTypeProvider<__Context__>>::Types; } + ///Component marker for [`HasTypes`]. pub struct TypesTypeProviderComponent; impl<__Context__> TypesTypeProvider<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/abstract_types/cgp_type_macro.rs b/crates/tests/cgp-tests/tests/abstract_types/cgp_type_macro.rs index c47c54ec1..e34b8f5c5 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/cgp_type_macro.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/cgp_type_macro.rs @@ -48,6 +48,7 @@ snapshot_cgp_type! { ScalarTypeProviderComponent, >>::Delegate as ScalarTypeProvider<__Context__>>::Scalar; } + ///Component marker for [`HasScalarType`]. pub struct ScalarTypeProviderComponent; impl<__Context__> ScalarTypeProvider<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/abstract_types/cgp_type_self_referential.rs b/crates/tests/cgp-tests/tests/abstract_types/cgp_type_self_referential.rs index 1882c3b48..5a7da0bab 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/cgp_type_self_referential.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/cgp_type_self_referential.rs @@ -50,6 +50,7 @@ snapshot_cgp_type! { ScalarTypeProviderComponent, >>::Delegate as ScalarTypeProvider<__Context__>>::Scalar; } + ///Component marker for [`HasScalarType`]. pub struct ScalarTypeProviderComponent; impl<__Context__> ScalarTypeProvider<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/abstract_types/cgp_type_unsized.rs b/crates/tests/cgp-tests/tests/abstract_types/cgp_type_unsized.rs index b5210ebd3..9584d93d5 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/cgp_type_unsized.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/cgp_type_unsized.rs @@ -50,6 +50,7 @@ snapshot_cgp_type! { ProvideFooTypeComponent, >>::Delegate as ProvideFooType<__Context__, T>>::Foo; } + ///Component marker for [`HasFooType`]. pub struct ProvideFooTypeComponent; impl<__Context__, T: ?Sized> ProvideFooType<__Context__, T> for UseContext where diff --git a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_alias.rs b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_alias.rs index 619378a11..4f997f8b9 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_alias.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_alias.rs @@ -34,7 +34,9 @@ snapshot_cgp_fn! { expand_rectangle_area(output) { insta::assert_snapshot!(output, @" + ///The trait for the `rectangle_area` operation. pub trait RectangleArea: HasScalarType { + ///The `rectangle_area` operation. fn rectangle_area(&self) -> ::Scalar; } impl<__Context__> RectangleArea for __Context__ diff --git a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_deep_foreign.rs b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_deep_foreign.rs index 5efb13f78..1194a0f80 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_deep_foreign.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_deep_foreign.rs @@ -43,11 +43,13 @@ snapshot_cgp_fn! { expand_deep(output) { insta::assert_snapshot!(output, @" + ///The trait for the `deep` operation. pub trait Deep: HasA where ::A: HasB, <::A as HasB>::B: HasC, { + ///The `deep` operation. fn deep(&self) -> <<::A as HasB>::B as HasC>::C; } impl<__Context__> Deep for __Context__ diff --git a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_equality.rs b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_equality.rs index 5edd0dc00..a1ba1bb19 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_equality.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_equality.rs @@ -28,7 +28,9 @@ snapshot_cgp_fn! { expand_rectangle_area(output) { insta::assert_snapshot!(output, @" + ///The trait for the `rectangle_area` operation. pub trait RectangleArea: HasScalarType { + ///The `rectangle_area` operation. fn rectangle_area(&self) -> ::Scalar; } impl<__Context__> RectangleArea for __Context__ diff --git a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_equality_cross_trait.rs b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_equality_cross_trait.rs index cefa72efa..996476952 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_equality_cross_trait.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_equality_cross_trait.rs @@ -36,7 +36,9 @@ snapshot_cgp_fn! { expand_do_foo(output) { insta::assert_snapshot!(output, @" + ///The trait for the `do_foo` operation. pub trait DoFoo: HasFooType { + ///The `do_foo` operation. fn do_foo(&self) -> ::Foo; } impl<__Context__> DoFoo for __Context__ @@ -60,7 +62,9 @@ snapshot_cgp_fn! { expand_do_bar(output) { insta::assert_snapshot!(output, @" + ///The trait for the `do_bar` operation. pub trait DoBar: HasBarType { + ///The `do_bar` operation. fn do_bar(&self) -> ::Bar; } impl<__Context__> DoBar for __Context__ @@ -91,7 +95,9 @@ snapshot_cgp_fn! { expand_return_foo_or_bar(output) { insta::assert_snapshot!(output, @" + ///The trait for the `return_foo_or_bar` operation. trait ReturnFooOrBar: HasBarType + HasFooType { + ///The `return_foo_or_bar` operation. fn return_foo_or_bar(&self, flag: bool) -> ::Foo; } impl<__Context__> ReturnFooOrBar for __Context__ diff --git a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_equality_nested.rs b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_equality_nested.rs index fc76d0428..c9a2df2a6 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_equality_nested.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_equality_nested.rs @@ -41,7 +41,9 @@ snapshot_cgp_fn! { expand_begin_nested(output) { insta::assert_snapshot!(output, @" + ///The trait for the `begin_nested` operation. pub trait BeginNested: HasDbType + HasTransactionType { + ///The `begin_nested` operation. fn begin_nested(&self) -> ::Transaction; } impl<__Context__> BeginNested for __Context__ @@ -70,7 +72,9 @@ snapshot_cgp_fn! { expand_begin_nested_reversed(output) { insta::assert_snapshot!(output, @" + ///The trait for the `begin_nested_reversed` operation. pub trait BeginNestedReversed: HasTransactionType + HasDbType { + ///The `begin_nested_reversed` operation. fn begin_nested_reversed(&self) -> ::Transaction; } impl<__Context__> BeginNestedReversed for __Context__ @@ -95,7 +99,9 @@ snapshot_cgp_fn! { expand_begin_projected(output) { insta::assert_snapshot!(output, @" + ///The trait for the `begin_projected` operation. pub trait BeginProjected: HasDbType + HasTransactionType { + ///The `begin_projected` operation. fn begin_projected(&self) -> ::Transaction; } impl<__Context__> BeginProjected for __Context__ diff --git a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_expr_path.rs b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_expr_path.rs index 3e0244165..acaa27a5e 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_expr_path.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_expr_path.rs @@ -75,7 +75,9 @@ snapshot_cgp_fn! { expand_begin_transaction(output) { insta::assert_snapshot!(output, @" + ///The trait for the `begin_transaction` operation. pub trait BeginTransaction: HasDbType + HasTransactionType { + ///The `begin_transaction` operation. fn begin_transaction(&self) -> ::Transaction; } impl<__Context__> BeginTransaction for __Context__ @@ -115,7 +117,9 @@ snapshot_cgp_fn! { expand_transaction_label(output) { insta::assert_snapshot!(output, @" + ///The trait for the `transaction_label` operation. pub trait TransactionLabel: HasDbType + HasTransactionType { + ///The `transaction_label` operation. fn transaction_label(&self) -> &'static str; } impl<__Context__> TransactionLabel for __Context__ @@ -147,7 +151,9 @@ snapshot_cgp_fn! { expand_tagged_transaction(output) { insta::assert_snapshot!(output, @" + ///The trait for the `tagged_transaction` operation. pub trait TaggedTransaction: HasDbType + HasTransactionType { + ///The `tagged_transaction` operation. fn tagged_transaction(&self) -> ::Transaction; } impl<__Context__> TaggedTransaction for __Context__ @@ -186,7 +192,9 @@ snapshot_cgp_fn! { expand_unit_struct_untouched(output) { insta::assert_snapshot!(output, @" + ///The trait for the `unit_struct_untouched` operation. pub trait UnitStructUntouched: HasDbType { + ///The `unit_struct_untouched` operation. fn unit_struct_untouched(&self) -> Marker2; } impl<__Context__> UnitStructUntouched for __Context__ diff --git a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_extend.rs b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_extend.rs index 424907c4e..ca7d2f4b9 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_extend.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_extend.rs @@ -36,7 +36,9 @@ snapshot_cgp_fn! { expand_rectangle_area(output) { insta::assert_snapshot!(output, @" + ///The trait for the `rectangle_area` operation. pub trait RectangleArea: HasScalarType { + ///The `rectangle_area` operation. fn rectangle_area(&self) -> Self::Scalar; } impl<__Context__> RectangleArea for __Context__ diff --git a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_foreign.rs b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_foreign.rs index 6521b0caf..d2d9d3759 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_foreign.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_foreign.rs @@ -41,10 +41,12 @@ snapshot_cgp_fn! { expand_rectangle_area(output) { insta::assert_snapshot!(output, @" + ///The trait for the `rectangle_area` operation. pub trait RectangleArea where Types: HasScalarType, { + ///The `rectangle_area` operation. fn rectangle_area(&self) -> ::Scalar; } impl<__Context__, Types> RectangleArea for __Context__ diff --git a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_foreign_equality.rs b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_foreign_equality.rs index 6904533e1..bc0cac2f4 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_foreign_equality.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_foreign_equality.rs @@ -38,10 +38,12 @@ snapshot_cgp_fn! { expand_rectangle_area(output) { insta::assert_snapshot!(output, @" + ///The trait for the `rectangle_area` operation. pub trait RectangleArea: HasTypes where ::Types: HasScalarType, { + ///The `rectangle_area` operation. fn rectangle_area(&self) -> <::Types as HasScalarType>::Scalar; } impl<__Context__> RectangleArea for __Context__ diff --git a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_foreign_equality_cross_trait.rs b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_foreign_equality_cross_trait.rs index fb8bad05a..9487a1783 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_foreign_equality_cross_trait.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_foreign_equality_cross_trait.rs @@ -33,7 +33,9 @@ snapshot_cgp_fn! { expand_do_foo(output) { insta::assert_snapshot!(output, @" + ///The trait for the `do_foo` operation. pub trait DoFoo: HasFooType { + ///The `do_foo` operation. fn do_foo(&self) -> ::Foo; } impl<__Context__> DoFoo for __Context__ @@ -57,10 +59,12 @@ snapshot_cgp_fn! { expand_do_bar(output) { insta::assert_snapshot!(output, @" + ///The trait for the `do_bar` operation. pub trait DoBar: HasBarType where ::Bar: HasFooType, { + ///The `do_bar` operation. fn do_bar(&self) -> <::Bar as HasFooType>::Foo; } impl<__Context__> DoBar for __Context__ @@ -96,10 +100,12 @@ snapshot_cgp_fn! { expand_return_foo_or_bar(output) { insta::assert_snapshot!(output, @" + ///The trait for the `return_foo_or_bar` operation. trait ReturnFooOrBar: HasFooType + HasBarType where ::Bar: HasFooType, { + ///The `return_foo_or_bar` operation. fn return_foo_or_bar(&self, flag: bool) -> ::Foo; } impl<__Context__> ReturnFooOrBar for __Context__ diff --git a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_generic_trait_equality.rs b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_generic_trait_equality.rs index c34a09556..d2ed62038 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_generic_trait_equality.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_generic_trait_equality.rs @@ -36,7 +36,9 @@ snapshot_cgp_fn! { expand_get_foo(output) { insta::assert_snapshot!(output, @" + ///The trait for the `get_foo` operation. pub trait GetFoo: HasFooType { + ///The `get_foo` operation. fn get_foo(&self) -> >::Foo; } impl<__Context__> GetFoo for __Context__ @@ -60,7 +62,9 @@ snapshot_cgp_fn! { expand_get_pair(output) { insta::assert_snapshot!(output, @" + ///The trait for the `get_pair` operation. pub trait GetPair: HasPairType + HasFooType { + ///The `get_pair` operation. fn get_pair( &self, ) -> ( @@ -105,7 +109,9 @@ snapshot_cgp_fn! { expand_get_ref(output) { insta::assert_snapshot!(output, @" + ///The trait for the `get_ref` operation. pub trait GetRef<'a>: HasRefType<'a> { + ///The `get_ref` operation. fn get_ref(&self) -> >::Ref; } impl<'a, __Context__> GetRef<'a> for __Context__ diff --git a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_nested_foreign.rs b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_nested_foreign.rs index fbdaecf6a..70fef4870 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_nested_foreign.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_nested_foreign.rs @@ -45,11 +45,13 @@ snapshot_cgp_fn! { expand_rectangle_area(output) { insta::assert_snapshot!(output, @" + ///The trait for the `rectangle_area` operation. pub trait RectangleArea: HasTypes where <::Types as HasScalarType>::Scalar: Copy, ::Types: HasScalarType, { + ///The `rectangle_area` operation. fn rectangle_area(&self) -> <::Types as HasScalarType>::Scalar; } impl<__Context__> RectangleArea for __Context__ diff --git a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_stacked_attributes.rs b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_stacked_attributes.rs index 73b559c82..f4735d20c 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_stacked_attributes.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_stacked_attributes.rs @@ -38,7 +38,9 @@ snapshot_cgp_fn! { expand_get_foo(output) { insta::assert_snapshot!(output, @" + ///The trait for the `get_foo` operation. pub trait GetFoo: HasFooType + HasBarType { + ///The `get_foo` operation. fn get_foo(&self) -> ::Foo; } impl<__Context__> GetFoo for __Context__ @@ -65,7 +67,9 @@ snapshot_cgp_fn! { expand_get_foo_reversed(output) { insta::assert_snapshot!(output, @" + ///The trait for the `get_foo_reversed` operation. pub trait GetFooReversed: HasBarType + HasFooType { + ///The `get_foo_reversed` operation. fn get_foo_reversed(&self) -> ::Foo; } impl<__Context__> GetFooReversed for __Context__ diff --git a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_trait_arg_alias.rs b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_trait_arg_alias.rs index 1e7eeca4b..5a2a6d79e 100644 --- a/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_trait_arg_alias.rs +++ b/crates/tests/cgp-tests/tests/abstract_types/use_type_fn_trait_arg_alias.rs @@ -37,7 +37,9 @@ snapshot_cgp_fn! { expand_get_pool(output) { insta::assert_snapshot!(output, @" + ///The trait for the `get_pool` operation. pub trait GetPool: HasDbType + HasPoolType<::Db> { + ///The `get_pool` operation. fn get_pool(&self) -> ::Db>>::Pool; } impl<__Context__> GetPool for __Context__ @@ -62,7 +64,9 @@ snapshot_cgp_fn! { expand_get_pinned_pool(output) { insta::assert_snapshot!(output, @" + ///The trait for the `get_pinned_pool` operation. pub trait GetPinnedPool: HasDbType + HasPoolType<::Db> { + ///The `get_pinned_pool` operation. fn get_pinned_pool(&self) -> ::Db>>::Pool; } impl<__Context__> GetPinnedPool for __Context__ @@ -96,9 +100,11 @@ snapshot_cgp_fn! { expand_get_handle(output) { insta::assert_snapshot!(output, @" + ///The trait for the `get_handle` operation. pub trait GetHandle: HasDbType + HasPoolType< ::Db, > + HasHandleType<::Db>>::Pool> { + ///The `get_handle` operation. fn get_handle( &self, ) -> String; } #[async_trait] diff --git a/crates/tests/cgp-tests/tests/async_and_send/component_async.rs b/crates/tests/cgp-tests/tests/async_and_send/component_async.rs index e134a50c5..47166db76 100644 --- a/crates/tests/cgp-tests/tests/async_and_send/component_async.rs +++ b/crates/tests/cgp-tests/tests/async_and_send/component_async.rs @@ -53,6 +53,7 @@ snapshot_cgp_component! { .await } } + ///Component marker for [`CanFetch`]. pub struct FetcherComponent; #[async_trait] impl<__Context__> Fetcher<__Context__> for UseContext diff --git a/crates/tests/cgp-tests/tests/auto_dispatch/async_self_ref_only.rs b/crates/tests/cgp-tests/tests/auto_dispatch/async_self_ref_only.rs index 0bdd76761..49d6e8f19 100644 --- a/crates/tests/cgp-tests/tests/auto_dispatch/async_self_ref_only.rs +++ b/crates/tests/cgp-tests/tests/auto_dispatch/async_self_ref_only.rs @@ -68,6 +68,7 @@ snapshot_cgp_auto_dispatch! { __Code__, > IsProviderFor for ComputeCall {} + ///Provider `ComputeCall` for [`AsyncComputer`]. pub struct ComputeCall; impl DelegateComponent for ComputeCall where diff --git a/crates/tests/cgp-tests/tests/auto_dispatch/elided_lifetimes.rs b/crates/tests/cgp-tests/tests/auto_dispatch/elided_lifetimes.rs index d0b5bb5a0..e142f08de 100644 --- a/crates/tests/cgp-tests/tests/auto_dispatch/elided_lifetimes.rs +++ b/crates/tests/cgp-tests/tests/auto_dispatch/elided_lifetimes.rs @@ -94,6 +94,7 @@ snapshot_cgp_auto_dispatch! { __Context__, (__Code__, (&'__a__ __Variants__, (&'__a1__ str))), > for ComputeLabel {} + ///Provider `ComputeLabel` for [`Computer`]. pub struct ComputeLabel; impl DelegateComponent for ComputeLabel where diff --git a/crates/tests/cgp-tests/tests/auto_dispatch/generics.rs b/crates/tests/cgp-tests/tests/auto_dispatch/generics.rs index 19c79d63a..360475143 100644 --- a/crates/tests/cgp-tests/tests/auto_dispatch/generics.rs +++ b/crates/tests/cgp-tests/tests/auto_dispatch/generics.rs @@ -99,6 +99,7 @@ snapshot_cgp_auto_dispatch! { __Context__, (__Code__, (&'__a__ __Variants__, (u64, &'__a1__ T))), > for ComputeCallA {} + ///Provider `ComputeCallA` for [`Computer`]. pub struct ComputeCallA; impl DelegateComponent for ComputeCallA where @@ -274,6 +275,7 @@ snapshot_cgp_auto_dispatch! { __Context__, (__Code__, (__Variants__, (u64, &'__a1__ mut T))), > for ComputeCallB {} + ///Provider `ComputeCallB` for [`Computer`]. pub struct ComputeCallB; impl DelegateComponent for ComputeCallB where diff --git a/crates/tests/cgp-tests/tests/auto_dispatch/multi_args_ref.rs b/crates/tests/cgp-tests/tests/auto_dispatch/multi_args_ref.rs index 1cc312536..979198054 100644 --- a/crates/tests/cgp-tests/tests/auto_dispatch/multi_args_ref.rs +++ b/crates/tests/cgp-tests/tests/auto_dispatch/multi_args_ref.rs @@ -73,6 +73,7 @@ snapshot_cgp_auto_dispatch! { __Context__, (__Code__, (&'a mut __Variants__, (&'a u64, bool))), > for ComputeCall {} + ///Provider `ComputeCall` for [`Computer`]. pub struct ComputeCall; impl DelegateComponent for ComputeCall where diff --git a/crates/tests/cgp-tests/tests/auto_dispatch/raw_method_name.rs b/crates/tests/cgp-tests/tests/auto_dispatch/raw_method_name.rs index 95d254afe..99b6d2905 100644 --- a/crates/tests/cgp-tests/tests/auto_dispatch/raw_method_name.rs +++ b/crates/tests/cgp-tests/tests/auto_dispatch/raw_method_name.rs @@ -68,6 +68,7 @@ snapshot_cgp_auto_dispatch! { __Code__, > IsProviderFor for ComputeType {} + ///Provider `ComputeType` for [`Computer`]. pub struct ComputeType; impl DelegateComponent for ComputeType where diff --git a/crates/tests/cgp-tests/tests/auto_dispatch/self_mut_only.rs b/crates/tests/cgp-tests/tests/auto_dispatch/self_mut_only.rs index 8a582762e..32e6f973b 100644 --- a/crates/tests/cgp-tests/tests/auto_dispatch/self_mut_only.rs +++ b/crates/tests/cgp-tests/tests/auto_dispatch/self_mut_only.rs @@ -61,6 +61,7 @@ snapshot_cgp_auto_dispatch! { __Code__, > IsProviderFor for ComputeCall {} + ///Provider `ComputeCall` for [`Computer`]. pub struct ComputeCall; impl DelegateComponent for ComputeCall where diff --git a/crates/tests/cgp-tests/tests/auto_dispatch/self_only.rs b/crates/tests/cgp-tests/tests/auto_dispatch/self_only.rs index 3fb2a39c1..af7821649 100644 --- a/crates/tests/cgp-tests/tests/auto_dispatch/self_only.rs +++ b/crates/tests/cgp-tests/tests/auto_dispatch/self_only.rs @@ -57,6 +57,7 @@ snapshot_cgp_auto_dispatch! { __Code__, > IsProviderFor for ComputeCall {} + ///Provider `ComputeCall` for [`Computer`]. pub struct ComputeCall; impl DelegateComponent for ComputeCall where diff --git a/crates/tests/cgp-tests/tests/auto_dispatch/self_ref_only.rs b/crates/tests/cgp-tests/tests/auto_dispatch/self_ref_only.rs index 1c793f850..fb560e1a3 100644 --- a/crates/tests/cgp-tests/tests/auto_dispatch/self_ref_only.rs +++ b/crates/tests/cgp-tests/tests/auto_dispatch/self_ref_only.rs @@ -61,6 +61,7 @@ snapshot_cgp_auto_dispatch! { __Code__, > IsProviderFor for ComputeCall {} + ///Provider `ComputeCall` for [`Computer`]. pub struct ComputeCall; impl DelegateComponent for ComputeCall where diff --git a/crates/tests/cgp-tests/tests/auto_dispatch/self_ref_return_explicit_ref.rs b/crates/tests/cgp-tests/tests/auto_dispatch/self_ref_return_explicit_ref.rs index e560e6b89..847cfbd3a 100644 --- a/crates/tests/cgp-tests/tests/auto_dispatch/self_ref_return_explicit_ref.rs +++ b/crates/tests/cgp-tests/tests/auto_dispatch/self_ref_return_explicit_ref.rs @@ -62,6 +62,7 @@ snapshot_cgp_auto_dispatch! { __Code__, > IsProviderFor for ComputeCall {} + ///Provider `ComputeCall` for [`Computer`]. pub struct ComputeCall; impl DelegateComponent for ComputeCall where diff --git a/crates/tests/cgp-tests/tests/auto_dispatch/supertrait.rs b/crates/tests/cgp-tests/tests/auto_dispatch/supertrait.rs index baad14c1b..a54703486 100644 --- a/crates/tests/cgp-tests/tests/auto_dispatch/supertrait.rs +++ b/crates/tests/cgp-tests/tests/auto_dispatch/supertrait.rs @@ -77,6 +77,7 @@ snapshot_cgp_auto_dispatch! { __Code__, > IsProviderFor for ComputeGreet {} + ///Provider `ComputeGreet` for [`Computer`]. pub struct ComputeGreet; impl DelegateComponent for ComputeGreet where diff --git a/crates/tests/cgp-tests/tests/basic_delegation/component_assoc_const.rs b/crates/tests/cgp-tests/tests/basic_delegation/component_assoc_const.rs index 6c76f8288..6c831eb78 100644 --- a/crates/tests/cgp-tests/tests/basic_delegation/component_assoc_const.rs +++ b/crates/tests/cgp-tests/tests/basic_delegation/component_assoc_const.rs @@ -57,6 +57,7 @@ snapshot_cgp_component! { >>::Delegate::limit(__context__) } } + ///Component marker for [`HasLimit`]. pub struct LimitProviderComponent; impl<__Context__> LimitProvider<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/basic_delegation/component_macro.rs b/crates/tests/cgp-tests/tests/basic_delegation/component_macro.rs index 9d3f81a0f..e5f0ea928 100644 --- a/crates/tests/cgp-tests/tests/basic_delegation/component_macro.rs +++ b/crates/tests/cgp-tests/tests/basic_delegation/component_macro.rs @@ -51,6 +51,7 @@ snapshot_cgp_component! { >>::Delegate::foo(__context__, value) } } + ///Component marker for [`CanDoFoo`]. pub struct FooProviderComponent; impl<__Context__> FooProvider<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/basic_delegation/default_methods.rs b/crates/tests/cgp-tests/tests/basic_delegation/default_methods.rs index ab78005ee..4901b18af 100644 --- a/crates/tests/cgp-tests/tests/basic_delegation/default_methods.rs +++ b/crates/tests/cgp-tests/tests/basic_delegation/default_methods.rs @@ -67,6 +67,7 @@ snapshot_cgp_component! { >>::Delegate::greet(__context__) } } + ///Component marker for [`CanGreet`]. pub struct GreeterComponent; impl<__Context__> Greeter<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/basic_delegation/delegate_components_macro.rs b/crates/tests/cgp-tests/tests/basic_delegation/delegate_components_macro.rs index d3917dd87..6eada7eb6 100644 --- a/crates/tests/cgp-tests/tests/basic_delegation/delegate_components_macro.rs +++ b/crates/tests/cgp-tests/tests/basic_delegation/delegate_components_macro.rs @@ -21,6 +21,7 @@ snapshot_delegate_components! { expand_foo_component(output) { insta::assert_snapshot!(output, @" + ///Wiring table `FooComponents`. pub struct FooComponents; impl DelegateComponent> for FooComponents { type Delegate = u64; @@ -56,6 +57,7 @@ snapshot_delegate_components! { expand_bar_component(output) { insta::assert_snapshot!(output, @" + ///Wiring table `BarComponents`. pub struct BarComponents; impl DelegateComponent> for BarComponents { type Delegate = FooComponents; diff --git a/crates/tests/cgp-tests/tests/basic_delegation/doc_comment_on_cgp_component.rs b/crates/tests/cgp-tests/tests/basic_delegation/doc_comment_on_cgp_component.rs new file mode 100644 index 000000000..9c697389c --- /dev/null +++ b/crates/tests/cgp-tests/tests/basic_delegation/doc_comment_on_cgp_component.rs @@ -0,0 +1,102 @@ +//! Where a user's doc comment lands on a `#[cgp_component]`. +//! +//! The consumer trait's doc is copied onto every item the macro derives, so the +//! provider trait and the blanket impls carry it too, and the marker struct +//! carries a generated line naming the consumer trait. The two never meet on one +//! item: the marker struct has only the generated line, and the derived items have +//! only the user's doc. +//! +//! See cgp-knowledge-base/cgp/implementation/README.md#doc-comments-on-generated-items. + +// The doc comment inside the invocation is consumed by the macro, which emits it +// on the generated items, so rustdoc never sees it here. +#![allow(unused_doc_comments)] + +use cgp_macro_test_util::snapshot_cgp_component; + +snapshot_cgp_component! { + #[cgp_component(Greeter)] + /// The user's doc for the consumer trait. + pub trait CanGreet { + /// The user's doc for the method. + fn greet(&self) -> String; + } + + expand_can_greet(output) { + insta::assert_snapshot!(output, @" + /// The user's doc for the consumer trait. + pub trait CanGreet { + /// The user's doc for the method. + fn greet(&self) -> String; + } + /// The user's doc for the consumer trait. + impl<__Context__> CanGreet for __Context__ + where + __Context__: Greeter<__Context__>, + { + fn greet(&self) -> String { + __Context__::greet(self) + } + } + /// The user's doc for the consumer trait. + pub trait Greeter<__Context__>: IsProviderFor { + /// The user's doc for the method. + fn greet(__context__: &__Context__) -> String; + } + /// The user's doc for the consumer trait. + impl<__Provider__, __Context__> Greeter<__Context__> for __Provider__ + where + __Provider__: DelegateComponent + + IsProviderFor, + <__Provider__ as DelegateComponent< + GreeterComponent, + >>::Delegate: Greeter<__Context__>, + { + fn greet(__context__: &__Context__) -> String { + <__Provider__ as DelegateComponent< + GreeterComponent, + >>::Delegate::greet(__context__) + } + } + ///Component marker for [`CanGreet`]. + pub struct GreeterComponent; + /// The user's doc for the consumer trait. + impl<__Context__> Greeter<__Context__> for UseContext + where + __Context__: CanGreet, + { + fn greet(__context__: &__Context__) -> String { + __Context__::greet(__context__) + } + } + impl<__Context__> IsProviderFor for UseContext + where + __Context__: CanGreet, + {} + /// The user's doc for the consumer trait. + impl<__Context__, __Components__, __Path__> Greeter<__Context__> + for RedirectLookup<__Components__, __Path__> + where + __Components__: DelegateComponent<__Path__>, + <__Components__ as DelegateComponent<__Path__>>::Delegate: Greeter<__Context__>, + { + fn greet(__context__: &__Context__) -> String { + <__Components__ as DelegateComponent<__Path__>>::Delegate::greet(__context__) + } + } + impl< + __Context__, + __Components__, + __Path__, + > IsProviderFor + for RedirectLookup<__Components__, __Path__> + where + __Components__: DelegateComponent<__Path__>, + <__Components__ as DelegateComponent< + __Path__, + >>::Delegate: IsProviderFor + + Greeter<__Context__>, + {} + ") + } +} diff --git a/crates/tests/cgp-tests/tests/basic_delegation/mod.rs b/crates/tests/cgp-tests/tests/basic_delegation/mod.rs index 619ee48eb..4f29d51db 100644 --- a/crates/tests/cgp-tests/tests/basic_delegation/mod.rs +++ b/crates/tests/cgp-tests/tests/basic_delegation/mod.rs @@ -31,3 +31,7 @@ pub mod delegate_nested_use_delegate; pub mod delegate_new_array_key; pub mod delegate_new_generic_struct; pub mod delegate_new_struct; + +// Where a user's doc comment lands: copied onto the derived items, with a generated +// line on the marker struct. +pub mod doc_comment_on_cgp_component; diff --git a/crates/tests/cgp-tests/tests/basic_delegation/provider_component_override.rs b/crates/tests/cgp-tests/tests/basic_delegation/provider_component_override.rs index 29f3f2937..64db8fcb0 100644 --- a/crates/tests/cgp-tests/tests/basic_delegation/provider_component_override.rs +++ b/crates/tests/cgp-tests/tests/basic_delegation/provider_component_override.rs @@ -37,6 +37,7 @@ snapshot_cgp_impl! { } } impl<__Context__> IsProviderFor for FortyTwo {} + ///Provider `FortyTwo` for [`FooProvider`]. pub struct FortyTwo; ") } diff --git a/crates/tests/cgp-tests/tests/basic_delegation/provider_macro.rs b/crates/tests/cgp-tests/tests/basic_delegation/provider_macro.rs index f480cdff8..716e407df 100644 --- a/crates/tests/cgp-tests/tests/basic_delegation/provider_macro.rs +++ b/crates/tests/cgp-tests/tests/basic_delegation/provider_macro.rs @@ -33,6 +33,7 @@ snapshot_cgp_impl! { } } impl IsProviderFor for ValueToString {} + ///Provider `ValueToString` for [`FooProvider`]. pub struct ValueToString; ") } diff --git a/crates/tests/cgp-tests/tests/basic_delegation/self_local_assoc_const.rs b/crates/tests/cgp-tests/tests/basic_delegation/self_local_assoc_const.rs index 376d53ace..606b30a17 100644 --- a/crates/tests/cgp-tests/tests/basic_delegation/self_local_assoc_const.rs +++ b/crates/tests/cgp-tests/tests/basic_delegation/self_local_assoc_const.rs @@ -55,6 +55,7 @@ snapshot_cgp_impl! { } impl<__Context__> IsProviderFor for AllowUnderLimit {} + ///Provider `AllowUnderLimit` for [`RateLimiter`]. pub struct AllowUnderLimit; ") } diff --git a/crates/tests/cgp-tests/tests/dispatching/const_generic_tables.rs b/crates/tests/cgp-tests/tests/dispatching/const_generic_tables.rs index f91dd8a8a..333e84db0 100644 --- a/crates/tests/cgp-tests/tests/dispatching/const_generic_tables.rs +++ b/crates/tests/cgp-tests/tests/dispatching/const_generic_tables.rs @@ -31,6 +31,7 @@ snapshot_delegate_components! { } expand_constant_table(output) { insta::assert_snapshot!(output, @" + ///Wiring table `ConstantTable`. pub struct ConstantTable(pub ::core::marker::PhantomData<()>); impl DelegateComponent for ConstantTable { type Delegate = UseConstant; @@ -89,6 +90,7 @@ snapshot_delegate_components! { } expand_count_table(output) { insta::assert_snapshot!(output, @" + ///Wiring table `CountTable`. pub struct CountTable(pub ::core::marker::PhantomData<()>); impl DelegateComponent for Wrapper { type Delegate = UseDelegate>; diff --git a/crates/tests/cgp-tests/tests/dispatching/use_delegate_getter.rs b/crates/tests/cgp-tests/tests/dispatching/use_delegate_getter.rs index 6a2d342e2..38ef7919e 100644 --- a/crates/tests/cgp-tests/tests/dispatching/use_delegate_getter.rs +++ b/crates/tests/cgp-tests/tests/dispatching/use_delegate_getter.rs @@ -60,6 +60,7 @@ snapshot_cgp_type! { FooTypeProviderAtComponent, >>::Delegate as FooTypeProviderAt<__Context__, I, J>>::Foo; } + ///Component marker for [`HasFooTypeAt`]. pub struct FooTypeProviderAtComponent; impl<__Context__, I, J> FooTypeProviderAt<__Context__, I, J> for UseContext where @@ -238,6 +239,7 @@ snapshot_cgp_getter! { >>::Delegate::foo_at(__context__, _tag) } } + ///Component marker for [`HasFooAt`]. pub struct FooGetterAtComponent; impl<__Context__, I, J> FooGetterAt<__Context__, I, J> for UseContext where @@ -495,7 +497,9 @@ mod derive_delegate { expand_my_context(output) { insta::assert_snapshot!(output, @r#" + ///Wiring table `FooTypes`. pub struct FooTypes; + ///Wiring table `FooGetters`. pub struct FooGetters; impl DelegateComponent for MyContext { type Delegate = UseDelegate; @@ -621,7 +625,9 @@ mod derive_delegate2 { expand_my_context(output) { insta::assert_snapshot!(output, @r#" + ///Wiring table `FooTypes`. pub struct FooTypes; + ///Wiring table `FooGetters`. pub struct FooGetters; impl DelegateComponent for MyContext { type Delegate = UseDelegate2; diff --git a/crates/tests/cgp-tests/tests/extensible_records/build_field_derive.rs b/crates/tests/cgp-tests/tests/extensible_records/build_field_derive.rs index 06caa5cbf..5e34ae6f9 100644 --- a/crates/tests/cgp-tests/tests/extensible_records/build_field_derive.rs +++ b/crates/tests/cgp-tests/tests/extensible_records/build_field_derive.rs @@ -35,6 +35,7 @@ snapshot_derive_build_field! { expand_person(output) { insta::assert_snapshot!(output, @" + ///The partial builder for [`Person`]. pub struct __PartialPerson<__F0__: MapType, __F1__: MapType> { pub first_name: <__F0__ as MapType>::Map, pub last_name: <__F1__ as MapType>::Map, diff --git a/crates/tests/cgp-tests/tests/extensible_records/generic_record.rs b/crates/tests/cgp-tests/tests/extensible_records/generic_record.rs index 25c180366..8fd520c07 100644 --- a/crates/tests/cgp-tests/tests/extensible_records/generic_record.rs +++ b/crates/tests/cgp-tests/tests/extensible_records/generic_record.rs @@ -169,6 +169,7 @@ snapshot_derive_cgp_data! { Cons((&self.foo).into(), Cons((&self.bar).into(), Cons((&self.baz).into(), Nil))) } } + ///The partial builder for [`Context`]. pub struct __PartialContext< Foo, Bar, diff --git a/crates/tests/cgp-tests/tests/extensible_records/optional_builder.rs b/crates/tests/cgp-tests/tests/extensible_records/optional_builder.rs index 2a29d7782..be735b212 100644 --- a/crates/tests/cgp-tests/tests/extensible_records/optional_builder.rs +++ b/crates/tests/cgp-tests/tests/extensible_records/optional_builder.rs @@ -106,6 +106,7 @@ snapshot_derive_cgp_data! { Cons((&self.foo).into(), Cons((&self.bar).into(), Nil)) } } + ///The partial builder for [`Context`]. pub struct __PartialContext<__F0__: MapType, __F1__: MapType> { pub foo: <__F0__ as MapType>::Map, pub bar: <__F1__ as MapType>::Map, diff --git a/crates/tests/cgp-tests/tests/extensible_records/person_record.rs b/crates/tests/cgp-tests/tests/extensible_records/person_record.rs index abd7dd36c..dd19a37b8 100644 --- a/crates/tests/cgp-tests/tests/extensible_records/person_record.rs +++ b/crates/tests/cgp-tests/tests/extensible_records/person_record.rs @@ -362,6 +362,7 @@ snapshot_derive_cgp_data! { Cons((&self.first_name).into(), Cons((&self.last_name).into(), Nil)) } } + ///The partial builder for [`Person`]. pub struct __PartialPerson<__F0__: MapType, __F1__: MapType> { pub first_name: <__F0__ as MapType>::Map, pub last_name: <__F1__ as MapType>::Map, diff --git a/crates/tests/cgp-tests/tests/extensible_records/point_cast.rs b/crates/tests/cgp-tests/tests/extensible_records/point_cast.rs index 9b031d6f7..d23215161 100644 --- a/crates/tests/cgp-tests/tests/extensible_records/point_cast.rs +++ b/crates/tests/cgp-tests/tests/extensible_records/point_cast.rs @@ -89,6 +89,7 @@ snapshot_derive_cgp_data! { Cons((&self.x).into(), Cons((&self.y).into(), Nil)) } } + ///The partial builder for [`Point2d`]. struct __PartialPoint2d<__F0__: MapType, __F1__: MapType> { x: <__F0__ as MapType>::Map, y: <__F1__ as MapType>::Map, diff --git a/crates/tests/cgp-tests/tests/extensible_records/record_derive.rs b/crates/tests/cgp-tests/tests/extensible_records/record_derive.rs index 1acc55d65..80a5b39ec 100644 --- a/crates/tests/cgp-tests/tests/extensible_records/record_derive.rs +++ b/crates/tests/cgp-tests/tests/extensible_records/record_derive.rs @@ -138,6 +138,7 @@ snapshot_derive_cgp_data! { Cons((&self.foo).into(), Cons((&self.bar).into(), Cons((&self.baz).into(), Nil))) } } + ///The partial builder for [`FooBarBaz`]. pub struct __PartialFooBarBaz<__F0__: MapType, __F1__: MapType, __F2__: MapType> { pub foo: <__F0__ as MapType>::Map, pub bar: <__F1__ as MapType>::Map, diff --git a/crates/tests/cgp-tests/tests/extensible_records/record_empty.rs b/crates/tests/cgp-tests/tests/extensible_records/record_empty.rs index f1ff6dd4b..259e82da8 100644 --- a/crates/tests/cgp-tests/tests/extensible_records/record_empty.rs +++ b/crates/tests/cgp-tests/tests/extensible_records/record_empty.rs @@ -48,6 +48,7 @@ snapshot_derive_cgp_data! { Nil } } + ///The partial builder for [`NoConfig`]. pub struct __PartialNoConfig {} impl HasBuilder for NoConfig { type Builder = __PartialNoConfig; diff --git a/crates/tests/cgp-tests/tests/extensible_records/tuple_record.rs b/crates/tests/cgp-tests/tests/extensible_records/tuple_record.rs index 52a455773..53c322da6 100644 --- a/crates/tests/cgp-tests/tests/extensible_records/tuple_record.rs +++ b/crates/tests/cgp-tests/tests/extensible_records/tuple_record.rs @@ -91,6 +91,7 @@ snapshot_derive_cgp_data! { Cons((&self.0).into(), Cons((&self.1).into(), Cons((&self.2).into(), Nil))) } } + ///The partial builder for [`Context`]. pub struct __PartialContext<__F0__: MapType, __F1__: MapType, __F2__: MapType>( pub <__F0__ as MapType>::Map, pub <__F1__ as MapType>::Map, diff --git a/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data.rs b/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data.rs index 57f66eb8c..ec841846c 100644 --- a/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data.rs +++ b/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data.rs @@ -141,11 +141,13 @@ snapshot_derive_cgp_data! { Self::Baz(value) } } + ///The partial extractor for [`FooBarBaz`]. pub enum __PartialFooBarBaz<__F0__: MapType, __F1__: MapType, __F2__: MapType> { Foo(<__F0__ as MapType>::Map), Bar(<__F1__ as MapType>::Map), Baz(<__F2__ as MapType>::Map), } + ///The borrowed partial extractor for [`FooBarBaz`]. pub enum __PartialRefFooBarBaz< '__a__, __R__: MapTypeRef, diff --git a/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data_empty.rs b/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data_empty.rs index 6aef481c0..c6a83934f 100644 --- a/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data_empty.rs +++ b/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data_empty.rs @@ -46,7 +46,9 @@ snapshot_derive_cgp_data! { match *self {} } } + ///The partial extractor for [`Never`]. pub enum __PartialNever {} + ///The borrowed partial extractor for [`Never`]. pub enum __PartialRefNever {} impl PartialData for __PartialNever { type Target = Never; diff --git a/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data_empty_variants.rs b/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data_empty_variants.rs index 482f16101..07c28e3c8 100644 --- a/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data_empty_variants.rs +++ b/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data_empty_variants.rs @@ -363,6 +363,7 @@ snapshot_derive_cgp_data! { Self::Archived {} } } + ///The partial extractor for [`Status`]. pub enum __PartialStatus< __F0__: MapType, __F1__: MapType, @@ -374,6 +375,7 @@ snapshot_derive_cgp_data! { Paused(<__F2__ as MapType>::Map), Archived(<__F3__ as MapType>::Map), } + ///The borrowed partial extractor for [`Status`]. pub enum __PartialRefStatus< '__a__, __R__: MapTypeRef, diff --git a/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data_generic.rs b/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data_generic.rs index 0578f3523..c669f5b8d 100644 --- a/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data_generic.rs +++ b/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data_generic.rs @@ -139,6 +139,7 @@ snapshot_derive_cgp_data! { Self::Baz(value) } } + ///The partial extractor for [`FooBarBazGeneric`]. pub enum __PartialFooBarBazGeneric< Foo, Bar, @@ -151,6 +152,7 @@ snapshot_derive_cgp_data! { Bar(<__F1__ as MapType>::Map), Baz(<__F2__ as MapType>::Map), } + ///The borrowed partial extractor for [`FooBarBazGeneric`]. pub enum __PartialRefFooBarBazGeneric< '__a__, __R__: MapTypeRef, diff --git a/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data_shape.rs b/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data_shape.rs index 0e9ecad53..2a6fc8505 100644 --- a/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data_shape.rs +++ b/crates/tests/cgp-tests/tests/extensible_variants/derive_cgp_data_shape.rs @@ -244,10 +244,12 @@ snapshot_derive_cgp_data! { Self::Rectangle(value) } } + ///The partial extractor for [`Shape`]. pub enum __PartialShape<__F0__: MapType, __F1__: MapType> { Circle(<__F0__ as MapType>::Map), Rectangle(<__F1__ as MapType>::Map), } + ///The borrowed partial extractor for [`Shape`]. pub enum __PartialRefShape<'__a__, __R__: MapTypeRef, __F0__: MapType, __F1__: MapType> { Circle(<__F0__ as MapType>::Map<<__R__ as MapTypeRef>::Map<'__a__, Circle>>), Rectangle(<__F1__ as MapType>::Map<<__R__ as MapTypeRef>::Map<'__a__, Rectangle>>), diff --git a/crates/tests/cgp-tests/tests/extensible_variants/extract_field_derive.rs b/crates/tests/cgp-tests/tests/extensible_variants/extract_field_derive.rs index 00191f3d9..aa90035d5 100644 --- a/crates/tests/cgp-tests/tests/extensible_variants/extract_field_derive.rs +++ b/crates/tests/cgp-tests/tests/extensible_variants/extract_field_derive.rs @@ -45,10 +45,12 @@ snapshot_derive_extract_field! { expand_shape(output) { insta::assert_snapshot!(output, @" + ///The partial extractor for [`Shape`]. pub enum __PartialShape<__F0__: MapType, __F1__: MapType> { Circle(<__F0__ as MapType>::Map), Rectangle(<__F1__ as MapType>::Map), } + ///The borrowed partial extractor for [`Shape`]. pub enum __PartialRefShape<'__a__, __R__: MapTypeRef, __F0__: MapType, __F1__: MapType> { Circle(<__F0__ as MapType>::Map<<__R__ as MapTypeRef>::Map<'__a__, Circle>>), Rectangle(<__F1__ as MapType>::Map<<__R__ as MapTypeRef>::Map<'__a__, Rectangle>>), diff --git a/crates/tests/cgp-tests/tests/generic_components/component_lifetime.rs b/crates/tests/cgp-tests/tests/generic_components/component_lifetime.rs index f5ca71ab6..2bd95dadb 100644 --- a/crates/tests/cgp-tests/tests/generic_components/component_lifetime.rs +++ b/crates/tests/cgp-tests/tests/generic_components/component_lifetime.rs @@ -58,6 +58,7 @@ snapshot_cgp_component! { >>::Delegate::get_reference(__context__) } } + ///Component marker for [`HasReference`]. pub struct ReferenceGetterComponent; impl<'a, __Context__, T: 'a + ?Sized> ReferenceGetter<'a, __Context__, T> for UseContext where diff --git a/crates/tests/cgp-tests/tests/generic_components/component_type_param.rs b/crates/tests/cgp-tests/tests/generic_components/component_type_param.rs index 33cf69454..ff4a3c0f5 100644 --- a/crates/tests/cgp-tests/tests/generic_components/component_type_param.rs +++ b/crates/tests/cgp-tests/tests/generic_components/component_type_param.rs @@ -55,6 +55,7 @@ snapshot_cgp_component! { >>::Delegate::calculate_area(__context__, shape) } } + ///Component marker for [`CanCalculateArea`]. pub struct AreaCalculatorComponent; impl<__Context__, Shape> AreaCalculator<__Context__, Shape> for UseContext where diff --git a/crates/tests/cgp-tests/tests/generic_components/fn_generic_param.rs b/crates/tests/cgp-tests/tests/generic_components/fn_generic_param.rs index 9d058c709..35ed0cfa8 100644 --- a/crates/tests/cgp-tests/tests/generic_components/fn_generic_param.rs +++ b/crates/tests/cgp-tests/tests/generic_components/fn_generic_param.rs @@ -27,7 +27,9 @@ snapshot_cgp_fn! { expand_rectangle_area(output) { insta::assert_snapshot!(output, @" + ///The trait for the `rectangle_area` operation. pub trait RectangleArea { + ///The `rectangle_area` operation. fn rectangle_area(&self) -> Scalar; } impl<__Context__, Scalar> RectangleArea for __Context__ diff --git a/crates/tests/cgp-tests/tests/generic_components/fn_impl_generics.rs b/crates/tests/cgp-tests/tests/generic_components/fn_impl_generics.rs index 09c2ad4be..d063cc673 100644 --- a/crates/tests/cgp-tests/tests/generic_components/fn_impl_generics.rs +++ b/crates/tests/cgp-tests/tests/generic_components/fn_impl_generics.rs @@ -25,7 +25,9 @@ snapshot_cgp_fn! { expand_greet(output) { insta::assert_snapshot!(output, @r#" + ///The trait for the `greet` operation. pub trait Greet { + ///The `greet` operation. fn greet(&self) -> String; } impl<__Context__, Name: Display> Greet for __Context__ @@ -59,7 +61,9 @@ snapshot_cgp_fn! { expand_test_greet(output) { insta::assert_snapshot!(output, @r#" + ///The trait for the `test_greet` operation. pub trait TestGreet { + ///The `test_greet` operation. fn test_greet(&self); } impl<__Context__> TestGreet for __Context__ diff --git a/crates/tests/cgp-tests/tests/getters/abstract_type_extend.rs b/crates/tests/cgp-tests/tests/getters/abstract_type_extend.rs index 441ccafa8..e8ea6cd48 100644 --- a/crates/tests/cgp-tests/tests/getters/abstract_type_extend.rs +++ b/crates/tests/cgp-tests/tests/getters/abstract_type_extend.rs @@ -135,6 +135,7 @@ snapshot_cgp_getter! { >>::Delegate::height(__context__) } } + ///Component marker for [`HasRectangleFields`]. pub struct RectangleFieldsGetterComponent; impl<__Context__> RectangleFieldsGetter<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/getters/abstract_type_use_type.rs b/crates/tests/cgp-tests/tests/getters/abstract_type_use_type.rs index 1e8e97fd4..4f09d5087 100644 --- a/crates/tests/cgp-tests/tests/getters/abstract_type_use_type.rs +++ b/crates/tests/cgp-tests/tests/getters/abstract_type_use_type.rs @@ -136,6 +136,7 @@ snapshot_cgp_getter! { >>::Delegate::height(__context__) } } + ///Component marker for [`HasRectangleFields`]. pub struct RectangleFieldsGetterComponent; impl<__Context__> RectangleFieldsGetter<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/getters/assoc_type_getter.rs b/crates/tests/cgp-tests/tests/getters/assoc_type_getter.rs index c8fe43f6b..28a93a31f 100644 --- a/crates/tests/cgp-tests/tests/getters/assoc_type_getter.rs +++ b/crates/tests/cgp-tests/tests/getters/assoc_type_getter.rs @@ -58,6 +58,7 @@ snapshot_cgp_getter! { >>::Delegate::scalar(__context__) } } + ///Component marker for [`HasScalar`]. pub struct ScalarGetterComponent; impl<__Context__> ScalarGetter<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/getters/assoc_type_self_referential.rs b/crates/tests/cgp-tests/tests/getters/assoc_type_self_referential.rs index fdeacd7a6..309b97979 100644 --- a/crates/tests/cgp-tests/tests/getters/assoc_type_self_referential.rs +++ b/crates/tests/cgp-tests/tests/getters/assoc_type_self_referential.rs @@ -55,6 +55,7 @@ snapshot_cgp_getter! { >>::Delegate::name(__context__) } } + ///Component marker for [`HasName`]. pub struct NameGetterComponent; impl<__Context__> NameGetter<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/getters/clone.rs b/crates/tests/cgp-tests/tests/getters/clone.rs index 1c87e94d7..d7125da3c 100644 --- a/crates/tests/cgp-tests/tests/getters/clone.rs +++ b/crates/tests/cgp-tests/tests/getters/clone.rs @@ -56,6 +56,7 @@ snapshot_cgp_getter! { >>::Delegate::name(__context__) } } + ///Component marker for [`HasName`]. pub struct NameGetterComponent; impl<__Context__> NameGetter<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/getters/mref.rs b/crates/tests/cgp-tests/tests/getters/mref.rs index 16d10252b..314b7908c 100644 --- a/crates/tests/cgp-tests/tests/getters/mref.rs +++ b/crates/tests/cgp-tests/tests/getters/mref.rs @@ -44,6 +44,7 @@ snapshot_cgp_getter! { >>::Delegate::foo(__context__) } } + ///Component marker for [`HasFoo`]. pub struct FooGetterComponent; impl<__Context__> FooGetter<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/getters/mut_getter.rs b/crates/tests/cgp-tests/tests/getters/mut_getter.rs index c063523d6..1aecec316 100644 --- a/crates/tests/cgp-tests/tests/getters/mut_getter.rs +++ b/crates/tests/cgp-tests/tests/getters/mut_getter.rs @@ -49,6 +49,7 @@ snapshot_cgp_getter! { >>::Delegate::count(__context__) } } + ///Component marker for [`HasCount`]. pub struct CountGetterComponent; impl<__Context__> CountGetter<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/getters/mut_slice.rs b/crates/tests/cgp-tests/tests/getters/mut_slice.rs index 7869b1b47..486b3e8de 100644 --- a/crates/tests/cgp-tests/tests/getters/mut_slice.rs +++ b/crates/tests/cgp-tests/tests/getters/mut_slice.rs @@ -51,6 +51,7 @@ snapshot_cgp_getter! { >>::Delegate::items(__context__) } } + ///Component marker for [`HasItems`]. pub struct ItemsGetterComponent; impl<__Context__> ItemsGetter<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/getters/non_self.rs b/crates/tests/cgp-tests/tests/getters/non_self.rs index c977e0314..3aa7d3867 100644 --- a/crates/tests/cgp-tests/tests/getters/non_self.rs +++ b/crates/tests/cgp-tests/tests/getters/non_self.rs @@ -64,6 +64,7 @@ snapshot_cgp_getter! { >>::Delegate::foo_bar(foo) } } + ///Component marker for [`HasFooBar`]. pub struct FooBarGetterComponent; impl<__Context__> FooBarGetter<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/getters/option.rs b/crates/tests/cgp-tests/tests/getters/option.rs index 71fd2ceaa..0e5dd2dc8 100644 --- a/crates/tests/cgp-tests/tests/getters/option.rs +++ b/crates/tests/cgp-tests/tests/getters/option.rs @@ -44,6 +44,7 @@ snapshot_cgp_getter! { >>::Delegate::foo(__context__) } } + ///Component marker for [`HasFoo`]. pub struct FooGetterComponent; impl<__Context__> FooGetter<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/getters/slice.rs b/crates/tests/cgp-tests/tests/getters/slice.rs index 8db2df54a..217d3fc74 100644 --- a/crates/tests/cgp-tests/tests/getters/slice.rs +++ b/crates/tests/cgp-tests/tests/getters/slice.rs @@ -45,6 +45,7 @@ snapshot_cgp_getter! { >>::Delegate::foo(__context__) } } + ///Component marker for [`HasFoo`]. pub struct FooGetterComponent; impl<__Context__> FooGetter<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/getters/string.rs b/crates/tests/cgp-tests/tests/getters/string.rs index a606a6672..9c4d44d83 100644 --- a/crates/tests/cgp-tests/tests/getters/string.rs +++ b/crates/tests/cgp-tests/tests/getters/string.rs @@ -44,6 +44,7 @@ snapshot_cgp_getter! { >>::Delegate::foo(__context__) } } + ///Component marker for [`HasFoo`]. pub struct FooGetterComponent; impl<__Context__> FooGetter<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/getters/string_custom_name.rs b/crates/tests/cgp-tests/tests/getters/string_custom_name.rs index 80bed0373..630011408 100644 --- a/crates/tests/cgp-tests/tests/getters/string_custom_name.rs +++ b/crates/tests/cgp-tests/tests/getters/string_custom_name.rs @@ -44,6 +44,7 @@ snapshot_cgp_getter! { >>::Delegate::foo(__context__) } } + ///Component marker for [`HasFoo`]. pub struct GetStringComponent; impl<__Context__> GetString<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/getters/string_custom_spec.rs b/crates/tests/cgp-tests/tests/getters/string_custom_spec.rs index c681335c5..ad5fcbcad 100644 --- a/crates/tests/cgp-tests/tests/getters/string_custom_spec.rs +++ b/crates/tests/cgp-tests/tests/getters/string_custom_spec.rs @@ -43,6 +43,7 @@ snapshot_cgp_getter! { <__Provider__ as DelegateComponent>::Delegate::foo(__context__) } } + ///Component marker for [`HasFoo`]. pub struct GetStringComp; impl<__Context__> GetString<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/handlers/computer_macro.rs b/crates/tests/cgp-tests/tests/handlers/computer_macro.rs index 9032854c3..cf3fd55d1 100644 --- a/crates/tests/cgp-tests/tests/handlers/computer_macro.rs +++ b/crates/tests/cgp-tests/tests/handlers/computer_macro.rs @@ -54,6 +54,7 @@ snapshot_cgp_computer! { __Context__, __Code__, > IsProviderFor for Add {} + ///Provider `Add` for [`Computer`]. pub struct Add; impl DelegateComponent for Add where @@ -226,6 +227,7 @@ snapshot_cgp_computer! { __Code__, > IsProviderFor for AddWithError {} + ///Provider `AddWithError` for [`Computer`]. pub struct AddWithError; impl DelegateComponent for AddWithError where @@ -505,6 +507,7 @@ snapshot_cgp_computer! { __Context__, __Code__, > IsProviderFor for AddGeneric {} + ///Provider `AddGeneric` for [`Computer`]. pub struct AddGeneric; impl DelegateComponent for AddGeneric where diff --git a/crates/tests/cgp-tests/tests/handlers/computer_macro_arity.rs b/crates/tests/cgp-tests/tests/handlers/computer_macro_arity.rs index 13290ccd6..fddf88b9d 100644 --- a/crates/tests/cgp-tests/tests/handlers/computer_macro_arity.rs +++ b/crates/tests/cgp-tests/tests/handlers/computer_macro_arity.rs @@ -36,6 +36,7 @@ snapshot_cgp_computer! { } impl<__Context__, __Code__> IsProviderFor for Zero {} + ///Provider `Zero` for [`Computer`]. pub struct Zero; impl DelegateComponent for Zero where @@ -206,6 +207,7 @@ snapshot_cgp_computer! { __Context__, __Code__, > IsProviderFor for Increment {} + ///Provider `Increment` for [`Computer`]. pub struct Increment; impl DelegateComponent for Increment where diff --git a/crates/tests/cgp-tests/tests/handlers/computer_macro_generics.rs b/crates/tests/cgp-tests/tests/handlers/computer_macro_generics.rs index ff298302e..d29a3ab64 100644 --- a/crates/tests/cgp-tests/tests/handlers/computer_macro_generics.rs +++ b/crates/tests/cgp-tests/tests/handlers/computer_macro_generics.rs @@ -53,6 +53,7 @@ snapshot_cgp_computer! { where T: Display, {} + ///Provider `Describe` for [`Computer`]. pub struct Describe; impl DelegateComponent for Describe where @@ -225,6 +226,7 @@ snapshot_cgp_computer! { __Context__, __Code__, > IsProviderFor for FirstChar {} + ///Provider `FirstChar` for [`Computer`]. pub struct FirstChar; impl DelegateComponent for FirstChar where @@ -397,6 +399,7 @@ snapshot_cgp_computer! { __Context__, __Code__, > IsProviderFor for SumArray {} + ///Provider `SumArray` for [`Computer`]. pub struct SumArray; impl DelegateComponent for SumArray where diff --git a/crates/tests/cgp-tests/tests/handlers/computer_macro_named.rs b/crates/tests/cgp-tests/tests/handlers/computer_macro_named.rs index 6e80ecfd3..87b9f48b4 100644 --- a/crates/tests/cgp-tests/tests/handlers/computer_macro_named.rs +++ b/crates/tests/cgp-tests/tests/handlers/computer_macro_named.rs @@ -33,6 +33,7 @@ snapshot_cgp_computer! { __Context__, __Code__, > IsProviderFor for MyAdder {} + ///Provider `MyAdder` for [`Computer`]. pub struct MyAdder; impl DelegateComponent for MyAdder where diff --git a/crates/tests/cgp-tests/tests/handlers/computer_macro_output.rs b/crates/tests/cgp-tests/tests/handlers/computer_macro_output.rs index 1ad8c1cc2..6628267b9 100644 --- a/crates/tests/cgp-tests/tests/handlers/computer_macro_output.rs +++ b/crates/tests/cgp-tests/tests/handlers/computer_macro_output.rs @@ -35,6 +35,7 @@ snapshot_cgp_computer! { __Context__, __Code__, > IsProviderFor for Ignore {} + ///Provider `Ignore` for [`Computer`]. pub struct Ignore; impl DelegateComponent for Ignore where @@ -207,6 +208,7 @@ snapshot_cgp_computer! { __Code__, > IsProviderFor for ParseQualified {} + ///Provider `ParseQualified` for [`Computer`]. pub struct ParseQualified; impl DelegateComponent for ParseQualified where diff --git a/crates/tests/cgp-tests/tests/handlers/handler_macro.rs b/crates/tests/cgp-tests/tests/handlers/handler_macro.rs index 48e8d6de7..b65861092 100644 --- a/crates/tests/cgp-tests/tests/handlers/handler_macro.rs +++ b/crates/tests/cgp-tests/tests/handlers/handler_macro.rs @@ -50,6 +50,7 @@ snapshot_cgp_computer! { __Context__, __Code__, > IsProviderFor for Add {} + ///Provider `Add` for [`AsyncComputer`]. pub struct Add; impl DelegateComponent for Add where @@ -142,6 +143,7 @@ snapshot_cgp_computer! { __Code__, > IsProviderFor for AddWithError {} + ///Provider `AddWithError` for [`AsyncComputer`]. pub struct AddWithError; impl DelegateComponent for AddWithError where diff --git a/crates/tests/cgp-tests/tests/handlers/producer_macro.rs b/crates/tests/cgp-tests/tests/handlers/producer_macro.rs index 873402f4a..d920075c3 100644 --- a/crates/tests/cgp-tests/tests/handlers/producer_macro.rs +++ b/crates/tests/cgp-tests/tests/handlers/producer_macro.rs @@ -43,6 +43,7 @@ snapshot_cgp_producer! { } impl<__Context__, __Code__> IsProviderFor for MagicNumber {} + ///Provider `MagicNumber` for [`Producer`]. pub struct MagicNumber; impl DelegateComponent for MagicNumber { type Delegate = PromoteProducer; diff --git a/crates/tests/cgp-tests/tests/handlers/producer_macro_output.rs b/crates/tests/cgp-tests/tests/handlers/producer_macro_output.rs index 37ee801ba..ffc595124 100644 --- a/crates/tests/cgp-tests/tests/handlers/producer_macro_output.rs +++ b/crates/tests/cgp-tests/tests/handlers/producer_macro_output.rs @@ -36,6 +36,7 @@ snapshot_cgp_producer! { } impl<__Context__, __Code__> IsProviderFor for TheAnswer {} + ///Provider `TheAnswer` for [`Producer`]. pub struct TheAnswer; impl DelegateComponent for TheAnswer { type Delegate = PromoteProducer; diff --git a/crates/tests/cgp-tests/tests/higher_order_providers/lifetime_inner_provider.rs b/crates/tests/cgp-tests/tests/higher_order_providers/lifetime_inner_provider.rs index 781645d5a..15de79010 100644 --- a/crates/tests/cgp-tests/tests/higher_order_providers/lifetime_inner_provider.rs +++ b/crates/tests/cgp-tests/tests/higher_order_providers/lifetime_inner_provider.rs @@ -55,6 +55,7 @@ snapshot_cgp_new_provider! { where Inner: ReferenceGetter<'a, Context>, {} + ///Provider `ForwardReference` for [`ReferenceGetter`]. pub struct ForwardReference(pub ::core::marker::PhantomData); ") } diff --git a/crates/tests/cgp-tests/tests/higher_order_providers/use_provider_fn.rs b/crates/tests/cgp-tests/tests/higher_order_providers/use_provider_fn.rs index f1c276eda..c33f0a826 100644 --- a/crates/tests/cgp-tests/tests/higher_order_providers/use_provider_fn.rs +++ b/crates/tests/cgp-tests/tests/higher_order_providers/use_provider_fn.rs @@ -34,7 +34,9 @@ snapshot_cgp_fn! { expand_rectangle_area(output) { insta::assert_snapshot!(output, @" + ///The trait for the `rectangle_area` operation. trait RectangleArea { + ///The `rectangle_area` operation. fn rectangle_area(&self) -> f64; } impl<__Context__> RectangleArea for __Context__ diff --git a/crates/tests/cgp-tests/tests/higher_order_providers/use_provider_impl.rs b/crates/tests/cgp-tests/tests/higher_order_providers/use_provider_impl.rs index 664f77597..f07bc756a 100644 --- a/crates/tests/cgp-tests/tests/higher_order_providers/use_provider_impl.rs +++ b/crates/tests/cgp-tests/tests/higher_order_providers/use_provider_impl.rs @@ -150,6 +150,7 @@ snapshot_cgp_impl! { Inner: IsProviderFor + AreaCalculator<__Context__>, {} + ///Provider `ScaledArea` for [`AreaCalculator`]. pub struct ScaledArea(pub ::core::marker::PhantomData); ") } diff --git a/crates/tests/cgp-tests/tests/impl_side_dependencies/fn_extend.rs b/crates/tests/cgp-tests/tests/impl_side_dependencies/fn_extend.rs index e8312eadb..e8aa6fc30 100644 --- a/crates/tests/cgp-tests/tests/impl_side_dependencies/fn_extend.rs +++ b/crates/tests/cgp-tests/tests/impl_side_dependencies/fn_extend.rs @@ -38,7 +38,9 @@ snapshot_cgp_fn! { expand_rectangle_area(output) { insta::assert_snapshot!(output, @" + ///The trait for the `rectangle_area` operation. pub trait RectangleArea: HasScalarType { + ///The `rectangle_area` operation. fn rectangle_area(&self) -> Self::Scalar; } impl<__Context__> RectangleArea for __Context__ diff --git a/crates/tests/cgp-tests/tests/impl_side_dependencies/fn_uses.rs b/crates/tests/cgp-tests/tests/impl_side_dependencies/fn_uses.rs index d1f56c8fa..a021ac18f 100644 --- a/crates/tests/cgp-tests/tests/impl_side_dependencies/fn_uses.rs +++ b/crates/tests/cgp-tests/tests/impl_side_dependencies/fn_uses.rs @@ -30,7 +30,9 @@ snapshot_cgp_fn! { expand_scaled_rectangle_area(output) { insta::assert_snapshot!(output, @" + ///The trait for the `scaled_rectangle_area` operation. pub trait ScaledRectangleArea { + ///The `scaled_rectangle_area` operation. fn scaled_rectangle_area(&self) -> f64; } impl<__Context__> ScaledRectangleArea for __Context__ diff --git a/crates/tests/cgp-tests/tests/impl_side_dependencies/fn_uses_associated_type.rs b/crates/tests/cgp-tests/tests/impl_side_dependencies/fn_uses_associated_type.rs index c2c8d5ec2..7e08cfd89 100644 --- a/crates/tests/cgp-tests/tests/impl_side_dependencies/fn_uses_associated_type.rs +++ b/crates/tests/cgp-tests/tests/impl_side_dependencies/fn_uses_associated_type.rs @@ -27,7 +27,9 @@ snapshot_cgp_fn! { expand_always_true(output) { insta::assert_snapshot!(output, @" + ///The trait for the `always_true` operation. pub trait AlwaysTrue { + ///The `always_true` operation. fn always_true(&self) -> bool; } impl<__Context__> AlwaysTrue for __Context__ diff --git a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_calling_fn.rs b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_calling_fn.rs index d05f34a79..a62a21ad8 100644 --- a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_calling_fn.rs +++ b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_calling_fn.rs @@ -17,7 +17,9 @@ snapshot_cgp_fn! { expand_rectangle_area(output) { insta::assert_snapshot!(output, @" + ///The trait for the `rectangle_area` operation. pub trait RectangleArea { + ///The `rectangle_area` operation. fn rectangle_area(&self) -> f64; } impl<__Context__> RectangleArea for __Context__ @@ -82,7 +84,9 @@ snapshot_cgp_fn! { expand_scaled_rectangle_area(output) { insta::assert_snapshot!(output, @" + ///The trait for the `scaled_rectangle_area` operation. pub trait ScaledRectangleArea { + ///The `scaled_rectangle_area` operation. fn scaled_rectangle_area(&self) -> f64; } impl<__Context__> ScaledRectangleArea for __Context__ diff --git a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_custom_trait_name.rs b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_custom_trait_name.rs index 0ec009615..ebf913f46 100644 --- a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_custom_trait_name.rs +++ b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_custom_trait_name.rs @@ -14,7 +14,9 @@ snapshot_cgp_fn! { expand_rectangle_area(output) { insta::assert_snapshot!(output, @" + ///The trait for the `rectangle_area` operation. pub trait CanCalculateRectangleArea { + ///The `rectangle_area` operation. fn rectangle_area(&self) -> f64; } impl<__Context__> CanCalculateRectangleArea for __Context__ diff --git a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_greet.rs b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_greet.rs index 7d5118da8..349287d21 100644 --- a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_greet.rs +++ b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_greet.rs @@ -19,7 +19,9 @@ snapshot_cgp_fn! { expand_greet(output) { insta::assert_snapshot!(output, @r#" + ///The trait for the `greet` operation. pub trait Greet { + ///The `greet` operation. fn greet(&self); } impl<__Context__> Greet for __Context__ diff --git a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_multi_and_use_type.rs b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_multi_and_use_type.rs index e7ac567e5..f39526674 100644 --- a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_multi_and_use_type.rs +++ b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_multi_and_use_type.rs @@ -47,7 +47,9 @@ snapshot_cgp_fn! { insta::assert_snapshot!(output, @" #[allow(unused)] #[async_trait] + ///The trait for the `do_foo_bar` operation. pub trait DoFooBar: HasFooType + HasFooType + HasBarType { + ///The `do_foo_bar` operation. async fn do_foo_bar(&self, x: X, y: Y) -> Option<::Baz>; } #[allow(unused)] diff --git a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_mut_self_immutable.rs b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_mut_self_immutable.rs index b59137d10..7df14b42f 100644 --- a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_mut_self_immutable.rs +++ b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_mut_self_immutable.rs @@ -22,7 +22,9 @@ snapshot_cgp_fn! { expand_format_label(output) { insta::assert_snapshot!(output, @r#" + ///The trait for the `format_label` operation. pub trait FormatLabel { + ///The `format_label` operation. fn format_label(&mut self) -> String; } impl<__Context__> FormatLabel for __Context__ diff --git a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_mut_slice.rs b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_mut_slice.rs index 7738a452f..cb77ca8cc 100644 --- a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_mut_slice.rs +++ b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_mut_slice.rs @@ -23,7 +23,9 @@ snapshot_cgp_fn! { expand_zero_all(output) { insta::assert_snapshot!(output, @" + ///The trait for the `zero_all` operation. pub trait ZeroAll { + ///The `zero_all` operation. fn zero_all(&mut self); } impl<__Context__> ZeroAll for __Context__ diff --git a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_mutable.rs b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_mutable.rs index 9e2bc4d96..6da70f2be 100644 --- a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_mutable.rs +++ b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_mutable.rs @@ -23,7 +23,9 @@ snapshot_cgp_fn! { expand_capitalize_name(output) { insta::assert_snapshot!(output, @" + ///The trait for the `capitalize_name` operation. pub trait CapitalizeName { + ///The `capitalize_name` operation. fn capitalize_name(&mut self); } impl<__Context__> CapitalizeName for __Context__ diff --git a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_option_mut.rs b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_option_mut.rs index 56818ed85..e685a1897 100644 --- a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_option_mut.rs +++ b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_option_mut.rs @@ -23,7 +23,9 @@ snapshot_cgp_fn! { expand_clear_slot(output) { insta::assert_snapshot!(output, @" + ///The trait for the `clear_slot` operation. pub trait ClearSlot { + ///The `clear_slot` operation. fn clear_slot(&mut self); } impl<__Context__> ClearSlot for __Context__ diff --git a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_option_str.rs b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_option_str.rs index 8b2c36ce1..caa29fa6d 100644 --- a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_option_str.rs +++ b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_option_str.rs @@ -22,7 +22,9 @@ snapshot_cgp_fn! { expand_describe(output) { insta::assert_snapshot!(output, @r#" + ///The trait for the `describe` operation. pub trait Describe { + ///The `describe` operation. fn describe(&self) -> String; } impl<__Context__> Describe for __Context__ diff --git a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_owned_tuple.rs b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_owned_tuple.rs index 874e2a08b..bb3d4fc56 100644 --- a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_owned_tuple.rs +++ b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_owned_tuple.rs @@ -18,7 +18,9 @@ snapshot_cgp_fn! { expand_origin_distance(output) { insta::assert_snapshot!(output, @" + ///The trait for the `origin_distance` operation. pub trait OriginDistance { + ///The `origin_distance` operation. fn origin_distance(&self) -> f64; } impl<__Context__> OriginDistance for __Context__ diff --git a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_slice.rs b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_slice.rs index 1140d3312..e158513c9 100644 --- a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_slice.rs +++ b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_fn_slice.rs @@ -21,7 +21,9 @@ snapshot_cgp_fn! { expand_count_matches(output) { insta::assert_snapshot!(output, @" + ///The trait for the `count_matches` operation. pub trait CountMatches { + ///The `count_matches` operation. fn count_matches(&mut self, byte: u8) -> usize; } impl<__Context__> CountMatches for __Context__ diff --git a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_impl_implicit.rs b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_impl_implicit.rs index e35b5110c..e42a5143d 100644 --- a/crates/tests/cgp-tests/tests/implicit_arguments/cgp_impl_implicit.rs +++ b/crates/tests/cgp-tests/tests/implicit_arguments/cgp_impl_implicit.rs @@ -94,6 +94,7 @@ snapshot_cgp_impl! { Value = f64, >, {} + ///Provider `RectangleArea` for [`AreaCalculator`]. pub struct RectangleArea; ") } diff --git a/crates/tests/cgp-tests/tests/implicit_arguments/doc_comment_on_cgp_fn.rs b/crates/tests/cgp-tests/tests/implicit_arguments/doc_comment_on_cgp_fn.rs new file mode 100644 index 000000000..5144aa8db --- /dev/null +++ b/crates/tests/cgp-tests/tests/implicit_arguments/doc_comment_on_cgp_fn.rs @@ -0,0 +1,53 @@ +//! Where a user's doc comment lands on a `#[cgp_fn]`. +//! +//! The function's doc describes the operation, so it stays on the method, where +//! the function's body lands, and the generated trait carries a line of its own. +//! The generated line is not appended after the user's doc: the method carries one +//! doc line, the user's, and the trait carries one, the generated line. A function +//! with no doc leaves the method with a generated line too, which +//! `doc_comment_on_cgp_fn_without_doc` pins. +//! +//! See cgp-knowledge-base/cgp/implementation/README.md#doc-comments-on-generated-items. + +// The doc comment inside the invocation is consumed by the macro, which emits it +// on the generated items, so rustdoc never sees it here. +#![allow(unused_doc_comments)] + +use cgp_macro_test_util::snapshot_cgp_fn; + +snapshot_cgp_fn! { + #[cgp_fn] + /// The user's doc for the operation. + pub fn greet_fn(&self, #[implicit] name: &str) -> String { + name.to_owned() + } + + expand_greet_fn(output) { + insta::assert_snapshot!(output, @" + ///The trait for the `greet_fn` operation. + pub trait GreetFn { + /// The user's doc for the operation. + fn greet_fn(&self) -> String; + } + /// The user's doc for the operation. + impl<__Context__> GreetFn for __Context__ + where + Self: HasField< + Symbol<4, Chars<'n', Chars<'a', Chars<'m', Chars<'e', Nil>>>>>, + Value = String, + >, + { + fn greet_fn(&self) -> String { + let name: &str = self + .get_field( + ::core::marker::PhantomData::< + Symbol<4, Chars<'n', Chars<'a', Chars<'m', Chars<'e', Nil>>>>>, + >, + ) + .as_str(); + name.to_owned() + } + } + ") + } +} diff --git a/crates/tests/cgp-tests/tests/implicit_arguments/doc_comment_on_cgp_fn_without_doc.rs b/crates/tests/cgp-tests/tests/implicit_arguments/doc_comment_on_cgp_fn_without_doc.rs new file mode 100644 index 000000000..8a2f806e8 --- /dev/null +++ b/crates/tests/cgp-tests/tests/implicit_arguments/doc_comment_on_cgp_fn_without_doc.rs @@ -0,0 +1,47 @@ +//! A `#[cgp_fn]` function with no doc comment. +//! +//! The generated line fills the gap: the method carries `The `greet_fn` operation.` +//! and the trait carries `The trait for the `greet_fn` operation.`, so a crate +//! that enables `missing_docs` reports neither. Together with +//! `doc_comment_on_cgp_fn`, this pins both halves of the rule: a generated line is +//! never appended after a user's doc, and it is added only where the item would +//! otherwise have none. +//! +//! See cgp-knowledge-base/cgp/implementation/README.md#doc-comments-on-generated-items. + +use cgp_macro_test_util::snapshot_cgp_fn; + +snapshot_cgp_fn! { + #[cgp_fn] + pub fn greet_fn(&self, #[implicit] name: &str) -> String { + name.to_owned() + } + + expand_greet_fn_without_doc(output) { + insta::assert_snapshot!(output, @" + ///The trait for the `greet_fn` operation. + pub trait GreetFn { + ///The `greet_fn` operation. + fn greet_fn(&self) -> String; + } + impl<__Context__> GreetFn for __Context__ + where + Self: HasField< + Symbol<4, Chars<'n', Chars<'a', Chars<'m', Chars<'e', Nil>>>>>, + Value = String, + >, + { + fn greet_fn(&self) -> String { + let name: &str = self + .get_field( + ::core::marker::PhantomData::< + Symbol<4, Chars<'n', Chars<'a', Chars<'m', Chars<'e', Nil>>>>>, + >, + ) + .as_str(); + name.to_owned() + } + } + ") + } +} diff --git a/crates/tests/cgp-tests/tests/implicit_arguments/mod.rs b/crates/tests/cgp-tests/tests/implicit_arguments/mod.rs index f5de7dc00..c5762dbf7 100644 --- a/crates/tests/cgp-tests/tests/implicit_arguments/mod.rs +++ b/crates/tests/cgp-tests/tests/implicit_arguments/mod.rs @@ -20,3 +20,8 @@ pub mod cgp_fn_mut_self_immutable; pub mod cgp_impl_implicit; pub mod cgp_impl_implicit_generic; pub mod implicit_context; + +// Where a user's doc comment lands: on the method, with a generated line on the trait. +pub mod doc_comment_on_cgp_fn; +// The gap-filling half: a function with no doc leaves the method with a generated line. +pub mod doc_comment_on_cgp_fn_without_doc; diff --git a/crates/tests/cgp-tests/tests/namespaces/default_impl_use_type.rs b/crates/tests/cgp-tests/tests/namespaces/default_impl_use_type.rs index a124370c1..b5c67dec4 100644 --- a/crates/tests/cgp-tests/tests/namespaces/default_impl_use_type.rs +++ b/crates/tests/cgp-tests/tests/namespaces/default_impl_use_type.rs @@ -69,6 +69,7 @@ snapshot_cgp_impl! { >, __Context__: HasNameType, {} + ///Provider `GreetByName` for [`Greeter`]. pub struct GreetByName; impl<__Components__> AppNamespace<__Components__> for PathCons< diff --git a/crates/tests/cgp-tests/tests/namespaces/default_impls.rs b/crates/tests/cgp-tests/tests/namespaces/default_impls.rs index 3629bc4ce..c2fc4f5e1 100644 --- a/crates/tests/cgp-tests/tests/namespaces/default_impls.rs +++ b/crates/tests/cgp-tests/tests/namespaces/default_impls.rs @@ -55,6 +55,7 @@ snapshot_cgp_component! { >>::Delegate::show(__context__, value) } } + ///Component marker for [`Show`]. pub struct ShowImplComponent; impl<__Context__, T> ShowImpl<__Context__, T> for UseContext where @@ -133,6 +134,7 @@ snapshot_cgp_impl! { } impl<__Context__> IsProviderFor for ShowString {} + ///Provider `ShowString` for [`ShowImpl`]. pub struct ShowString; impl<__Components__> DefaultImpls1 for String { type Delegate = ShowString; @@ -158,6 +160,7 @@ snapshot_cgp_impl! { } impl<__Context__, T: Display> IsProviderFor for ShowWithDisplay {} + ///Provider `ShowWithDisplay` for [`ShowImpl`]. pub struct ShowWithDisplay; ") } @@ -176,8 +179,11 @@ snapshot_cgp_namespace! { expand_default_show_components(output) { insta::assert_snapshot!(output, @" + ///Wiring table for the `DefaultShowComponents` namespace. pub struct __DefaultShowComponentsComponents; + ///The `DefaultShowComponents` namespace's wiring table. pub trait DefaultShowComponents<__Table__> { + ///The provider table the `DefaultShowComponents` namespace delegates to. type Delegate; } impl<__Table__> DefaultShowComponents<__Table__> for String { @@ -198,8 +204,11 @@ snapshot_cgp_namespace! { expand_default_impls_extended_namespace(output) { insta::assert_snapshot!(output, @" + ///Wiring table for the `ExtendedNamespace` namespace. pub struct __ExtendedNamespaceComponents; + ///The `ExtendedNamespace` namespace's wiring table. pub trait ExtendedNamespace<__Table__> { + ///The provider table the `ExtendedNamespace` namespace delegates to. type Delegate; } impl<__Table__, __Key__, __Value__> ExtendedNamespace<__Table__> for __Key__ @@ -230,6 +239,7 @@ snapshot_cgp_impl! { } } impl<__Context__> IsProviderFor for ShowU32 {} + ///Provider `ShowU32` for [`ShowImpl`]. pub struct ShowU32; impl<__Components__> ExtendedNamespace<__Components__> for PathCons< diff --git a/crates/tests/cgp-tests/tests/namespaces/extended.rs b/crates/tests/cgp-tests/tests/namespaces/extended.rs index 67819f835..95c608cfb 100644 --- a/crates/tests/cgp-tests/tests/namespaces/extended.rs +++ b/crates/tests/cgp-tests/tests/namespaces/extended.rs @@ -23,8 +23,11 @@ snapshot_cgp_namespace! { expand_extended_namespace(output) { insta::assert_snapshot!(output, @" + ///Wiring table for the `ExtendedNamespace` namespace. pub struct __ExtendedNamespaceComponents; + ///The `ExtendedNamespace` namespace's wiring table. pub trait ExtendedNamespace<__Table__> { + ///The provider table the `ExtendedNamespace` namespace delegates to. type Delegate; } impl<__Table__, __Key__, __Value__> ExtendedNamespace<__Table__> for __Key__ diff --git a/crates/tests/cgp-tests/tests/namespaces/namespace_basic.rs b/crates/tests/cgp-tests/tests/namespaces/namespace_basic.rs index 22ac50184..57e0e37c2 100644 --- a/crates/tests/cgp-tests/tests/namespaces/namespace_basic.rs +++ b/crates/tests/cgp-tests/tests/namespaces/namespace_basic.rs @@ -33,8 +33,11 @@ snapshot_cgp_namespace! { expand_basic_my_namespace(output) { insta::assert_snapshot!(output, @" + ///Wiring table for the `MyNamespace` namespace. pub struct __MyNamespaceComponents; + ///The `MyNamespace` namespace's wiring table. pub trait MyNamespace<__Table__> { + ///The provider table the `MyNamespace` namespace delegates to. type Delegate; } impl<__Table__> MyNamespace<__Table__> for FooProviderComponent { @@ -83,6 +86,7 @@ snapshot_cgp_component! { >>::Delegate::bar(__context__) } } + ///Component marker for [`Bar`]. pub struct BarProviderComponent; impl<__Context__> BarProvider<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/namespaces/namespace_header_only.rs b/crates/tests/cgp-tests/tests/namespaces/namespace_header_only.rs index 220f1beac..caff3dc82 100644 --- a/crates/tests/cgp-tests/tests/namespaces/namespace_header_only.rs +++ b/crates/tests/cgp-tests/tests/namespaces/namespace_header_only.rs @@ -27,8 +27,11 @@ snapshot_cgp_namespace! { expand_header_only_namespace(output) { insta::assert_snapshot!(output, @" + ///Wiring table for the `HeaderOnlyNamespace` namespace. pub struct __HeaderOnlyNamespaceComponents; + ///The `HeaderOnlyNamespace` namespace's wiring table. pub trait HeaderOnlyNamespace<__Table__> { + ///The provider table the `HeaderOnlyNamespace` namespace delegates to. type Delegate; } ") @@ -42,8 +45,11 @@ snapshot_cgp_namespace! { expand_header_only_extended_namespace(output) { insta::assert_snapshot!(output, @" + ///Wiring table for the `HeaderOnlyExtendedNamespace` namespace. pub struct __HeaderOnlyExtendedNamespaceComponents; + ///The `HeaderOnlyExtendedNamespace` namespace's wiring table. pub trait HeaderOnlyExtendedNamespace<__Table__> { + ///The provider table the `HeaderOnlyExtendedNamespace` namespace delegates to. type Delegate; } impl<__Table__, __Key__, __Value__> HeaderOnlyExtendedNamespace<__Table__> for __Key__ diff --git a/crates/tests/cgp-tests/tests/namespaces/namespace_multi.rs b/crates/tests/cgp-tests/tests/namespaces/namespace_multi.rs index 3450588b0..b49804812 100644 --- a/crates/tests/cgp-tests/tests/namespaces/namespace_multi.rs +++ b/crates/tests/cgp-tests/tests/namespaces/namespace_multi.rs @@ -35,8 +35,11 @@ snapshot_cgp_namespace! { expand_multi_ns_my_namespace(output) { insta::assert_snapshot!(output, @" + ///Wiring table for the `MyNamespace` namespace. pub struct __MyNamespaceComponents; + ///The `MyNamespace` namespace's wiring table. pub trait MyNamespace<__Table__> { + ///The provider table the `MyNamespace` namespace delegates to. type Delegate; } impl<__Table__> MyNamespace<__Table__> for FooProviderComponent { @@ -59,8 +62,11 @@ snapshot_cgp_namespace! { expand_multi_ns_other_namespace(output) { insta::assert_snapshot!(output, @" + ///Wiring table for the `OtherNamespace` namespace. pub struct __OtherNamespaceComponents; + ///The `OtherNamespace` namespace's wiring table. pub trait OtherNamespace<__Table__> { + ///The provider table the `OtherNamespace` namespace delegates to. type Delegate; } impl<__Table__> OtherNamespace<__Table__> for FooProviderComponent { @@ -122,6 +128,7 @@ snapshot_cgp_component! { >>::Delegate::bar(__context__) } } + ///Component marker for [`Bar`]. pub struct BarProviderComponent; impl<__Context__> BarProvider<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/namespaces/namespace_nested_table.rs b/crates/tests/cgp-tests/tests/namespaces/namespace_nested_table.rs index 12611ab69..a195a1a4c 100644 --- a/crates/tests/cgp-tests/tests/namespaces/namespace_nested_table.rs +++ b/crates/tests/cgp-tests/tests/namespaces/namespace_nested_table.rs @@ -48,10 +48,14 @@ snapshot_cgp_namespace! { expand_nested_table_namespace(output) { insta::assert_snapshot!(output, @" + ///Wiring table for the `NestedNs` namespace. pub struct __NestedNsComponents; + ///The `NestedNs` namespace's wiring table. pub trait NestedNs<__Table__> { + ///The provider table the `NestedNs` namespace delegates to. type Delegate; } + ///Wiring table `FooTable`. pub struct FooTable; impl<__Table__> NestedNs<__Table__> for FooProviderComponent { type Delegate = UseDelegate; diff --git a/crates/tests/cgp-tests/tests/namespaces/namespace_symbol_path.rs b/crates/tests/cgp-tests/tests/namespaces/namespace_symbol_path.rs index 4cae79e3f..c3c31afdf 100644 --- a/crates/tests/cgp-tests/tests/namespaces/namespace_symbol_path.rs +++ b/crates/tests/cgp-tests/tests/namespaces/namespace_symbol_path.rs @@ -31,8 +31,11 @@ snapshot_cgp_namespace! { expand_symbol_path_my_namespace(output) { insta::assert_snapshot!(output, @" + ///Wiring table for the `MyNamespace` namespace. pub struct __MyNamespaceComponents; + ///The `MyNamespace` namespace's wiring table. pub trait MyNamespace<__Table__> { + ///The provider table the `MyNamespace` namespace delegates to. type Delegate; } impl<__Table__> MyNamespace<__Table__> for FooProviderComponent { @@ -93,6 +96,7 @@ snapshot_cgp_component! { >>::Delegate::bar(__context__) } } + ///Component marker for [`Bar`]. pub struct BarProviderComponent; impl<__Context__> BarProvider<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/namespaces/namespace_type_path.rs b/crates/tests/cgp-tests/tests/namespaces/namespace_type_path.rs index cb9930fba..fcb12b9e8 100644 --- a/crates/tests/cgp-tests/tests/namespaces/namespace_type_path.rs +++ b/crates/tests/cgp-tests/tests/namespaces/namespace_type_path.rs @@ -33,8 +33,11 @@ snapshot_cgp_namespace! { expand_type_path_my_namespace(output) { insta::assert_snapshot!(output, @" + ///Wiring table for the `MyNamespace` namespace. pub struct __MyNamespaceComponents; + ///The `MyNamespace` namespace's wiring table. pub trait MyNamespace<__Table__> { + ///The provider table the `MyNamespace` namespace delegates to. type Delegate; } impl<__Table__> MyNamespace<__Table__> for FooProviderComponent { @@ -86,6 +89,7 @@ snapshot_cgp_component! { >>::Delegate::bar(__context__) } } + ///Component marker for [`Bar`]. pub struct BarProviderComponent; impl<__Context__> BarProvider<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/namespaces/prefix_default_namespace.rs b/crates/tests/cgp-tests/tests/namespaces/prefix_default_namespace.rs index 7d9f9c2db..2e0a3bb0b 100644 --- a/crates/tests/cgp-tests/tests/namespaces/prefix_default_namespace.rs +++ b/crates/tests/cgp-tests/tests/namespaces/prefix_default_namespace.rs @@ -58,6 +58,7 @@ snapshot_cgp_component! { >>::Delegate::foo(__context__) } } + ///Component marker for [`Foo`]. pub struct FooProviderComponent; impl<__Context__> FooProvider<__Context__> for UseContext where diff --git a/crates/tests/cgp-tests/tests/namespaces/redirect_lookup.rs b/crates/tests/cgp-tests/tests/namespaces/redirect_lookup.rs index 3f08c13c9..7e943aa12 100644 --- a/crates/tests/cgp-tests/tests/namespaces/redirect_lookup.rs +++ b/crates/tests/cgp-tests/tests/namespaces/redirect_lookup.rs @@ -51,6 +51,7 @@ snapshot_cgp_component! { <__Provider__ as DelegateComponent>::Delegate::foo() } } + ///Component marker for [`CanDoFoo`]. pub struct FooProviderComponent; impl<__Context__> FooProvider<__Context__> for UseContext where