diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-12-19 01:16:35 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-12-19 01:16:35 +0100 |
| commit | b4b022940b908d8fe490b9f4f68bc60dcfb76cd2 (patch) | |
| tree | bc93a2f51295f97f971466ab87bdd763c0ed6002 /macros/src/node.rs | |
| parent | ba384e5bb6c2455eb431f6e1fcc8b98aca1e9879 (diff) | |
Syntax and example sections
Diffstat (limited to 'macros/src/node.rs')
| -rw-r--r-- | macros/src/node.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/macros/src/node.rs b/macros/src/node.rs index 1e03c441..5f9573f9 100644 --- a/macros/src/node.rs +++ b/macros/src/node.rs @@ -333,13 +333,18 @@ fn create_node_set_func(node: &Node) -> syn::ImplItemMethod { fn create_node_properties_func(node: &Node) -> syn::ImplItemMethod { let infos = node.properties.iter().filter(|p| !p.skip).map(|property| { let name = property.name.to_string().replace('_', "-").to_lowercase(); - let docs = documentation(&property.attrs); let value_ty = &property.value_ty; let shorthand = matches!(property.shorthand, Some(Shorthand::Positional)); + + let mut docs = documentation(&property.attrs); + let example = quote_option(super::func::example(&mut docs)); + let docs = docs.trim(); + quote! { ::typst::model::ParamInfo { name: #name, docs: #docs, + example: #example, cast: <#value_ty as ::typst::model::Cast< ::typst::syntax::Spanned<::typst::model::Value> >>::describe(), |
