Reports¶
The format-agnostic report model, the renderer contract and implementations, and the writer that emits rendered reports. See Report Format Reference for the user-facing shape of each format.
Base¶
Renderer contract for turning a Report into a string.
- class markdown_checker.reports.base.ReportRenderer¶
Bases:
ABCRenders a
Reportinto a string. Pure: no file or network I/O.- format_name: Literal['markdown', 'json', 'github-annotations', 'console']¶
Registry key and CLI value, e.g. “markdown”, “json
Model¶
Format-agnostic report model.
Report (and the ReportIssue / FileReport / ReportContext types it is
made of) is the single pivot between the check-running tool and report
rendering: build_report() is the only place that converts tool-specific
CheckResult data into this structure, and every renderer consumes only
Report from here on.
- class markdown_checker.reports.model.ReportIssue(link, line_number, file_path, message, level)¶
Bases:
objectA single finding, decoupled from the runtime
MarkdownLinkBaseobject.- Parameters:
- class markdown_checker.reports.model.FileReport(file_path, errors=(), warnings=())¶
Bases:
objectAll findings for one file, pre-split by level.
- Parameters:
file_path (Path)
errors (tuple[ReportIssue, ...])
warnings (tuple[ReportIssue, ...])
- errors: tuple[ReportIssue, ...]¶
- warnings: tuple[ReportIssue, ...]¶
- class markdown_checker.reports.model.ReportContext(check_name, output_mode='local', repo_url=None, guide_url=None, tool_name='markdown-checker', tool_version='')¶
Bases:
objectRun-level metadata that any renderer may use.
- Parameters:
- class markdown_checker.reports.model.Report(context, files=(), links_checked=0, files_checked=0)¶
Bases:
objectA complete, format-agnostic report for a single check run.
- Parameters:
context (ReportContext)
files (tuple[FileReport, ...])
links_checked (int)
files_checked (int)
- context: ReportContext¶
- files: tuple[FileReport, ...]¶
- markdown_checker.reports.model.build_report(check_result, *, context, files_checked)¶
Convert checker output (
CheckResultofMarkdownLinkBaseissues) into the format-agnosticReport.- Parameters:
check_result (CheckResult) – The result returned by
run_check_on_files.context (ReportContext) – Run-level metadata to attach to the report.
files_checked (int) – Total number of files that were checked.
- Returns:
A
Reportwith issues split into errors/warnings per file.- Return type:
Registry¶
Registry mapping report format names to ReportRenderer implementations.
- markdown_checker.reports.registry.RENDERERS: dict[Literal['markdown', 'json', 'github-annotations', 'console'], type[ReportRenderer]]¶
Maps the CLI
--report-formatargument value to the corresponding renderer class.
- markdown_checker.reports.registry.get_renderer(format_name, **options)¶
Instantiate a renderer by name.
- Parameters:
- Raises:
ValueError – If
format_nameis not a registered renderer.- Return type:
Writer¶
Writes rendered report strings to a file or stdout.
- markdown_checker.reports.writer.write_report(rendered, *, output_path)¶
Write a rendered report to
output_path, or to stdout whenoutput_pathisNone.
Markdown Renderer¶
Renders a Report as a Markdown document with an HTML issues table.
This mirrors the original MarkdownGenerator output exactly: a per-check
header template, an optional contributing-guide line, then a table of
error-level issues only (warnings are not included in the Markdown report).
- class markdown_checker.reports.renderers.markdown.MarkdownRenderer¶
Bases:
ReportRendererRenders a
Reportas Markdown, matching the historicalcomment.mdoutput.- format_name: Literal['markdown', 'json', 'github-annotations', 'console']¶
Registry key and CLI value, e.g. “markdown”, “json
JSON Renderer¶
Renders a Report as machine-readable JSON.
- class markdown_checker.reports.renderers.json.JsonRenderer(indent=2)¶
Bases:
ReportRendererRenders a
Reportas a JSON document, including both errors and warnings.- Parameters:
indent (int)
- format_name: Literal['markdown', 'json', 'github-annotations', 'console']¶
Registry key and CLI value, e.g. “markdown”, “json
GitHub Annotations Renderer¶
Renders a Report as GitHub Actions workflow annotations
(::error file=...,line=...::...).
- class markdown_checker.reports.renderers.annotations.GitHubAnnotationsRenderer¶
Bases:
ReportRendererRenders a
Reportas one GitHub Actions annotation per issue.- format_name: Literal['markdown', 'json', 'github-annotations', 'console']¶
Registry key and CLI value, e.g. “markdown”, “json
- file_extension: str¶
Default file extension for this report format, including the dot, e.g. “.md”, “.json”.
- render_lines(report)¶
Return (annotation_line, level) pairs, in file/issue order.
Console Renderer¶
Renders a Report as plain, human-readable console text (local/non-CI mode).
- class markdown_checker.reports.renderers.console.ConsoleRenderer¶
Bases:
ReportRendererRenders a
Reportas plain console text, one block per issue.- format_name: Literal['markdown', 'json', 'github-annotations', 'console']¶
Registry key and CLI value, e.g. “markdown”, “json
- file_extension: str¶
Default file extension for this report format, including the dot, e.g. “.md”, “.json”.
- render_lines(report)¶
Return (console_block, level) pairs, in file/issue order.