Documentation
¶
Overview ¶
Package render produit la sortie colorée et accessible destinée à l'apprenant.
Index ¶
- Constants
- func HasDarkBackground(out io.Writer, env func(string) string) bool
- func IsTerminal(w io.Writer) bool
- func NewWriter(w io.Writer, color bool) io.Writer
- func RenderDeepen(w io.Writer, e *catalog.Entry, captures map[string]string, exercise bool, ...) error
- func RenderExplanation(w io.Writer, d diagnose.Diagnosis, original string, o Options) error
- func ResolveColor(flag string, env func(string) string, isTTY bool) bool
- func TerminalWidth(w io.Writer) int
- func Wrap(text string, width int, prefix string) string
- type ColorMode
- type Line
- type Options
- type Theme
- func (t Theme) Anti(s string) string
- func (t Theme) Cause(s string) string
- func (t Theme) Concept(s string) string
- func (t Theme) Dim(s string) string
- func (t Theme) Emphasis(s string) string
- func (t Theme) Fix(s string) string
- func (t Theme) Highlight(code, lexer string) string
- func (t Theme) HighlightLines(lines []Line, lexer string, focusLine, focusCol int) string
- func (t Theme) Hint(s string) string
- func (t Theme) Label(s string) string
- func (t Theme) Success(s string) string
- func (t Theme) Title(s string) string
Constants ¶
const ( SymbolError = "✖" LabelConcept = "📘 Concept" LabelCause = "🔎 Cause probable" LabelFixes = "💡 Corrections" LabelAnti = "⚠ Anti-pattern" SymbolSuccess = "✔" LabelDeepen = "➜ Pour aller plus loin" LabelOriginal = "Message Docker d'origine" LabelUnknown = "Erreur non reconnue" LabelExercise = "🧪 Exercice" LabelExample = "▶ Exemple" LabelDocLink = "📖 Documentation" LabelRepeated = "↺ Même erreur que précédemment" LabelLast = "↺ Explication complète" LabelProblem = "✖ Problème" LabelFixedPart = "💡 Version corrigée" )
Libellés et symboles de chaque bloc. Ils restent affichés sans couleur : la couleur n'est jamais le seul porteur d'information (FR-007a).
const TabMarker = "→"
TabMarker représente une tabulation dans les extraits affichés.
Variables ¶
This section is empty.
Functions ¶
func HasDarkBackground ¶
HasDarkBackground devine si le fond du terminal est sombre : d'abord par la variable COLORFGBG (« texte;fond »), puis en interrogeant le terminal quand stdin et la sortie en sont un. Par défaut, le fond est supposé sombre.
func NewWriter ¶
NewWriter enveloppe w pour adapter les couleurs aux capacités du terminal (16, 256 ou 16 millions de couleurs). Quand la couleur est forcée sur une sortie qui n'est pas un terminal, le profil 256 couleurs est utilisé.
func RenderDeepen ¶
func RenderDeepen(w io.Writer, e *catalog.Entry, captures map[string]string, exercise bool, o Options) error
RenderDeepen affiche l'approfondissement d'une entrée : concept détaillé, exemple exécutable coloré, exercice (sur demande) et lien vers la documentation officielle.
func RenderExplanation ¶
RenderExplanation écrit l'explication d'un diagnostic, en français, dans l'ordre : résumé, concept, cause, corrections, anti-pattern, message d'origine, approfondissement.
func ResolveColor ¶
ResolveColor décide si la sortie doit être colorée.
- --color=always ou --color=never l'emportent sur tout le reste ;
- en mode auto : NO_COLOR (non vide) désactive, CLICOLOR_FORCE=1 force, sinon la couleur n'est active que si la sortie est un terminal.
func TerminalWidth ¶
TerminalWidth renvoie la largeur du terminal associé à w, ou 80 par défaut.
Types ¶
type ColorMode ¶
type ColorMode string
ColorMode est la valeur de l'option --color.
func ParseColorMode ¶
ParseColorMode valide la valeur de l'option --color.
type Options ¶
type Options struct {
Theme Theme
Width int // largeur de mise en page (40 minimum)
DockerVersion string // version du client Docker, si connue (FR-001b)
Repeated bool // même erreur depuis moins de 10 minutes : rendu court
Interactive bool // stderr non capturé
ExitCode int
}
Options règle le rendu d'une explication.
type Theme ¶
Theme applique les styles de chaque rôle. Sans couleur, il renvoie le texte tel quel.
func (Theme) Highlight ¶
Highlight colore du code (lexer « bash », « yaml » ou « docker »). Sans couleur, le code est renvoyé tel quel.
func (Theme) HighlightLines ¶
HighlightLines affiche un extrait numéroté. La ligne focusLine est marquée par « ➤ » (et surlignée en couleur) ; si focusCol > 0, un « ^ » est placé sous la colonne fautive.