feat: add rpk documentation automation#1733
Conversation
✅ Deploy Preview for redpanda-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR introduces a complete system for customizing auto-generated rpk CLI documentation through JSON-based overrides. It adds a directory structure guide, a comprehensive JSON Schema defining the override format, a detailed user guide explaining how to use overrides, and a GitHub Actions workflow that automates documentation generation and pull request creation with parsed diff summaries. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
6f87a4e to
9c868ee
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
.github/workflows/update-rpk-docs.yml (1)
30-30: ⚡ Quick winPin GitHub Actions to commit SHAs for supply chain security.
Actions are referenced by mutable tags (
@v4,@v5,@v6) which can be updated by action maintainers. Pinning to immutable commit SHAs prevents supply chain attacks where action tags are compromised.Example pins for current stable versions:
actions/checkout@v4→actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683# v4.2.2actions/setup-node@v4→actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af# v4.1.0actions/setup-go@v5→actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a# v5.2.0peter-evans/create-pull-request@v6→peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f# v7.0.5Verify current SHA pins before applying.
Also applies to: 35-35, 44-44, 210-210
🤖 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 @.github/workflows/update-rpk-docs.yml at line 30, The workflow references mutable action tags like actions/checkout@v4, actions/setup-node@v4, actions/setup-go@v5, and peter-evans/create-pull-request@v6; replace those tag references with their corresponding immutable commit SHAs (e.g., actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683, actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af, actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a, peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f) and verify the current stable SHA for each action before applying the change so the workflow uses immutable pins for supply-chain security.
🤖 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 @.github/workflows/update-rpk-docs.yml:
- Around line 29-32: The checkout step labeled "Checkout docs repo" (uses:
actions/checkout@v4) is missing persist-credentials control; modify that step to
add persist-credentials: false under its with block to ensure the GITHUB_TOKEN
is not persisted to the checked-out repo and cannot leak to subsequent steps or
git operations.
- Around line 48-71: The step is vulnerable because it directly interpolates
user-controlled inputs into shell assignments (VERSION, DIFF_VERSION,
DRAFT_MISSING, branch_name); instead validate and sanitize those inputs before
use: explicitly read the incoming values into safe variables, validate VERSION
against an allowlist/regex (e.g. semantic version or "dev"), normalize/whitelist
DIFF_VERSION and DRAFT_MISSING (accept only expected patterns like digits or
"true"/"false"), and reject or fallback to safe defaults for anything else;
construct branch_name from the validated VERSION only (no raw string
concatenation of untrusted input) and prefer assigning values via the GitHub
Actions env/outputs mechanism rather than unquoted shell expansion so no user
payload can inject commands.
- Around line 102-107: Remove the redundant file-existence test that uses `[ -f
"docs-data/rpk-diff-*.json" ]`; instead keep the existing discovery using
`DIFF_FILE=$(ls -t docs-data/rpk-diff-*.json 2>/dev/null | head -1)` and the
subsequent `if [ -n "$DIFF_FILE" ]; then echo "diff_file=$DIFF_FILE" >>
$GITHUB_OUTPUT; fi` logic so the script relies on `ls` to find the latest
matching `docs-data/rpk-diff-*.json` file and only emits to `GITHUB_OUTPUT` when
`DIFF_FILE` is non-empty (remove the outer `if [ -f ... ]; then` and its
matching `fi`).
---
Nitpick comments:
In @.github/workflows/update-rpk-docs.yml:
- Line 30: The workflow references mutable action tags like actions/checkout@v4,
actions/setup-node@v4, actions/setup-go@v5, and
peter-evans/create-pull-request@v6; replace those tag references with their
corresponding immutable commit SHAs (e.g.,
actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683,
actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af,
actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a,
peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f) and
verify the current stable SHA for each action before applying the change so the
workflow uses immutable pins for supply-chain security.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2516b58b-06c0-462f-88ec-8c6809c42486
📒 Files selected for processing (5)
.github/workflows/update-rpk-docs.ymldocs-data/README.adocdocs-data/RPK_OVERRIDES_GUIDE.adocdocs-data/rpk-overrides.jsondocs-data/rpk-overrides.schema.json
c85e851 to
371ce42
Compare
PR ReviewFiles reviewed: 2 What this PR doesAdds the infrastructure to automatically generate rpk CLI documentation: a GitHub Actions workflow (triggerable manually or via Jira ticket alignmentTicket: Not referenced directly in the PR title/body. Linked dependency is docs-extensions-and-macros#203 ("DOC-2220: comprehensive rpk documentation automation system"), which is still OPEN, not merged. Critical issues (must fix)
Suggestions (should consider)
Impact on other files
CodeRabbit findings worth consideringAll four are surfaced above. The template injection one (critical) is the most important — that's a real CI security issue, not a style preference. The other three ( What works well
🤖 Generated with Claude Code via |
|
Thanks for the thorough review! Addressed all critical issues in 719f467: Critical fixes:
Note on redundant glob test: Already fixed in a99a1e4 - the Merge order: Confirmed - docs-extensions-and-macros#203 must merge first (contains the |
|
@JakeSCahill let me know if this is valid:
|
|
@kbatuigas Good catch! I've fixed both issues: Fixed in d5cfc54
Schema now validates successfully: The schema matches the generator's expected data model in docs-extensions-and-macros. |
|
@kbatuigas please take another look |
|
Two notes from working through a 1. A {
"description": "Fix doubled 'are' in rpk group description",
"pattern": "than there are are total partitions",
"replacement": "than there are total partitions",
"flags": "g"
}I scoped the pattern to the full phrase rather than 2. Minor doc fix in |
|
Cross-linking for visibility: redpanda-data/adp-docs#110 is hand-adding 34 That bumps into this PR's design: #1733 deliberately excludes Two things worth aligning on when you get a chance:
No action needed on this PR — just flagging the connection so the rpk-ai path doesn't fall between the two repos. |
Add the infrastructure for automated rpk CLI documentation generation. Does not include generated pages - those will be created by running the workflow after merge. ## New files - `.github/workflows/update-rpk-docs.yml` - GitHub Action for automated updates - `docs-data/rpk-overrides.json` - Writer override configuration - `docs-data/rpk-overrides.schema.json` - JSON Schema for validation - `docs-data/RPK_OVERRIDES_GUIDE.adoc` - Writer guide for customization - `docs-data/README.adoc` - Directory reference ## Workflow features - Manual trigger via workflow_dispatch - Cross-repo trigger via repository_dispatch - Automatic PR creation with diff summary - Support for version tags and dev branch ## Excluded commands - `rpk ai *` - 41 commands marked "coming soon" - `rpk oxla` - Marked "coming soon" Related: redpanda-data/docs-extensions-and-macros#203
Add the infrastructure for automated rpk CLI documentation generation. Does not include generated pages - those will be created by running the workflow after merge. - `.github/workflows/update-rpk-docs.yml` - GitHub Action for automated updates - `docs-data/rpk-overrides.json` - Writer override configuration - `docs-data/rpk-overrides.schema.json` - JSON Schema for validation - `docs-data/RPK_OVERRIDES_GUIDE.adoc` - Writer guide for customization - `docs-data/README.adoc` - Directory reference - Manual trigger via workflow_dispatch - Cross-repo trigger via repository_dispatch - Automatic PR creation with diff summary - Support for version tags and dev branch - `rpk ai *` - 41 commands marked "coming soon" - `rpk oxla` - Marked "coming soon" Related: redpanda-data/docs-extensions-and-macros#203
- Remove redundant "NOTE:" prefix from content in type: "note" items (template already adds the prefix) - Add safety net text transformations for duplicate admonitions Fixes: - rpk security acl create: "NOTE: NOTE:" → "NOTE:" - rpk cluster self-test start: "NOTE: NOTE:" → "NOTE:" Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Capture Michele's editorial improvements for rpk ai commands while keeping them excluded. Content will be used when exclusions are removed. - rpk ai llm: supported provider types - rpk ai model: catalog behavior explanation - rpk ai oauth: OAuth provider purpose - rpk ai oauth-client: OAuthClient explanation and client_secret behavior Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When running with --diff, automatically update the what's-new file with new rpk commands, flags, and changed defaults. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Detect RC versions (e.g., v26.2.0-rc1) - Validate RC version matches beta branch antora.yml version - Create PRs against beta branch for RC releases - Regular releases continue targeting main branch Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Critical fixes: - Fix file paths in RPK_OVERRIDES_GUIDE.adoc (remove docs-extensions-and-macros/ prefix) - Fix command example path (remove ../docs/ prefix) - Replace broken relative links with cross-repo GitHub URLs - Fix template injection vulnerability by moving repository_dispatch payload to env block - Add persist-credentials: false to checkout step Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove explicit path since it now defaults to the standard location. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixes schema/overrides mismatch flagged in PR review: 1. Updated rpk-overrides.schema.json to match the version in docs-extensions-and-macros which includes: - descriptionScope property for conditional description scoping - exampleItem $def for reuse in subsections - items property in subsection (alternative to content) - anyOf constraint allowing either content or items in subsections 2. Renamed descriptionAppend → appendToDescription in rpk-overrides.json to match the schema property name Schema now validates successfully against the overrides file. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add GitHub Actions workflow to validate: - rpk-overrides.json against rpk-overrides.schema.json using AJV - property-overrides.json syntax and structure Triggered on PRs and pushes to main that modify these files. This ensures schema and data stay in sync. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The automation only updated the What's new page and produced a change summary when an operator manually supplied a diff version. The cross-repo repository_dispatch trigger (fired by an rpk release) passes no diff version, so it generated docs but never touched What's new and emitted an empty change summary. - Default the diff base to antora.yml's full-version (the currently published version) when none is supplied, so the diff, the --update-whats-new pass, and the PR change summary populate without manual input. Explicit input still overrides; guard against self-diff. - The generator diffs against a committed baseline snapshot (docs-data/rpk-<version>.json) rather than rebuilding the old version, so skip the diff with a clear warning when the snapshot is absent instead of claiming a comparison that did not run. - Build the PR body from the generator's own --summary-file output (generation stats, change tables, command lists, validation report) instead of a hand-rolled jq block, and call out the What's new update. - Write generation log, PR summary, and PR body under runner.temp so the temp files are not committed into the generated PR. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds --ref flag support and --print-tree-based generation needed for rpk v26.1.12+ automation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Runs the new JSON-tree-based generator against rpk v26.1.12 to produce: - 233 AsciiDoc pages in modules/reference/pages/rpk/ - 9 new command pages (rpk connect blobl, connect help, connect mcp-server subcommands, connect template, shadow config, rpk.adoc, rpk cloud mcp-proxy) - docs-data/rpk-v26.1.12.json baseline snapshot for future diffs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove $schema reference (path was wrong and schema is optional) - Remove overrides for commands no longer in rpk v26.1.12: rpk redpanda start, config, config set, mode, tune, tune list, iotune - Remove rpk ai subcommand entries (agent, connection, llm, mcp, model, oauth, oauth-client, version) — these don't appear in the command tree because they require the AI server plugin to be running Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The automation installs rpk plugins (ai, check, connect, oxla) during generation via Docker so all plugin subcommands appear in the command tree. The previous commit incorrectly removed these entries after a local run fell back to native Go build (Docker build step failed), causing plugin subcommands to be absent from the tree. The entries are valid and required for when generation runs with Docker. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
rpk ai oauth* commands don't exist in the tree — the actual commands are rpk ai oauth-provider-* (different naming). Removing invalid override entries. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Re-run with Docker build fixed (golang:1.26.4 image) so all plugins install correctly. Adds 60 rpk-ai command pages and updates existing pages with plugin-aware command tree data. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…k docs - Replace rpai shorthand with rpk ai in all examples (rpai is the plugin binary name) - Fix formatExamples to correctly parse Go CLI example format: indented # comments become plain-text descriptions, consecutive indented command lines share one code block - Add applyTextTransformations helper so replacements are applied to examples content - Fix .trim() stripping indentation from first example line (use replace(/^\n+|\n+$/) instead) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fixes descriptions, flag docs, and examples in rpk-cluster, rpk-security, rpk-profile, rpk-registry, rpk-group, rpk-container, rpk-debug, rpk-plugin, rpk-shadow, rpk-connect, rpk-transform, rpk-generate, and rpk-ai. Notable fixes: - rpk cluster partitions list: fix broken example (was missing 's' in command) - rpk group seek to-file: clarify it's a text file, not JSON - rpk ai *: fix corrupted descriptions and internal ADP references - rpk connect studio sync-schema: remove Benthos product name reference Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… $ backreference corruption String.prototype.replace(search, string) interprets special patterns in the replacement string (e.g. $` means "string before match"). When a flag description contains `$` in backticks (like `^` and `$`), restoring the inline-code placeholder with the literal string caused `$` + backtick to be expanded to the entire preceding text rather than the literal dollar sign. Switch all four placeholder-restore loops (earlyCodeBlocks, inlineCode, xrefs, codeBlocks) to use () => value arrow functions, which bypass the special-pattern expansion entirely. Fixes garbled output in rpk topic list --regex flag description. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
499b1b9 to
a3292b4
Compare
…k docs
Regenerated with generator escaping fixes to prevent AsciiDoc attribute
substitution on CLI format specifiers and path placeholders like {namespace},
{topic}, {hex}, etc. that appear in backtick spans and table cells.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ections override The auto-generator was replacing the entire file, discarding the manually-authored == Example output and == Tuners sections (per-tuner explanations, YAML config keys). Moved that content into rpk-overrides.json as custom sections so it survives future regenerations. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… overrides Restores sections that were replaced by auto-generation without equivalent content: - rpk security acl: Principals/Hosts/Roles/Resources/Operations/Permissions/Management - rpk connect run: Flags table (connect flags not in CLI JSON tree) - rpk redpanda start: Set up a mode (dev-container bundled flags/properties) - rpk redpanda tune: Examples + Related topics - rpk iotune: Example output + Related topics - rpk generate grafana-dashboard: Available dashboards table - rpk cloud byoc install: Example section - rpk container status: Example section - rpk cluster partitions list: Enabled/Disabled concept section Fixes inline code formatting lost in auto-generation: - redpanda_connect / redpanda_cluster scope values now wrapped in backticks via textTransformations.replacements regex - --mode flag: sq/sq_split/mq values in backticks (rpk redpanda tune + tune list) - --state flag: OPEN/CLOSED values in backticks (rpk cluster connections list) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add textTransformations rules to merge split flag+value inline code spans (e.g. `--format` json → `--format json`, `-f json` from bare CLI descriptions, `--mode help`) — two rules handle backtick-wrapped flags (STEP 1 merge) and bare flags from CLI JSON (STEP 3 non-merge) - Add textTransformations rule to wrap bare scope values in inline code (redpanda_connect, redpanda_cluster) - Restore rpk cloud mcp install: Examples section, --client supported values (claude or claude-code), and Suggested reading links - Restore rpk cloud mcp stdio: Examples section and Suggested reading Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- rpk cloud cluster select: add --profile flag description override to replace double-quoted "rpk-cloud" with backtick-wrapped `rpk-cloud`, which was causing __INLINE_CODE_0__ to leak into the generated output - rpk cluster quotas import: split the CLI description into a plain text override + after_description content section for the tabs block; the indented YAML inside ---- in the CLI description was triggering the generator's early code block detection (STEP 1b) before the ---- block protection (STEP 2), resulting in __EARLY_CODE_BLOCK_0__ leaking out Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The autogenerated comment in all rpk doc pages linked to RPK_OVERRIDES_GUIDE.adoc in docs-extensions-and-macros, but the guide now lives in this repo at docs-data/RPK_OVERRIDES_GUIDE.adoc. Updated the URL in the command.hbs template (both local node_modules patch and upstream PR branch) and regenerated all 311 rpk doc files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The CLI description for rpk ai agent a2a had 'json and yaml' as plain text on a continuation line. Added a description override that applies inline code formatting to `json` and `yaml` as format value references. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ng rule Reverts the maintenance-debt approach of duplicating the entire CLI description for `rpk ai agent a2a`. Instead, adds a narrow textTransformations rule that wraps standalone `json`/`yaml` format value words in backticks, handling the CLI help text line-break case where these words appear as continuation-line tokens. The rule uses precise lookbehind/lookahead to avoid false positives: - Excludes after `.` (file extensions like `.json`, `.yaml`) - Excludes after `=` (flag=value like `--format=json`) - Excludes after `/`, `,`, `-`, word chars, backtick (lists, paths, already-wrapped spans) - Excludes before word chars, `/`, `,`, `:`, `-`, backtick Also correctly wraps bare format names in a few published pages (rpk-profile-create, rpk-redpanda-config-set, rpk-registry-schema-create). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Removes the blanket exclusion of 29 rpk ai commands — the exclude mechanism prevents file generation so there was never anything to link from the nav; now these pages are generated and indexable. Re-excludes only `rpk ai connection*` (3 commands) whose CLI descriptions explicitly say "coming soon"; deletes their stale files. Adds modules/reference/partials/rpk-ai-agentic-cluster.adoc with a NOTE admonition about agentic data plane cluster requirements, included in the rpk ai parent command page via after_header content override. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
rpk-connect-studio-pull and rpk-connect-studio-sync-schema no longer exist in the v26.1.12 CLI JSON, so the generator correctly deletes them. Also remove their nav.adoc entries to avoid broken xrefs. The rpk.adoc index gains the new rpk ai entry from the regeneration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Add the infrastructure for automated rpk CLI documentation generation. Does not include generated pages - those will be created by running the workflow after merge.
Dependencies
Requires: redpanda-data/docs-extensions-and-macros#203 - The rpk-docs generator tool
What's included
GitHub Action workflow
.github/workflows/update-rpk-docs.yml- Automated documentation updates:repository_dispatchWriter override system
docs-data/rpk-overrides.json- Customize auto-generated content:Documentation
docs-data/RPK_OVERRIDES_GUIDE.adoc- Complete guide for writersdocs-data/README.adoc- Directory referencedocs-data/rpk-overrides.schema.json- JSON Schema for editor validationExcluded commands
The following commands are excluded from generation (marked "coming soon"):
rpk ai *- 41 commandsrpk oxla- 1 commandUsage after merge
Generate docs via workflow:
v26.2.0ordev)Generate docs locally:
What's new updates and the diff baseline
The workflow updates the What's new page (
modules/get-started/pages/release-notes/redpanda.adoc) and produces the PR change summary from a diff between the version being generated and a previous baseline.diff_versionis supplied (the usual case for therepository_dispatchtrigger from an rpk release), the workflow defaults toantora.yml'sfull-version— the version the docs currently target. An explicitly supplieddiff_versionoverrides it, and a self-diff is skipped.docs-data/rpk-<version>.json; it does not rebuild the old version from source. The snapshot is written and committed on every run, so it is available from the next run onward.Important
The first run is expected to skip the diff. No
docs-data/rpk-v*.jsonsnapshots are committed yet, so the first run for any version logs a::warning::, skips the What's new update, and just establishes the baseline. What's new and the change summary populate automatically from the next run.Generating the
26.1baseline depends on the json-tree flag being available in26.1(backport pending). Once it is, generate the baseline for the patch matchingantora.ymlfull-version(currently26.1.9→docs-data/rpk-v26.1.9.json) so the lookup matches.Test plan
Workflow validates with
actdry runOverrides include excludes for rpk ai and rpk oxla
Schema validates correctly
Diff-base resolution (antora.yml fallback, explicit override, self-diff guard, missing-snapshot skip) verified against the extracted step script
PR-body assembly from the generator's
--summary-fileverified end to endWorkflow validates with
actdry runOverrides include excludes for rpk ai and rpk oxla
Schema validates correctly