Parses and validates Rust proc-macro attributes, extracting documentation and handling errors.
// Source: https://github.com/typst/typst | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
use heck::{ToKebabCase, ToTitleCase};
use proc_macro2::TokenStream;
use quote::{ToTokens, quote};
use std::str::FromStr;
use syn::parse::{Parse, ParseStream};
use syn::spanned::Spanned;
use syn::token::Token;
use syn::{Attribute, Error, Ident, Result, Token};
/// Return an error at the given item.
macro_rules! bail {
(callsite, $($tts:tt)*) => {
return Err(syn::Error::new(
proc_macro2::Span::call_site(),
format!("typst: {}", format!($($tts)*))
))
};
($item:expr, $($tts:tt)*) => {
return Err(syn::Error::new_spanned(
&$ite
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key