Skip to content

feat(cli-reference): improve intent pills, add shortcut/alias support#3361

Merged
Mpdreamz merged 2 commits into
mainfrom
feature/cli-schema-updates
May 20, 2026
Merged

feat(cli-reference): improve intent pills, add shortcut/alias support#3361
Mpdreamz merged 2 commits into
mainfrom
feature/cli-schema-updates

Conversation

@Mpdreamz
Copy link
Copy Markdown
Member

Summary

Intent modifier pills

The row of colored pills that indicate a command's operational characteristics (destructive, auth required, idempotent, etc.) has been improved in two ways:

  • Moved above the usage block. Previously the pills appeared directly below the bash usage example, which made them easy to miss. They now sit above the usage block so readers see the warnings before the command.
  • Tooltips on hover. Each pill now shows a plain-English explanation when hovered — e.g. "Modifies or removes data on the target. The change cannot be undone." for the destructive badge. When the CLI schema supplies its own description for a flag, that takes precedence; otherwise a sensible hardcoded fallback is shown.

CLI shortcut / alias support

The upstream CLI schema now ships a shortcuts list (e.g. esstack es, elasticsearchstack es). The docs now reflect this:

  • Alias pages in the navigation. Each shortcut gets its own entry in the nav sidebar with a distinct sky-blue "alias" badge, listed before commands and namespaces so they're easy to spot.
  • Alias pages redirect. Navigating to an alias URL (e.g. /cli/es) immediately redirects the browser to the canonical page (/cli/stack/es/) so there's no dead-end stub.
  • Canonical namespace pages list their aliases. The namespace page shows all known shorthand usages and includes a note linking to each alias.
  • Command pages show the shortest usage first. When a command is reachable via multiple aliases, the shortest form is shown in the bash block, followed by a compact "Also available as: …" note listing just the command names without the full argument list.
  • Required options listed first. Within any command's option list, required options are now sorted to the top so the most important flags are immediately visible.

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

Review Change Stack

Warning

Rate limit exceeded

@Mpdreamz has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 24 minutes and 11 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 820c1b64-c9b1-4853-830c-8e3d58f930bf

📥 Commits

Reviewing files that changed from the base of the PR and between 2c68fab and 70cfbe2.

📒 Files selected for processing (5)
  • src/Elastic.Documentation.Site/Assets/markdown/cli-modifiers.css
  • src/Elastic.Markdown/Extensions/CliReference/CliMarkdownGenerator.cs
  • src/Elastic.Markdown/Extensions/CliReference/CliReferenceDocsBuilderExtension.cs
  • src/Elastic.Markdown/Myst/Directives/CliModifiers/CliModifiersView.cshtml
  • src/Elastic.Markdown/_Layout.cshtml
📝 Walkthrough

Walkthrough

This PR introduces two major features to the CLI documentation system: (1) CLI shortcuts with synthetic alias pages that redirect to canonical command/namespace pages, including ancestor namespace options and global options rendering on command pages, and (2) optional descriptions for CLI modifier flags with CSS-driven tooltips on hover. The shortcut support flows from schema definition through file objects, markdown generation, and navigation/layout rendering. The modifier descriptions follow a similar path from block models through view models to rendered tooltips. Both features extend existing nullable-collection handling in namespace definitions to permit sparse schema structures.

Sequence Diagram

sequenceDiagram
  participant Schema
  participant BuildSynth as BuildSyntheticFiles
  participant GenPages as CliMarkdownGenerator
  participant NavGen as NavigationSetup
  Schema->>BuildSynth: schema.Shortcuts, schema.Namespaces
  BuildSynth->>BuildSynth: create CliAliasFile for each shortcut
  BuildSynth->>BuildSynth: compute ancestor options per command
  BuildSynth->>GenPages: NamespacePage(ns, shortcuts)
  BuildSynth->>GenPages: CommandPage(cmd, shortcuts, ancestorOptions)
  GenPages-->>BuildSynth: rendered pages
  BuildSynth->>NavGen: synthetic alias entities
  NavGen-->>NavGen: render [alias] navigation badges
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.68% 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 two main changes: improving intent pills and adding CLI shortcut/alias support.
Description check ✅ Passed The description is well-structured and clearly explains both features (intent modifier pills and CLI shortcut support) with specific examples.
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-schema-updates

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.

coderabbitai[bot]
coderabbitai Bot previously requested changes May 20, 2026
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: 5

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)

495-500: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Only sort required-first for options, not arguments.

AppendParameters is used for positional argument sections too. Reordering that list changes the documented invocation order, so commands with optional positionals will render incorrect argument sequences.

🤖 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 495 - 500, AppendParameters currently reorders parameters by p.Required
for all parameter types, which breaks positional argument order; change the
logic to only apply OrderByDescending(p => p.Required) to option parameters
while preserving original sequence for positional parameters. Inside
AppendParameters, split parameters into positional (e.g., where p.Name != "_"
and not starting with '-' or using a property like p.IsOption if available) and
option groups, leave the positional group in its incoming order, sort only the
option group by p.Required (and other desired ordering), then concatenate them
for rendering; reference AppendParameters, parameters, CliParamSchema,
p.Required, p.Name and p.Hidden when locating and updating the code.
🤖 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.Documentation.Site/Assets/markdown/cli-modifiers.css`:
- Around line 18-19: The tooltip is only shown on hover (selector
&[data-tooltip]:hover::after) which prevents keyboard users from seeing it;
update the CSS to also show the tooltip on focus (e.g., change the selector to
include :focus and/or :focus-visible such as &[data-tooltip]:hover::after,
&[data-tooltip]:focus::after { `@apply` opacity-100; }) and in
CliModifiersView.cshtml make each .cli-modifier span keyboard-focusable by
adding tabindex="0" to the span markup so focus triggers the tooltip.

In `@src/Elastic.Markdown/_Layout.cshtml`:
- Around line 16-19: Prevent redirects from archive layouts and safely encode
the URL before embedding in JS: change the condition to only run when the page
is not an archive (e.g., check Model.IsArchive != true or a similar archive flag
together with Model.RedirectUrl) and output the redirect URL using a JS-safe
encoder instead of raw interpolation (use HttpUtility.JavaScriptStringEncode or
serialize via JsonConvert/Json.Serialize and render with Html.Raw) so the value
is properly quoted/escaped before calling window.location.replace.

In `@src/Elastic.Markdown/Extensions/CliReference/CliMarkdownGenerator.cs`:
- Around line 856-863: The fallback currently constructs a truncated alias
suffix when canonicalUsage doesn't start with canonicalPrefix (see
canonicalPrefix, canonicalUsage, suffix, fullPath, binaryName, to) which can
produce incomplete alias examples; change the logic so that if canonicalUsage
does not start with canonicalPrefix you do not synthesize an alias usage at all
(i.e., treat it as unsafe to rewrite and skip emitting the alias variant)
instead of falling back to using fullPath[to.Length..]. Ensure the code path
that emits alias usage checks this condition and returns/omits the alias when
the match fails.
- Around line 96-99: Remove the inline JS redirect insertion so layout-level
RedirectUrl logic can control redirects: delete the call that appends the script
using canonicalUrl (the
sb.AppendLine($"<script>window.location.replace('{canonicalUrl}');</script>")
line) and keep only the subsequent no-JS fallback text that appends the shortcut
description using binaryName, shortcut.From and canonicalFull; ensure no other
code in CliMarkdownGenerator.cs injects a client-side redirect for alias pages.

In
`@src/Elastic.Markdown/Extensions/CliReference/CliReferenceDocsBuilderExtension.cs`:
- Around line 212-220: The loop over schema.Shortcuts can silently overwrite
existing entries in _syntheticFiles when SyntheticPath(...) for shortcut.From
collides; update the foreach handling in CliReferenceDocsBuilderExtension so
that after computing aliasPath (using SyntheticPath) you check whether
_syntheticFiles already contains that key, and if so emit an error/log message
referencing the conflicting shortcut (include schema and shortcut.From/To) and
skip creating the CliEntityInfo for that alias instead of assigning to
_syntheticFiles; only create and assign aliasInfo when the path is not already
claimed to prevent silent hijacks.

---

Outside diff comments:
In `@src/Elastic.Markdown/Extensions/CliReference/CliMarkdownGenerator.cs`:
- Around line 495-500: AppendParameters currently reorders parameters by
p.Required for all parameter types, which breaks positional argument order;
change the logic to only apply OrderByDescending(p => p.Required) to option
parameters while preserving original sequence for positional parameters. Inside
AppendParameters, split parameters into positional (e.g., where p.Name != "_"
and not starting with '-' or using a property like p.IsOption if available) and
option groups, leave the positional group in its incoming order, sort only the
option group by p.Required (and other desired ordering), then concatenate them
for rendering; reference AppendParameters, parameters, CliParamSchema,
p.Required, p.Name and p.Hidden when locating and updating the code.
🪄 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: aefffade-919e-4b8c-a179-3b7a72920d0b

📥 Commits

Reviewing files that changed from the base of the PR and between 20b4b96 and 2c68fab.

📒 Files selected for processing (19)
  • src/Elastic.Documentation.Configuration/Toc/CliReference/CliSchema.cs
  • src/Elastic.Documentation.Navigation/Isolated/Node/DocumentationSetNavigation.cs
  • src/Elastic.Documentation.Site/Assets/markdown/cli-modifiers.css
  • src/Elastic.Documentation.Site/Navigation/_TocTreeNav.cshtml
  • src/Elastic.Markdown/Extensions/CliReference/CliAliasFile.cs
  • 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/HtmlWriter.cs
  • src/Elastic.Markdown/IO/MarkdownFile.cs
  • src/Elastic.Markdown/MarkdownLayoutViewModel.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/DirectiveHtmlRenderer.cs
  • src/Elastic.Markdown/Page/Index.cshtml
  • src/Elastic.Markdown/Page/IndexViewModel.cs
  • src/Elastic.Markdown/_Layout.cshtml

Comment thread src/Elastic.Documentation.Site/Assets/markdown/cli-modifiers.css Outdated
Comment thread src/Elastic.Markdown/_Layout.cshtml Outdated
Comment thread src/Elastic.Markdown/Extensions/CliReference/CliMarkdownGenerator.cs Outdated
Comment thread src/Elastic.Markdown/Extensions/CliReference/CliMarkdownGenerator.cs Outdated
- Add :focus-visible to tooltip CSS and tabindex=0 to pills (keyboard a11y)
- JS-encode redirect URL and guard against Archive layout in _Layout
- Remove dead <script> from AliasPage markdown (blocked by DisableHtml)
- Skip alias usage when canonical prefix doesn't match (prevents garbled output)
- Emit error and skip on shortcut path collision instead of silent overwrite
- Preserve positional parameter order in AppendParameters; sort only options

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Mpdreamz Mpdreamz temporarily deployed to integration-tests May 20, 2026 14:05 — with GitHub Actions Inactive
@Mpdreamz Mpdreamz merged commit 46d3697 into main May 20, 2026
24 checks passed
@Mpdreamz Mpdreamz deleted the feature/cli-schema-updates branch May 20, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant