Classes
Linter
2
▼
Reusable linter bound to an immutable rule registry.
Use this to lint many documents with a fixed …
Linter
2
▼
Reusable linter bound to an immutable rule registry.
Use this to lint many documents with a fixed rule set. The registry is held
immutably on__slots__; each lint() call builds its own context
and accumulator, so one Linter is safe to share across threads.
Methods
Lint Markdown using this linter's registry.
Same polymorphic signature as the …
def lint(self, source: str | Document, *, text: str = '', source_file: str | None = None) -> list[Diagnostic]
Lint Markdown using this linter's registry.
Same polymorphic signature as the top-levellint(), minus the
rulesargument (the registry is fixed at construction).
Parameters
| Name | Type | Description |
|---|---|---|
source |
— |
Markdown source string, or a pre-parsed |
text |
— |
Raw source for a pre-parsed ''
|
source_file |
— |
Optional source file path. Default:None
|
Internal Methods 1 ▼
__init__
1
▼
Initialize with a registry (the default starter rules if None).
__init__
1
▼
def __init__(self, registry: LintRuleRegistry | None = None) -> None
Parameters
| Name | Type | Description |
|---|---|---|
registry |
— |
An immutable :class: None
|
Functions
Normalize the ``rules`` argument to a tuple of rules in order.
def _resolve_rules(rules: Sequence[LintRule] | LintRuleRegistry | None) -> tuple[LintRule, ...]
Parameters
| Name | Type | Description |
|---|---|---|
rules |
Sequence[LintRule] | LintRuleRegistry | None |
Returns
tuple[LintRule, ...]
Run rules over a context, stamping id/severity, sorted for determinism.
def _run(ctx: LintContext, rules: tuple[LintRule, ...]) -> list[Diagnostic]
Parameters
| Name | Type | Description |
|---|---|---|
ctx |
LintContext |
|
rules |
tuple[LintRule, ...] |
Returns
list[Diagnostic]
Lint Markdown and return a list of diagnostics.
Pass a ``str`` for the trivial…
def lint(source: str | Document, *, text: str = '', source_file: str | None = None, rules: Sequence[LintRule] | LintRuleRegistry | None = None) -> list[Diagnostic]
Lint Markdown and return a list of diagnostics.
Pass astrfor the trivial path: it is parsed internally and the same
string is used as the raw source for line-oriented rules, so all rules run
with zero ceremony. Pass a pre-parsed Document for
the power path, supplying the raw source viatext=so source-driven
rules (e.g. trailing-whitespace) are not silently skipped.
Parameters
| Name | Type | Description |
|---|---|---|
source |
str | Document |
Markdown source string, or a pre-parsed |
text |
str |
Raw source for a pre-parsed ''
|
source_file |
str | None |
Optional source file path; flows into the parse and into synthesized diagnostic locations. Default:None
|
rules |
Sequence[LintRule] | LintRuleRegistry | None |
An explicit None
|
Returns
list[Diagnostic]