Skip to content

Commit

Permalink
Portal: Support for portal to allow docs in enum fields
Browse files Browse the repository at this point in the history
  • Loading branch information
corigan01 committed Feb 10, 2025
1 parent cd7860e commit e5c6fd6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/portal-macro/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ pub struct ProtocolEnumDef {
#[derive(Debug)]
#[allow(unused)]
pub struct ProtocolEnumVarient {
pub docs: Vec<Attribute>,
pub ident: Ident,
pub fields: ProtocolEnumFields,
}
Expand Down
2 changes: 2 additions & 0 deletions crates/portal-macro/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,11 @@ impl TryFrom<&syn::Variant> for ast::ProtocolEnumVarient {
type Error = syn::Error;
fn try_from(value: &syn::Variant) -> Result<Self, Self::Error> {
let ident = value.ident.clone();
let docs = value.attrs.clone();
Ok(Self {
ident,
fields: (&value.fields).try_into()?,
docs,
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/portal-macro/src/rust_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,10 @@ impl ToTokens for ast::ProtocolEnumVarient {
fn to_tokens(&self, tokens: &mut TokenStream2) {
let ident = &self.ident;
let fields = &self.fields;
let docs = &self.docs;

tokens.append_all(quote! {
#(#docs)*
#ident #fields
});
}
Expand Down

0 comments on commit e5c6fd6

Please sign in to comment.