From b5956ca3f123085ddd9c6b518443b6a85509ded6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20d=27Herbais=20de=20Thun?= Date: Mon, 20 Nov 2023 18:20:42 +0100 Subject: [PATCH] Document the `#[ghost]` attribute from #2718 (#2721) --- crates/typst-macros/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/typst-macros/src/lib.rs b/crates/typst-macros/src/lib.rs index dc8f07b13..87048ee5e 100644 --- a/crates/typst-macros/src/lib.rs +++ b/crates/typst-macros/src/lib.rs @@ -193,6 +193,13 @@ pub fn ty(stream: BoundaryStream, item: BoundaryStream) -> BoundaryStream { /// - `#[variant]`: Allows setting the ID of a field's variant. This is used /// for fields that are accessed in `typst` and not `typst-library`. It gives /// the field a stable ID that can be used to access it. +/// - `#[ghost]`: Allows creating fields that are only present in the style chain, +/// this means that they *cannot* be accessed by the user, they cannot be set +/// on an individual instantiated element, and must be set via the style chain. +/// This is useful for fields that are only used internally by the style chain, +/// such as the fields from `ParElem` and `TextElem`. If your element contains +/// any ghost fields, then you cannot auto-generate `Construct` for it, and +/// you must implement `Construct` manually. #[proc_macro_attribute] pub fn elem(stream: BoundaryStream, item: BoundaryStream) -> BoundaryStream { let item = syn::parse_macro_input!(item as syn::ItemStruct);