[cardano-testnet] Modify `renderStatusReportHumanReadable` to return `Doc Ann` instead.
I maintainer di solito rispondono entro 2 giorni
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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
Docdescribes the content and where lines may break. A layouter (layoutPretty,layoutSmart) turns it into aSimpleDocStreamfor a given page width, and a renderer turns that intoText. The report code no longer decides where lines end. - Line breaks depend on the available width.
group,softlineandflatAltkeep the summary line or the no-testnet explanation on one line when it fits, and break it when it does not.hangandalignindent 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'sdocToTextuses the ANSI terminal renderer and shows it in colour, whileunAnnotategives 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 asDoc Ann(prettyError,prettyException), so a node's probe error could go into the report as it is, instead of being flattened to aStringfirst.Prettyinstances forNetworkStatusandNodeStatecan 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 AnnfromrenderStatusReportHumanReadable(both types come fromCardano.Api), and giveNetworkStatusandNodeStatePrettyinstances. - Build lines with
pretty,<+>andvsep. Usegroupwithsoftline, andhang, where a line can get long. - In
renderTable, keep the width calculation and replacepad width cellwithfill width (pretty cell)fromPrettyprinter. prettyprinter has no table combinator, so the borders stay hand-built. - Render at the edges:
docToTextwhereRun.hsprints the report. If colour is added, applyunAnnotatebefore rendering in the golden test and when stdout is not a terminal.
Originally posted by @carbolymer in https://github.com/IntersectMBO/cardano-node/pull/6741#discussion_r4348812162
- Lingua principale
- Haskell
- Stelle
- 3.2k
- Fork
- 764
- Merge medio
- 3g 2h
- PR unite (30g)
- 22
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di IntersectMBO/cardano-node
-
Stale
Difficoltà 1/5 1-3 ore Idoneità per principianti 75/100
IntersectMBO/cardano-node#6597 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
IntersectMBO/cardano-node#6522 · 3 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
IntersectMBO/cardano-node#6755 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Dijkstra PV12 needs triage type: regression
Difficoltà 5/5 Più di una settimana Idoneità per principianti 12/100
IntersectMBO/cardano-node#6748 ·
I maintainer di solito rispondono entro 2 giorni
-
[cardano-testnet] Enhancements for status commandForse già presa @palas l’ha presa 8 giorni fa. Aperta
IntersectMBO/cardano-node#6747 · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di IntersectMBO/cardano-node
Issue simili
-
validateXmirOptions error message is missing the word 'option'Forse già presa @opusstudiohq-max l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
objectionary/phino#2256 ·
I maintainer di solito rispondono entro 1 giorno
-
30-minutes algorithm any-language codewars dart easy elixir hackerrank hacktoberfest haskell help wanted interview-prep julia leetcode lua open-source r scala students zig
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Huerte/algo-solutions-python#163 ·
I maintainer di solito rispondono entro 1 giorno
-
subsystem: saw-core type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
GaloisInc/saw-script#3516 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 65/100
qnikst/HaskellNet#125 ·
-
linear
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
MercuryTechnologies/ghciwatch#466 ·