summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien d'Herbais de Thun <sebastien.d.herbais@gmail.com>2023-11-20 18:20:42 +0100
committerGitHub <noreply@github.com>2023-11-20 18:20:42 +0100
commitb5956ca3f123085ddd9c6b518443b6a85509ded6 (patch)
treedec54b8f67442e8c55316a08c1b07cdc0cd54c2c
parent96f02960a2d28bdfde23dec92d0a94058f78dd4f (diff)
Document the `#[ghost]` attribute from #2718 (#2721)
-rw-r--r--crates/typst-macros/src/lib.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/typst-macros/src/lib.rs b/crates/typst-macros/src/lib.rs
index dc8f07b1..87048ee5 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);