diff --git a/packages/sycamore-macro/src/component/mod.rs b/packages/sycamore-macro/src/component/mod.rs index a1c09c585..6347a100b 100644 --- a/packages/sycamore-macro/src/component/mod.rs +++ b/packages/sycamore-macro/src/component/mod.rs @@ -177,11 +177,23 @@ pub fn component_impl( arg, mut generics, vis, - attrs, + mut attrs, name, return_type, } = component; + let mut doc_attrs = Vec::new(); + let mut i = 0; + while i < attrs.len() { + if attrs[i].path.is_ident("doc") { + // Attribute is a doc attribute. Remove from attrs and add to doc_attrs. + let at = attrs.remove(i); + doc_attrs.push(at); + } else { + i += 1; + } + } + let prop_ty = match &arg { FnArg::Receiver(_) => unreachable!(), FnArg::Typed(pat_ty) => &pat_ty.ty, @@ -226,7 +238,7 @@ pub fn component_impl( } let quoted = quote! { - #(#attrs)* + #(#doc_attrs)* #vis struct #component_name#generics { #[doc(hidden)] _marker: ::std::marker::PhantomData<(#phantom_generics)>, @@ -239,6 +251,7 @@ pub fn component_impl( const NAME: &'static ::std::primitive::str = #component_name_str; type Props = #prop_ty; + #(#attrs)* fn create_component(#arg) -> #return_type{ #block } diff --git a/packages/sycamore/src/context.rs b/packages/sycamore/src/context.rs index 74c16abe5..3e4f0c2d8 100644 --- a/packages/sycamore/src/context.rs +++ b/packages/sycamore/src/context.rs @@ -53,6 +53,7 @@ where /// # } /// ``` #[component(ContextProvider)] +#[cfg_attr(debug_assertions, track_caller)] pub fn context_provider(props: ContextProviderProps) -> View where T: 'static,