Skip to content

feat(cli-docs): supplemental content system for generated CLI reference pages#3271

Merged
Mpdreamz merged 4 commits into
mainfrom
feature/cli-gen-continued
May 11, 2026
Merged

feat(cli-docs): supplemental content system for generated CLI reference pages#3271
Mpdreamz merged 4 commits into
mainfrom
feature/cli-gen-continued

Conversation

@Mpdreamz
Copy link
Copy Markdown
Member

@Mpdreamz Mpdreamz commented May 7, 2026

Why

The auto-generated CLI reference pages from #3221 are accurate but bare — they only render what's in the schema JSON. Writers have no way to add prose context, usage walkthroughs, cross-references, or worked examples without editing the schema (which belongs to the CLI tool's codebase, not the docs repo).

What

Supplemental files for writers

Drop a markdown file into docs/cli/ matching the command or namespace name and it enriches the generated page automatically on the next build. No configuration required. If the filename doesn't match a real command, the build fails with an error — so renamed or removed commands can never leave orphaned docs silently.

File naming mirrors the CLI structure:

docs/cli/
  assembler/
    index.md              ← assembler namespace intro
    cmd-build.md          ← assembler build
    deploy/
      cmd-apply.md        ← assembler deploy apply
  cmd-assemble.md         ← root-level assemble command

What goes in a supplemental file is controlled by headings:

A file with no ## headings replaces the description entirely:

Clones all repositories listed in the assembler configuration.
Defaults to `$(pwd)/.artifacts/checkouts/{content_source}`.

Use ## Description when you also want extra sections. Other ## headings append after the generated parameter table — good for usage walkthroughs and worked examples:

## Description

:::{note}
Run `docs-builder assembler clone` before this command.
:::

Builds all documentation sets into a complete site ready to deploy.

## Local workspace example

```sh
docs-builder assembler config init --local
docs-builder assemble --serve

Override the description for specific flags using `## Options` with `: \`--flag\`` entries. Unknown flag names are a build error:

```markdown
## Options

: `--environment`
  The environment to target. Must match the environment used when cloning.
  See [environments](../configure/site/environments.md) for available values.

Full authoring guide at /cli/cli-supplemental-docs — a new page under Automated Reference.

:::{cli-modifiers} pill row

Command metadata from the schema (destructive, requires-confirmation, auth required, idempotent, scope, streaming, long-running) now renders as a colour-coded pill row between the usage block and the description — same visual language as applies-to. The generator emits it automatically; authors never write it by hand.

Reinstated content for assembler and changelog namespaces

Before the schema-driven generator landed, the assembler and changelog command pages were hand-written static markdown files. Those pages were replaced by generated pages but the extra content — usage walkthroughs, platform-specific notes, cross-references, CI environment variable tables — was lost.

This PR reinstates all of it as supplemental files:

  • Assembler (11 files): assembler namespace overview, plus bloom-filter, config init, content-source match (including the speculative-builds explanation), deploy apply/plan, navigation validate, and the full assemble local-workspace walkthrough.
  • Changelog (7 files): add (filenames table, product format and resolution, CI auto-detection env vars), bundle-amend (resolve behaviour, examples), evaluate-pr (GitHub Actions outputs table), gh-release, init, remove (directory resolution tables, profile-based vs option-based mode), and render (output format reference).

Other generator improvements

  • __argh_root and other ReservedMetaCommands tokens are stripped from generated usage lines.
  • Schema notes field is no longer rendered on pages — that content belongs in supplemental post-sections where writers control it.
  • Behaviour flags (--dry-run, --force, output flags) get a compact quick-reference block above the full parameter table.
  • Stack-overflow fix: Collector is now protected on MarkdownFile so CLI record subclasses don't need to store BuildContext as a field, which was causing infinite GetHashCode recursion at startup.

…, and assembler/changelog content

Adds four generator improvements and restores hand-authored content for the
assembler and changelog namespaces.

Generator changes:
- New `:::{cli-modifiers}` directive renders a pill row (destructive,
  requires-confirmation, auth required, idempotent, scope, streaming,
  long-running) between the usage block and description on generated pages
- `CliSupplementalDoc` parser splits supplemental files into typed sections:
  `## Description` overrides the intro; `## Options` / `## Arguments` override
  per-parameter text (unknown keys are a build error); any other `##` heading
  appends as post-content after the generated parameter table
- `__argh_root` and other `ReservedMetaCommands` tokens are stripped from
  generated usage lines
- Schema `notes` field is no longer rendered (use supplemental post-content instead)
- Behaviour-flag params (dryRun, confirmationSkip, output) get a quick-reference
  block above Arguments/Options
- Stack-overflow fix: expose `Collector` as `protected` on `MarkdownFile` so CLI
  file subclasses can emit diagnostics without storing `BuildContext` as a record field

Supplemental content:
- Assembler namespace and all sub-commands (assemble, build, clone, serve, index,
  bloom-filter create/lookup, config init, content-source match/validate,
  deploy apply/plan/update-redirects, navigation validate/validate-link-reference)
- Changelog commands: add, bundle-amend, evaluate-pr, gh-release, init, remove, render

Docs:
- cli-reference-how-to step 3 replaced with a link to the new supplemental-docs page
- New `cli-supplemental-docs.md` documents file naming, heading rules, and
  `## Options` / `## Arguments` override syntax

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@Mpdreamz Mpdreamz requested review from a team as code owners May 7, 2026 19:51
@Mpdreamz Mpdreamz requested a review from cotti May 7, 2026 19:51
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 50a2c947-ffee-4992-a449-ede4fc511bd2

📥 Commits

Reviewing files that changed from the base of the PR and between 015ec32 and 09488ca.

📒 Files selected for processing (1)
  • src/Elastic.Markdown/Extensions/CliReference/CliMarkdownGenerator.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Elastic.Markdown/Extensions/CliReference/CliMarkdownGenerator.cs

📝 Walkthrough

Walkthrough

This PR introduces a structured supplemental documentation system for CLI reference pages alongside a visual modifier badge component system. New CliSupplementalDoc parses markdown files into descriptions, parameter override dictionaries, and post-content sections. Command modifiers (destructive, confirmation, auth, idempotent, streaming, long-running, scope) are rendered as visual badges via a new directive block and Razor view. The CLI markdown generator refactored to use structured supplemental docs instead of raw strings, validates overrides against real parameters, and cleans reserved meta-commands from usage text. File classes and parser/renderer were updated to wire reserved meta-commands and supplemental documents through the generation pipeline. Comprehensive new documentation covers assembler workflows, changelog operations, and supplemental content authoring guidelines.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main feature: a supplemental content system for CLI reference pages.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the why, what, and how of the supplemental content system.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feature/cli-gen-continued

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/Elastic.Markdown/Extensions/CliReference/CliMarkdownGenerator.cs (1)

129-134: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Namespace ## Options overrides are silently dropped.

AppendParameters is called with null overrides, so any OptionOverrides parsed from a namespace supplemental doc never reach the rendered namespace flags. Combined with CliNamespaceFile.BuildMarkdown not plumbing an emitError, writer typos in ## Options for a namespace produce neither an applied override nor a build error — they just vanish. CommandPage plumbs both, namespaces should match.

🛠 Suggested fix (also thread an error callback like `CommandPage`)
-	public static string NamespacePage(CliNamespaceSchema ns, CliSupplementalDoc? supplemental, string[]? fullPath = null, string? binaryName = null, string[]? reservedMetaCommands = null)
+	public static string NamespacePage(
+		CliNamespaceSchema ns,
+		CliSupplementalDoc? supplemental,
+		string[]? fullPath = null,
+		string? binaryName = null,
+		string[]? reservedMetaCommands = null,
+		Action<string>? emitError = null)
 	{
@@
-		if (ns.Options.Count > 0)
-		{
-			_ = sb.AppendLine("## Namespace Flags");
-			_ = sb.AppendLine();
-			AppendParameters(sb, ns.Options, null);
-		}
+		if (ns.Options.Count > 0)
+		{
+			_ = sb.AppendLine("## Namespace Flags");
+			_ = sb.AppendLine();
+			AppendParameters(sb, ns.Options, supplemental?.OptionOverrides);
+		}
+
+		if (supplemental is not null && emitError is not null)
+		{
+			var nsOptionNames = new HashSet<string>(ns.Options.Select(o => o.Name), StringComparer.OrdinalIgnoreCase);
+			foreach (var key in supplemental.OptionOverrides.Keys)
+			{
+				if (!nsOptionNames.Contains(key))
+					emitError($"CLI supplemental: Option '--{key}' not found in namespace '{ns.Segment}'");
+			}
+		}

And in CliNamespaceFile.BuildMarkdown:

-		return CliMarkdownGenerator.NamespacePage(_namespace, supplemental, _fullPath, _binaryName, _reservedMetaCommands);
+		return CliMarkdownGenerator.NamespacePage(
+			_namespace, supplemental, _fullPath, _binaryName, _reservedMetaCommands,
+			error => Collector.EmitError(_supplementalDoc ?? SourceFile, error));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Elastic.Markdown/Extensions/CliReference/CliMarkdownGenerator.cs` around
lines 129 - 134, The namespace-level option overrides are being dropped because
AppendParameters is called with null overrides and
CliNamespaceFile.BuildMarkdown isn't passing an emitError callback; update the
namespace rendering to call AppendParameters(sb, ns.Options, ns.OptionOverrides)
(or the actual property that holds namespace OptionOverrides) so parsed
overrides are applied, and modify CliNamespaceFile.BuildMarkdown to accept and
thread an emitError callback through to the generator (matching CommandPage's
plumbing) so writer typos produce build errors rather than silently
disappearing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/cli/changelog/cmd-render.md`:
- Line 8: The relative link target in the markdown text currently points to
"bundle-amend.md" which is incorrect; update the markdown link in the
docs/cli/changelog/cmd-render.md entry that references bundle-amend.md so it
instead points to the existing file "cmd-bundle-amend.md" (i.e., replace the
target "bundle-amend.md" with "cmd-bundle-amend.md" in the render command
description).

In `@docs/cli/cli-supplemental-docs.md`:
- Around line 19-27: The two fenced code blocks containing the directory
listings (the block starting with "cli/ assembler/ index.md ..." and the block
starting with "cli/ ns-assembler.md ...") must declare a fence language to
satisfy MD040; change their opening and closing fences from ``` to ```text so
both blocks are fenced as ```text ... ```text.

---

Outside diff comments:
In `@src/Elastic.Markdown/Extensions/CliReference/CliMarkdownGenerator.cs`:
- Around line 129-134: The namespace-level option overrides are being dropped
because AppendParameters is called with null overrides and
CliNamespaceFile.BuildMarkdown isn't passing an emitError callback; update the
namespace rendering to call AppendParameters(sb, ns.Options, ns.OptionOverrides)
(or the actual property that holds namespace OptionOverrides) so parsed
overrides are applied, and modify CliNamespaceFile.BuildMarkdown to accept and
thread an emitError callback through to the generator (matching CommandPage's
plumbing) so writer typos produce build errors rather than silently
disappearing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 63ddb330-85e4-43a5-90fc-9f3644d4cdd6

📥 Commits

Reviewing files that changed from the base of the PR and between 129a585 and bf1e179.

📒 Files selected for processing (36)
  • docs/_docset.yml
  • docs/cli/assembler/bloom-filter/cmd-create.md
  • docs/cli/assembler/bloom-filter/cmd-lookup.md
  • docs/cli/assembler/cmd-build.md
  • docs/cli/assembler/cmd-clone.md
  • docs/cli/assembler/config/cmd-init.md
  • docs/cli/assembler/content-source/cmd-match.md
  • docs/cli/assembler/deploy/cmd-apply.md
  • docs/cli/assembler/deploy/cmd-plan.md
  • docs/cli/assembler/index.md
  • docs/cli/assembler/navigation/cmd-validate-link-reference.md
  • docs/cli/assembler/navigation/cmd-validate.md
  • docs/cli/changelog/cmd-add.md
  • docs/cli/changelog/cmd-bundle-amend.md
  • docs/cli/changelog/cmd-evaluate-pr.md
  • docs/cli/changelog/cmd-gh-release.md
  • docs/cli/changelog/cmd-init.md
  • docs/cli/changelog/cmd-remove.md
  • docs/cli/changelog/cmd-render.md
  • docs/cli/cli-reference-how-to.md
  • docs/cli/cli-supplemental-docs.md
  • docs/cli/cmd-assemble.md
  • src/Elastic.Documentation.Site/Assets/markdown/cli-modifiers.css
  • src/Elastic.Documentation.Site/Assets/styles.css
  • src/Elastic.Markdown/Extensions/CliReference/CliCommandFile.cs
  • src/Elastic.Markdown/Extensions/CliReference/CliMarkdownGenerator.cs
  • src/Elastic.Markdown/Extensions/CliReference/CliNamespaceFile.cs
  • src/Elastic.Markdown/Extensions/CliReference/CliReferenceDocsBuilderExtension.cs
  • src/Elastic.Markdown/Extensions/CliReference/CliRootFile.cs
  • src/Elastic.Markdown/Extensions/CliReference/CliSupplementalDoc.cs
  • src/Elastic.Markdown/IO/MarkdownFile.cs
  • src/Elastic.Markdown/Myst/Directives/CliModifiers/CliModifiersBlock.cs
  • src/Elastic.Markdown/Myst/Directives/CliModifiers/CliModifiersView.cshtml
  • src/Elastic.Markdown/Myst/Directives/CliModifiers/CliModifiersViewModel.cs
  • src/Elastic.Markdown/Myst/Directives/DirectiveBlockParser.cs
  • src/Elastic.Markdown/Myst/Directives/DirectiveHtmlRenderer.cs

Comment thread docs/cli/changelog/cmd-render.md
Comment thread docs/cli/cli-supplemental-docs.md Outdated
- Thread OptionOverrides and emitError through NamespacePage so namespace
  supplemental ## Options are applied and typos are caught at build time
- Add text language to directory tree fenced blocks in cli-supplemental-docs.md

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Elastic.Markdown/Extensions/CliReference/CliMarkdownGenerator.cs`:
- Around line 283-308: The early return gated by hasModifiers in
CliMarkdownGenerator.cs prevents the cmd.Output?.Formats rendering block from
running when no modifiers are present; update the logic so output formats aren't
dropped — either include cmd.Output?.Formats (non-empty) in the hasModifiers
predicate or move the formats block (the block that checks cmd.Output?.Formats
and appends "**Output formats:**") above the hasModifiers early-return check;
locate the hasModifiers calculation and the cmd.Output?.Formats block in the
Generate/Write method and apply one of these fixes to ensure formats are always
emitted when present.
- Around line 218-232: The validation currently builds a single set allNames
from cmd.Parameters and checks both supplemental.OptionOverrides.Keys and
supplemental.ArgumentOverrides.Keys against it, allowing cross-matched keys
(option name matching a positional or vice-versa) to pass; change the validation
to build two separate name sets—one for flag/option parameter names and one for
positional/argument names—and validate OptionOverrides.Keys only against the
option-name set and ArgumentOverrides.Keys only against the positional-name set
(use existing symbols: supplemental, emitError, cmd, OptionOverrides,
ArgumentOverrides, and AppendParameters to locate where AppendParameters expects
options vs arguments).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 02d9b20c-b88b-4fae-9e95-b72259550257

📥 Commits

Reviewing files that changed from the base of the PR and between bf1e179 and 015ec32.

📒 Files selected for processing (3)
  • docs/cli/cli-supplemental-docs.md
  • src/Elastic.Markdown/Extensions/CliReference/CliMarkdownGenerator.cs
  • src/Elastic.Markdown/Extensions/CliReference/CliNamespaceFile.cs
✅ Files skipped from review due to trivial changes (1)
  • docs/cli/cli-supplemental-docs.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Elastic.Markdown/Extensions/CliReference/CliNamespaceFile.cs

Comment thread src/Elastic.Markdown/Extensions/CliReference/CliMarkdownGenerator.cs Outdated
Comment thread src/Elastic.Markdown/Extensions/CliReference/CliMarkdownGenerator.cs Outdated
- Output formats block no longer skipped when command has no modifier pills
- Option/argument override validation now checks against the correct parameter
  role subset so a flag name in ## Arguments (or vice-versa) is caught

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@Mpdreamz
Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 11, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Mpdreamz Mpdreamz merged commit 5712b2a into main May 11, 2026
24 checks passed
@Mpdreamz Mpdreamz deleted the feature/cli-gen-continued branch May 11, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants