You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[cardano-testnet] Modify renderStatusReportHumanReadable to return Doc Ann instead. #6746
renderStatusReportHumanReadable builds the report as a String: lines are joined with <> and unlines, and renderTable pads cells with pad and replicate. That one function decides the content, where lines break and how the output looks, so changing any of these (wrapping, colour, embedding a pretty-printed error) means rewriting string code. cardano-testnet already uses cardano-api's pretty-printing API (prettyError, docToString, docToText, pshow) and depends on prettyprinter, so the report could be a Doc Ann instead.
What prettyprinter gives here:
Layout is separate from content. A Doc describes the content and where lines may break. A layouter (layoutPretty, layoutSmart) turns it into a SimpleDocStream for a given page width, and a renderer turns that into Text. The report code no longer decides where lines end.
Line breaks depend on the available width.group, softline and flatAlt keep the summary line or the no-testnet explanation on one line when it fits, and break it when it does not. hang and align indent the continuation relative to the column where it started, so it lines up without counting the prefix length.
The renderer interprets annotations. Mark a node state as an error once with annotate. cardano-api's docToText uses the ANSI terminal renderer and shows it in colour, while unAnnotate gives plain text for goldens, pipes and log files. The layout code is the same for both.
It composes with existing Docs. cardano-api errors already render as Doc Ann (prettyError, prettyException), so a node's probe error could go into the report as it is, instead of being flattened to a String first. Pretty instances for NetworkStatus and NodeState can be reused the same way.
Today's report is short and has no colour, so these gains show once it grows, for example with the probe error from my comment on line 164.
A rough path:
Return Doc Ann from renderStatusReportHumanReadable (both types come from Cardano.Api), and give NetworkStatus and NodeStatePretty instances.
Build lines with pretty, <+> and vsep. Use group with softline, and hang, where a line can get long.
In renderTable, keep the width calculation and replace pad width cell with fill width (pretty cell) from Prettyprinter. prettyprinter has no table combinator, so the borders stay hand-built.
Render at the edges: docToText where Run.hs prints the report. If colour is added, apply unAnnotate before rendering in the golden test and when stdout is not a terminal.
changed the title [-]Modify `renderStatusReportHumanReadable` to return `Doc Ann` instead.[/-][+][cardano-testnet] Modify `renderStatusReportHumanReadable` to return `Doc Ann` instead.[/+]on Oct 27, 2026
Activity
[-]Modify `renderStatusReportHumanReadable` to return `Doc Ann` instead.[/-][+][cardano-testnet] Modify `renderStatusReportHumanReadable` to return `Doc Ann` instead.[/+]