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.

Scope limit: a directive is recognized in a SyntaxKind::COMMENT token only. In a .dtx documentation line the leading % is a DOC_MARGIN and the rest is prose, so a directive written there is inert; inside a macrocode chunk (where % comments are ordinary) it works as everywhere else.

Structs§

Directive
One directive, as written. Resolution against the tree happens in Suppressions::build.
Suppressions
The byte ranges a file’s directives suppress, resolved per axis.

Enums§

Axis
Which subsystem a directive turns off.
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.