typst/typst · error
the `stringify!` macro is not fully supported in the Typst d
Error message
the `stringify!` macro is not fully supported in the Typst documentation
What it means
This compile-time error is raised by the `documentation` helper in typst-macros when generating Typst documentation from doc comments. When a doc attribute's value is a `stringify!(...)` macro invocation, the helper calls its own `stringify` function to render the tokens; if that function returns `None` (the token stream uses constructs the helper cannot render), it emits this error at the expression's span, indicating the doc string cannot be produced for the Typst docs.
Source
Thrown at crates/typst-macros/src/util.rs:60
let mut doc = String::new();
// Parse doc comments.
for attr in attrs {
if let syn::Meta::NameValue(meta) = &attr.meta
&& meta.path.is_ident("doc")
{
if let syn::Expr::Lit(lit) = &meta.value
&& let syn::Lit::Str(string) = &lit.lit
{
let full = string.value();
let line = full.strip_prefix(' ').unwrap_or(&full);
doc.push_str(line);
doc.push('\n');
} else if let syn::Expr::Macro(expr) = &meta.value
&& expr.mac.path.is_ident("stringify")
{
let value = stringify(expr.mac.tokens.clone()).ok_or_else(|| {
Error::new(
expr.span(),
"the `stringify!` macro is not fully supported in \
the Typst documentation",
)
})?;
doc.push_str(&value);
doc.push('\n');
}
}
}
Ok(doc.trim().into())
}
/// Whether an attribute list has a specified attribute.
pub fn has_attr(attrs: &mut Vec<syn::Attribute>, target: &str) -> bool {
take_attr(attrs, target).is_some()
}View on GitHub (pinned to a73e705a5f)
Solutions
- Replace the `stringify!(...)` doc attribute with a plain string doc comment (`/// ...` or `#[doc = "..."]`) containing the literal text.
- Simplify the tokens inside `stringify!(...)` — remove nested macros or unsupported literals — so the helper's `stringify` function can render them.
- If the doc attribute is generated by another macro, change that generator to emit plain string literals.
Example fix
// before
#[doc = stringify!(MY_ELEMENT_DOCS)]
#[elem]
struct MyElem { ... }
// after
/// Documentation for my element.
#[elem]
struct MyElem { ... } Defensive patterns
Strategy: validation
Validate before calling
// Doc values passed to #[elem]/#[func]/#[ty] items must be plain strings. // Good: #[doc = "literal text"] or /// literal text // Bad: #[doc = stringify!(some_expr)]
Prevention
- Use plain `///` doc comments or `#[doc = "..."]` string literals on macro-decorated items.
- Avoid `stringify!` and nested macros in doc attributes on `#[elem]`/`#[func]`/`#[ty]` items.
- If docs are shared via constants, paste the literal text instead of `stringify!(CONST)`.
- Review any codegen that emits doc attributes to ensure it emits plain strings.
When it happens
Trigger: Writing a doc comment whose value expands to `stringify!(...)` — typically via a macro-generated doc attribute or a `doc = stringify!(...)` form — where the inner tokens contain constructs unsupported by the crate's `stringify` renderer (e.g. unusual literals, nested macros, or complex expressions). Called from `Variant`, `create_input_body`, `parse`, `Field`, and `Param` paths of the macro.
Common situations: Using `#[doc = stringify!(...)]` or a declarative macro that emits `#[doc = stringify!(...)]` on an `#[elem]`/`#[func]`/`#[ty]` item; codegen tools producing doc attributes that rustc accepts but Typst's documentation extractor cannot render; upgrading Typst and introducing docs features the extractor does not support.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- expected named fields
- explicit parent type required
- custom PEM certificates are not supported by native-tls on t
AI-assisted analysis of typst/typst@a73e705a5f (2026-09-12).
Data as JSON: /api/errors/d24797dfa119de85.
Report an issue: GitHub.