Skip to content

ci: preserve hand-maintained CLI command-reference index pages on regen#4836

Merged
lennessyy merged 7 commits into
mainfrom
ci/cli-docs-build-validation
Jul 10, 2026
Merged

ci: preserve hand-maintained CLI command-reference index pages on regen#4836
lennessyy merged 7 commits into
mainfrom
ci/cli-docs-build-validation

Conversation

@chaptersix

@chaptersix chaptersix commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

The gen-docs change in temporalio/cli#1112 stops emitting the CLI command-reference index landing pages (command-reference/index.mdx and cloud/index.mdx), because those are hand-maintained on the docs site (custom ordering, the ReleaseNoteHeader component). This workflow does rm -rf docs/cli/command-reference before regenerating, so without a change here those curated pages would be deleted — breaking the sidebars.js references (and the build).

This restores those two files from HEAD after regeneration. (The cp -r that preserves the cloud/ subdirectory is already in place.)

What changed since first review

This PR originally also added a yarn build validation step here plus a standalone validate-cli-docs-build.yml workflow. Per review (thanks @lennessyy) those were dropped:

  • The Vercel preview build is the required check on every PR and already compiles the generated MDX (failing on broken links/anchors), so a second build was redundant.
  • Worse, the build ran before the PR was opened — on failure, no PR would be created and the error would only surface in Actions run history that nobody watches.

So the PR is now just the index-preservation fix.

Companion PR

temporalio/cli#1112 — the gen-docs change this pairs with. They should land together (this workflow relies on that PR's -subdir flag, and the index restore pairs with it no longer emitting those pages).

The CLI command reference is auto-generated MDX. MDX is stricter than
plain Markdown: bare angle-bracket placeholders, JSON-in-braces, and
broken anchors can compile locally yet fail the site build. Nothing
verified the generated output before it landed, so breakage only surfaced
downstream.

Add a real Docusaurus build as the ground-truth check:

- The "CLI Docs Update" workflow now builds the site after regenerating
  the command reference and before opening its PR, so broken generated
  docs never become a PR. Because the site sets onBrokenLinks and
  onBrokenAnchors to 'throw', this also catches broken anchors and links.
- A new "Validate CLI Docs Build" workflow runs the same build on any PR
  that touches docs/cli/**, gating hand edits and the auto-generated PR.

Also preserve the hand-maintained command-reference index.mdx landing
pages (custom ordering, ReleaseNoteHeader component) across regeneration:
gen-docs no longer emits them, so restore them after the rm -rf that
refreshes the generated command pages.
@chaptersix chaptersix requested a review from a team as a code owner July 7, 2026 15:42
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
temporal-documentation Ready Ready Preview, Comment Jul 10, 2026 9:34pm

Request Review

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

📖 Docs PR preview links

This PR does not change any pages in /docs. If you make updates, links to the modified pages will appear here.

@chaptersix chaptersix marked this pull request as draft July 7, 2026 15:43
Comment thread .github/workflows/update-cli-docs.yml Outdated
@chaptersix chaptersix marked this pull request as ready for review July 7, 2026 17:12
The Vercel preview build is the required check on every PR, so it already
compiles the generated CLI MDX (and fails on broken links/anchors) once a
PR is opened. The extra `yarn build` step in this workflow was therefore
redundant, and worse, it ran before the PR was created: if it failed, no
PR would open and the failure would only surface in Actions run history
that nobody watches.

Remove that pre-PR build (and its Node setup / install steps) and the
standalone validate-cli-docs-build.yml workflow. Keep the copy + index
restore, which is the part that's actually needed alongside the gen-docs
change that stops emitting the hand-maintained index pages.
@chaptersix chaptersix changed the title ci: validate generated CLI docs with a Docusaurus build ci: preserve hand-maintained CLI command-reference index pages on regen Jul 7, 2026
Comment thread .github/workflows/update-cli-docs.yml Outdated
# subdirectory produced by -subdir.
rm -rf docs/cli/command-reference
mkdir -p docs/cli/command-reference
cp -r ../cli/dist/docs/* docs/cli/command-reference/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: consider using -R instead of -r

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done — switched to cp -R. Identical on the GNU coreutils runner, but -R is the POSIX-standard flag (-r is deprecated on BSD/macOS), so it's the better convention.

chaptersix added a commit to temporalio/cli that referenced this pull request Jul 8, 2026
…#1112)

## Summary

This consolidates the excellent groundwork in #980, #1076, and #981 into
a single change, and verifies the result against a real Docusaurus
3.10.1 build. Huge thanks to @lennessyy — the approach here is entirely
built on those PRs; this just stitches them together and irons out a few
interactions between them.

gen-docs now escapes the patterns that break Docusaurus MDX (JSX)
compilation, on **every** path that writes a command description
(including the new split paths):

- bare angle-bracket placeholders in prose (e.g.
`<base64-encoded-cert>`, `<key>`) → `\<...\>`
- single-quoted JSON examples (e.g. `'{"a":"b"}'`, `'Key={"a":"b"}'`) →
braces escaped in body text, backticked in option tables
- custom heading IDs (e.g. `## Heading {#id}`) → `{/* #id */}`, the form
that compiles under Docusaurus 3.10 and still produces the custom anchor

Fenced code blocks and inline code spans are left untouched.

It also adds the `-subdir` flag (subcommands of the named command are
written to a subdirectory, e.g. `-subdir cloud` → `cloud/*.mdx`, with
deeper subcommands nested as headings), and a generic auto-generated
notice.

## What changed relative to the existing PRs

All three PRs were on the right track. The differences here are about
how they interact:

- **#1076 (MDX escaping):** kept as the core of this change, including
the `{#id}` → `{/* #id */}` heading conversion — which I confirmed is
exactly right for the 3.10 upgrade (see verification below). Escaping is
now also applied to the `-subdir` split output, so cloud docs get the
same treatment. Re-added unit tests for the escaping logic.
- **#980 (`-subdir`):** kept the split mechanism. Unified the
`encodeJSONExample` regex so it matches both `'{...}'` and `'Key={...}'`
(the standalone-vs-key-value cases the two PRs handled separately).
Intentionally did **not** carry over #980's index-page generation:
`command-reference/index.mdx` and `cloud/index.mdx` are hand-maintained
on the docs site (custom ordering, the `ReleaseNoteHeader` component),
so gen-docs deliberately does not emit them — generating them would
overwrite that curated content. The companion docs PR restores those
files after each regeneration.
- **#981 (generic notice):** folded in — the previous notice pointed at
paths that no longer exist and don't hold for cloud-cli inputs.

## Companion PR
temporalio/documentation#4836
@lennessyy lennessyy enabled auto-merge (squash) July 10, 2026 21:33
@lennessyy lennessyy merged commit 21ab1d7 into main Jul 10, 2026
11 checks passed
@lennessyy lennessyy deleted the ci/cli-docs-build-validation branch July 10, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants