Skip to main content

Module directives

Module directives 

Source
Expand description

Comment directives that turn badness off for part of a file.

Three families, all spelled as ordinary LaTeX line comments. The verb carries the scope, so every form reads as an imperative (skip-file is “skip this file”, not “the file directive”) and all three share one grammar:

% badness-format <verb>              layout only
% badness-lint   <verb> [<rule>]     linting only, optionally one rule
% badness        <verb>              both at once

with <verb> one of:

skip        the next construct
off … on    everything between the two
skip-file   the whole file, wherever the directive sits

Only the lint axis takes a <rule>, because only the linter has anything to select; omitting it means every rule. The : <reason> tail is optional everywhere and is never interpreted.

§The retired % badness-ignore family

% badness-ignore <rule>: <reason>        → % badness-lint skip <rule>: <reason>
% badness-ignore-file <rule>: <reason>   → % badness-lint skip-file <rule>: <reason>
% badness-ignore-file: <reason>          → % badness-lint skip-file: <reason>

Still recognized, and resolved through exactly the same path as their replacements — the deprecation is in the documentation, never in the behavior. A directive spelling is user-facing API; breaking one silently would be worse than carrying it. Directive::deprecated marks them, so a lint rule reporting the retired spelling can reuse the parsed fact.

§Why this lives in the parser crate

Both consumers need it and neither can reach the other: the formatter is wasm-clean (and is what the dprint plugin embeds), the linter lives in the root crate. Resolving a directive is a pure function of the tree, so it sits below both.

Active directives are recognized in SyntaxKind::COMMENT tokens. A .dtx documentation line starts with DOC_MARGIN, not a comment; directive-shaped prose there is retained as DirectiveOutcome::Unsupported so the linter can explain why it is inert. Inside a macrocode chunk, % comments are ordinary and directives work as everywhere else.

Structs§

Directive
One directive, as written. Resolution against the tree happens in Suppressions::build.
LocatedDirective
A parsed directive together with the exact carrier and family-name ranges, plus its placement outcome. Consumers retain these facts so diagnostics never need to parse comment text or repeat the attachment walk.
Suppressions
The byte ranges a file’s directives suppress, resolved per axis.

Enums§

Axis
Which subsystem a directive turns off.
DirectiveOutcome
What a recognized directive accomplished after placement and region matching.
Verb
The scope a directive applies to. The verb is the scope.

Functions§

parse_directive
Read a directive out of a comment token’s text. Returns None for an ordinary comment and for an unrecognized verb.