all2md.linter.reporters

Reporters that render LintResult instances to strings.

Two reporters ship with the linter:

  • TextReporter — human-readable CLI output

  • JsonReporter — machine-readable output for CI

Third-party reporters can be added later; the get_reporter() factory currently dispatches on short format names only.

class all2md.linter.reporters.Reporter

Bases: ABC

Abstract base for reporters.

abstractmethod render(results: Sequence[LintResult | LintFixResult]) str

Render a list of lint results (or lint+fix results) to a single string.

all2md.linter.reporters.get_reporter(name: str) Reporter

Return a reporter by short name.

Parameters:

name (str) – One of "text" or "json".

Human-readable text reporter.

class all2md.linter.reporters.text.TextReporter

Bases: Reporter

Render lint results in a ruff-style single-line-per-violation format.

When given LintFixResult instances, the report prepends an “Applied N fixes” line per file (with the rule code + description for each applied fix) and adds a “deferred conflicts” footer if any fixes were skipped because another fix touched the same node first.

render(results: Sequence[LintResult | LintFixResult]) str

Render the results as a newline-separated list plus a summary footer.

Machine-readable JSON reporter.

class all2md.linter.reporters.json_reporter.JsonReporter

Bases: Reporter

Render lint results as JSON suitable for CI consumption.

Schema (lint-only):

{
    "summary": {"files": int, "violations": int, "errors": int,
                "warnings": int, "info": int},
    "results": [{
        "file_path": str | null,
        "rules_checked": int,
        "error_count": int, "warning_count": int, "info_count": int,
        "violations": [ { ...violation fields... } ]
    }]
}

When at least one input is a LintFixResult, the summary gains applied and skipped totals, and each result entry gains applied_fixes, skipped_fixes, and pre_fix_violations. The violations field on a fix result is the post-fix violations — what the user still needs to address.

render(results: Sequence[LintResult | LintFixResult]) str

Serialize the results to a JSON string matching the schema in the class docstring.