feat(cli-reference): support title overrides#3487
Conversation
Allow cli TOC entries to override the generated root page title and navigation label without changing schema command names. Co-authored-by: GPT-5.5 <gpt-5.5@openai.com> Co-authored-by: Cursor <cursoragent@cursor.com>
|
@copilot resolve the merge conflicts in this pull request |
Resolve the CLI reference generator overlap by preserving supplemental frontmatter output and keeping the root title override for the generated H1. Co-authored-by: GPT-5.5 <gpt-5.5@openai.com> Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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`:
- Line 17: The H1 fallback uses title ?? schema.Name which treats empty or
whitespace titles as present; change it to treat blank titles as missing by
replacing the expression with a whitespace check (e.g., use
string.IsNullOrWhiteSpace(title) ? schema.Name : title) where sb.AppendLine($"#
{title ?? schema.Name}") is called in CliMarkdownGenerator (method building the
header) so empty/whitespace title overrides fall back to schema.Name.
🪄 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: 755e1183-0231-4023-b713-b5740f39502b
📒 Files selected for processing (1)
src/Elastic.Markdown/Extensions/CliReference/CliMarkdownGenerator.cs
| var sb = new StringBuilder(); | ||
| AppendFrontMatter(sb, supplemental); | ||
| _ = sb.AppendLine($"# {schema.Name}"); | ||
| _ = sb.AppendLine($"# {title ?? schema.Name}"); |
There was a problem hiding this comment.
Fallback should ignore blank title overrides.
At Line 17, title ?? schema.Name will render an empty H1 when title is "" or whitespace. Treat blank values as missing so generated pages always have a valid heading.
Suggested fix
- _ = sb.AppendLine($"# {title ?? schema.Name}");
+ var pageTitle = string.IsNullOrWhiteSpace(title) ? schema.Name : title.Trim();
+ _ = sb.AppendLine($"# {pageTitle}");📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| _ = sb.AppendLine($"# {title ?? schema.Name}"); | |
| var pageTitle = string.IsNullOrWhiteSpace(title) ? schema.Name : title.Trim(); | |
| _ = sb.AppendLine($"# {pageTitle}"); |
🤖 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` at line
17, The H1 fallback uses title ?? schema.Name which treats empty or whitespace
titles as present; change it to treat blank titles as missing by replacing the
expression with a whitespace check (e.g., use string.IsNullOrWhiteSpace(title) ?
schema.Name : title) where sb.AppendLine($"# {title ?? schema.Name}") is called
in CliMarkdownGenerator (method building the header) so empty/whitespace title
overrides fall back to schema.Name.
Resolved and pushed. Merge conflicts are fixed in commit |
Co-authored-by: GPT-5.5 <gpt-5.5@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
titleandnavigation_titlesupport tocli:TOC entries.schema.namefor command usage examples.Test plan
dotnet test tests/Elastic.Documentation.Configuration.Tests/Elastic.Documentation.Configuration.Tests.csproj.dotnet test tests/Elastic.Markdown.Tests/Elastic.Markdown.Tests.csproj --filter FullyQualifiedName~CliMarkdownGeneratorTests.dotnet build.Made with Cursor