Skip to content

help: colorize the plain backend (headings/names/values/examples) - #396

Merged
helly25 merged 2 commits into
mainfrom
help/color
Aug 8, 2026
Merged

help: colorize the plain backend (headings/names/values/examples)#396
helly25 merged 2 commits into
mainfrom
help/color

Conversation

@helly25

@helly25 helly25 commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Adds ANSI color to the plain --help backend, the final polish item of the help-model EPIC (#154).

What

Reuses xff/color's resolution at the CLI boundary - color::Enabled(color::ResolveWhen(args), isatty(STDOUT), NO_COLOR) - so help color honors --color=auto|always|never (bare --color = always) and NO_COLOR, exactly like file-type colors. The resolved bool threads through HelpRenderContext into the plain backend.

Palette (color on):

  • section / subsection headings: bold
  • flag / primary entry terms (names): bold cyan
  • value-table terms (values / items): cyan
  • verbatim example / command code: green

Color off renders byte-for-byte as before (guarded by a test), so --man, --markdown, and piped --help are unchanged. XFF.md is unaffected (the markdown backend renders with color off).

How

WrapText is now ANSI-aware: a new VisibleWidth() skips CSI escape sequences, so colored words and indents wrap by their on-screen width, not their byte length. With that in place, the plain EmitRows unifies on WrapText (width 0 = verbatim aligned, width>0 = wrapped) and colors the term column, which let the now-dead RenderDocRows drop out of help.{h,cc} (and its include/dep out of the plain backend).

Tests

  • wrap_test: two ANSI-width cases (escapes are zero-width in both content and indent budgets).
  • help_render_test: the full reference emits every palette code with color on, and zero escapes with color off.
  • Full suite: bazel test //xff/... (85 + 5 skips) and --config=xff_full (90, incl. the XFF.md drift guard) green.

…reen examples)

Reuse xff/color's auto/always/never resolution at the CLI boundary
(color::Enabled(ResolveWhen(args), isatty, NO_COLOR)) and thread the
resolved bool through HelpRenderContext into the plain backend.

Palette (color on): section/subsection headings bold, flag/primary entry
terms bold-cyan, value-table terms cyan, verbatim example/command blocks
green. Color off renders byte-for-byte as before (guarded by a test).

Make WrapText ANSI-aware (VisibleWidth skips CSI escapes) so colored words
and indents wrap by their on-screen width, then unify plain EmitRows on
WrapText - dropping the now-dead RenderDocRows from help.{h,cc} and the
help.h include/dep from the plain backend.

XFF.md is unaffected (color is plain-only; the markdown backend renders
with color off).
@helly25
helly25 enabled auto-merge (squash) August 8, 2026 13:48
…pager idea

Help / docs rendering section: structured examples, indent-aware width
control, and color are all shipped via the EPIC; F (cross-ref/index/
validation) and the HTML backend are parked as infra for unused features.

Add a design leaning for a git-style --pager=CMD (auto on a TTY, honor
$PAGER, fall back to less -FRX; pairs with help color) under deferred
ideas - confirm the default before building.
@helly25
helly25 merged commit 029fe3e into main Aug 8, 2026
9 checks passed
@helly25
helly25 deleted the help/color branch August 8, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant