Document the #[ghost] attribute from #2718 (#2721)

This commit is contained in:
Sébastien d'Herbais de Thun 2023-11-20 18:20:42 +01:00 committed by GitHub
parent 96f02960a2
commit b5956ca3f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 /// - `#[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 /// 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. /// 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] #[proc_macro_attribute]
pub fn elem(stream: BoundaryStream, item: BoundaryStream) -> BoundaryStream { pub fn elem(stream: BoundaryStream, item: BoundaryStream) -> BoundaryStream {
let item = syn::parse_macro_input!(item as syn::ItemStruct); let item = syn::parse_macro_input!(item as syn::ItemStruct);