topmark.presentation.shared.diagnostic¶
topmark / presentation / shared / diagnostic
Shared diagnostic preparation for human-facing CLI emitters.
This module contains Click-free helpers and small data shapes that convert internal diagnostic objects into a presentation-friendly form for human output formats (TEXT / MARKDOWN).
Scope
- Prepare stable, minimal "human" diagnostics (counts + rendered lines).
- Avoid depending on machine-format schemas/payloads: those belong under
topmark/**/machine/*and are used by JSON/NDJSON emitters.
Design
- The resulting shapes (
HumanDiagnosticCounts,HumanDiagnosticLine) are used by both TEXT and Markdown emitters. - Helpers here do not print or perform Click I/O. They may normalize text, map levels, and count diagnostics.
Notes
If you need to change the machine diagnostic schema, do so in the
topmark.diagnostic.machine package instead.
HumanDiagnosticLine
dataclass
¶
A human-facing diagnostic line (Click-free).
This is intentionally not a machine schema type. It exists so TEXT and MARKDOWN output can share a stable presentation model without depending on machine-format payload schemas.
Attributes:
| Name | Type | Description |
|---|---|---|
level |
str
|
Diagnostic level as a lowercase string (e.g. "info", "warning", "error"). |
message |
str
|
Diagnostic message text. |
HumanDiagnosticCounts
dataclass
¶
Aggregated per-level counts for human-facing config output.
Attributes:
| Name | Type | Description |
|---|---|---|
info |
int
|
Number of info-level diagnostics. |
warning |
int
|
Number of warning-level diagnostics. |
error |
int
|
Number of error-level diagnostics. |
HumanDiagnostics
dataclass
¶
Prepared human-facing diagnostics for presentation emitters.
Attributes:
| Name | Type | Description |
|---|---|---|
counts |
HumanDiagnosticCounts
|
Aggregated diagnostic counts grouped by severity. |
lines |
list[HumanDiagnosticLine]
|
Prepared human-facing diagnostic lines. |
prepare_human_diagnostics ¶
Convert internal diagnostics into human-facing counts and lines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diagnostics
|
Iterable[Diagnostic]
|
Iterable of internal Diagnostic objects. |
required |
Returns:
| Type | Description |
|---|---|
HumanDiagnostics
|
Structured human-facing diagnostic preparation result. |