Grammar
A definition's spec — the shape of the line that follows @tagname — is written with a handful of factory methods on Spec, combined the same way a regular-expression or parser-combinator library would be: a sequence of parts, one of several alternatives, an optional group, a repeated group.
Spec::rule() is how a grammar reaches into the type parser, a variable, a URI, and so on without knowing anything about how any of those are actually read — that part is delegated entirely to a combinator.
Take the @param tag, whose grammar is
Written with Spec — a type, then a variable, then an optional description — this becomes:
Captures
The second argument to Spec::rule() — 'type', 'variable', 'description' above — is an alias: the key under which whatever that part of the grammar matched is later retrieved from the TagPayload handed to a definition's create().
getAll() returns every value captured under an alias that can occur more than once — the @suppress tag uses exactly that, for its comma-separated list of issue names:
A rule that only shapes the grammar, without producing a value worth keeping — a literal delimiter such as the </> around an email address in @author — is simply written without an alias at all; it still has to match, but nothing is captured for it.
Where to Go Next
- Combinators
The named building blocks a
Spec::rule()runs. See Combinators.- Definitions
Where a
speclives and how its captures are turned into a tag. See Definitions.