fix: doc comments breaking server functions (closes #2190) (#2191)

This commit is contained in:
Greg Johnston 2024-01-16 15:31:29 -05:00 committed by GitHub
parent 44db400f6b
commit 3f34d9bb23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -351,6 +351,7 @@ pub fn server_macro_impl(
}
struct ServerFnName {
_attrs: Vec<Attribute>,
struct_name: Ident,
_comma: Option<Token![,]>,
prefix: Option<Literal>,
@ -362,6 +363,7 @@ struct ServerFnName {
impl Parse for ServerFnName {
fn parse(input: ParseStream) -> syn::Result<Self> {
let _attrs: Vec<Attribute> = input.call(Attribute::parse_outer)?;
let struct_name = input.parse()?;
let _comma = input.parse()?;
let prefix = input.parse()?;
@ -382,6 +384,7 @@ impl Parse for ServerFnName {
let fn_path = input.parse()?;
Ok(Self {
_attrs,
struct_name,
_comma,
prefix,
@ -412,7 +415,7 @@ struct ServerFnBody {
/// The custom rusty variant of parsing rsx!
impl Parse for ServerFnBody {
fn parse(input: ParseStream) -> Result<Self> {
let attrs: Vec<Attribute> = input.call(Attribute::parse_outer)?;
let mut attrs: Vec<Attribute> = input.call(Attribute::parse_outer)?;
let vis: Visibility = input.parse()?;
let async_token = input.parse()?;
@ -452,6 +455,12 @@ impl Parse for ServerFnBody {
Some((value.unwrap_or_default(), attr.path.span()))
})
.collect();
attrs.retain(|attr| {
let Meta::NameValue(attr) = &attr.meta else {
return true;
};
!attr.path.is_ident("doc")
});
Ok(Self {
vis,