Skip to main content

macro_schema/
lib.rs

1// These link definitions come before the README, so rustdoc uses them for the
2// README's reference links; GitHub and crates.io use the README's own definitions.
3//! [`define!`]: macro@define
4//! [`expand!`]: macro@expand
5#![doc = include_str!("../README.md")]
6#![no_std]
7
8#[doc = include_str!("define.md")]
9pub use macro_schema_derive::define;
10
11/// The procedural macro that every macro defined with [`define!`](macro@define)
12/// calls. You re-export it once and never call it yourself.
13///
14/// Each crate that uses [`define!`](macro@define) must re-export `expand!` at
15/// its crate root, under exactly this name:
16///
17/// ```text
18/// #[doc(hidden)]
19/// pub use macro_schema::expand as __macro_schema_expand;
20/// ```
21///
22/// A defined macro is a small generated `macro_rules!` macro that forwards its
23/// caller's tokens, together with its schema and template, to
24/// `$crate::__macro_schema_expand!`. Because the forwarding goes through
25/// `$crate`, the generated macros work from other crates, including ones that
26/// rename yours.
27///
28/// `expand!` parses the call, checks it against the schema, fills in defaults,
29/// builds the generated documentation, and renders the template (or calls the
30/// [escape-hatch generator](macro@define#escape-hatch-a-macro_rules-generator)).
31/// The repository's `specs/MACRO_SCHEMA_SPEC.md` describes these steps in
32/// detail.
33///
34/// Its input format is internal and may change; only generated macros should
35/// call it.
36pub use macro_schema_derive::expand;