help-model epic: the document model + design note (slice A) - #368
Merged
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What (help-model epic #154, slice A)
The foundation for collapsing the two parallel help systems - the imperative
WriteReferencewalk and the 16 hand-assembledRender*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)Markdown / roff man page / HTML.
--width=N> detected TTY width viaTIOCGWINSZ/$COLUMNS> 80 fallback); Prose free-flows, Rows/Entry wrap with ahanging indent, Example stays verbatim; Markdown/HTML/roff never hard-wrap.
RefTargets (Topic/Flag/Primary/ManPage/Url/Anchor), never formatted links;every Section/Subsection/Entry has a stable anchor, a
BuildIndexwalkyields the index, and a resolution pass validates every internal ref at build
time (a dead
--help=Xbecomes a build error).-> 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
Inlineruns (Text/Code/Emphasis/Strong/Ref +RefTarget); a properlyrecursive block
Content(Entry.details and Subsection.children nest, via astd::vectorindirection that also bounds the variant size); Rows / Bullets /Example (with a
langhint) / SeeAlso; anchors on Section/Subsection/Entry;Documentroot.Tests
help_model_test.ccbuilds a document with every node kind and two levels ofSubsection nesting, then walks it with
std::visit- proving the recursioncompiles 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.