From b4b022940b908d8fe490b9f4f68bc60dcfb76cd2 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 19 Dec 2022 01:16:35 +0100 Subject: Syntax and example sections --- macros/src/node.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'macros/src/node.rs') 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(), -- cgit v1.2.3