Skip to content

comicbox.doctor.render

Print a DoctorReport in color.

Status colors are fixed, so red and green mean the same thing in every theme. Section headers and paths come from comicbox’s own print theme (general.theme), so the report matches comicbox -p; a theme of none prints plain text.

Every cell is a Text with a Style, never markup: paths and error messages carry brackets ([digital]) that markup would swallow.

render_report(report, *, theme=None, problems_only=False, console=None)

Print the report: a header, one table per section, and a summary.

problems_only (-q) keeps just the failures and their fixes, drops the sections left empty and the header, and keeps the summary, so a healthy run prints one line.

Source code in comicbox/doctor/render.py
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
def render_report(
    report: DoctorReport,
    *,
    theme: str | None = None,
    problems_only: bool = False,
    console: Console | None = None,
) -> None:
    """
    Print the report: a header, one table per section, and a summary.

    ``problems_only`` (``-q``) keeps just the failures and their fixes,
    drops the sections left empty and the header, and keeps the summary,
    so a healthy run prints one line.
    """
    palette = _palette(theme)
    if console is None:
        # No auto-highlighting: it would recolor numbers and paths.
        console = Console(highlight=False)
    rows = [row for row in report.results if row.status.is_failure or not problems_only]
    widths = _widths(rows, console)
    if not problems_only:
        header = Text("comicbox doctor", style=palette.header)
        header.append("   " + " · ".join(report.header), style=palette.host)
        console.print(header)
    for title, section_rows in groupby(rows, key=lambda row: row.section):
        _section(console, title, list(section_rows), palette, widths)
    if rows or not problems_only:
        console.print()
    console.print(_summary(report, palette))