Skip to content

help-model epic: the document model + design note (slice A) - #368

Merged
helly25 merged 1 commit into
mainfrom
feat/help-model-foundation
Aug 5, 2026
Merged

help-model epic: the document model + design note (slice A)#368
helly25 merged 1 commit into
mainfrom
feat/help-model-foundation

Conversation

@helly25

@helly25 helly25 commented Aug 5, 2026

Copy link
Copy Markdown
Owner

What (help-model epic #154, slice A)

The foundation for collapsing the two parallel help systems - the imperative
WriteReference walk and the 16 hand-assembled Render* string-builders +
kHelpText - into one semantic document model that pluggable backends render.
This slice adds the model + the design record; no live rendering is rewired yet.

Design (docs/design-help-model.md)

  • Model is an output-independent AST; backends are plain text / ANSI color /
    Markdown / roff man page / HTML.
  • Width is a text-backend-only concern (--width=N > detected TTY width via
    TIOCGWINSZ/$COLUMNS > 80 fallback); Prose free-flows, Rows/Entry wrap with a
    hanging indent, Example stays verbatim; Markdown/HTML/roff never hard-wrap.
  • Highlighting is typed inline runs; cross-references are semantic
    RefTargets (Topic/Flag/Primary/ManPage/Url/Anchor), never formatted links;
    every Section/Subsection/Entry has a stable anchor, a BuildIndex walk
    yields the index, and a resolution pass validates every internal ref at build
    time (a dead --help=X becomes a build error).
  • Authoring is C++ model data. The only string markup is backticks (single
    -> inline Code, triple fence -> Example); we deliberately do NOT parse
    #/-/* because those are exactly xff's flag/glob/regex characters. XHTML /
    Markdown are output backends only, never input.

Model (xff/cli/help_model.h)

Typed Inline runs (Text/Code/Emphasis/Strong/Ref + RefTarget); a properly
recursive block Content (Entry.details and Subsection.children nest, via a
std::vector indirection that also bounds the variant size); Rows / Bullets /
Example (with a lang hint) / SeeAlso; anchors on Section/Subsection/Entry;
Document root.

Tests

help_model_test.cc builds a document with every node kind and two levels of
Subsection nesting, then walks it with std::visit - proving the recursion
compiles and terminates - and asserts refs carry a semantic target and
entries/examples carry their metadata.

Next slices: the backtick parser, Render(Document, Backend) + porting the roff/
markdown/plain backends (byte-identical), build-from-SSOT, then the topic
migration that retires the Render* string pile.

The foundation for collapsing the two parallel help systems (the imperative
WriteReference walk plus the 16 hand-assembled Render* string-builders and
kHelpText) into one semantic document model that pluggable backends render.

- docs/design-help-model.md: the decision record. Model is an output-independent
  AST; backends are plain / ANSI color / Markdown / roff / HTML. Width is a
  text-backend-only concern (--width > TTY width > 80). Typed inline runs for
  highlighting; semantic RefTarget cross-references; per-node anchors + a
  BuildIndex walk + build-time cross-ref validation. Authoring is C++ model data;
  the only string markup is backticks (single -> inline Code, triple fence ->
  Example), because #/-/* collide with xff's flag/glob/regex characters.
- xff/cli/help_model.h: the generalized model. Typed Inline runs (Text / Code /
  Emphasis / Strong / Ref) with a semantic RefTarget; a properly recursive block
  Content (Entry.details, Subsection.children nest via a std::vector indirection),
  Rows / Bullets / Example (with a lang hint) / SeeAlso; stable anchors on
  Section / Subsection / Entry; Document root.
- xff/cli/help_model_test.cc: constructs a document exercising every node kind
  plus two levels of Subsection nesting, and walks it via std::visit - so the
  recursion is proven to compile and terminate; asserts inline refs carry a
  semantic target and entries/examples carry their metadata.

No live rendering is rewired yet; that is the next slices (parser, backends,
build-from-SSOT, topic migration).
@helly25
helly25 enabled auto-merge (squash) August 5, 2026 20:51
@helly25
helly25 merged commit 522df6a into main Aug 5, 2026
9 checks passed
@helly25
helly25 deleted the feat/help-model-foundation branch August 5, 2026 21:05
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