Skip to content

fix(docs): escape angle-bracket placeholders in generated docs - #60

Merged
cooper (czxtm) merged 1 commit into
mainfrom
fix/docs-mdx-escaping
Sep 23, 2026
Merged

cooper (czxtm) merged 1 commit into
mainfrom
fix/docs-mdx-escaping

Conversation

@czxtm

Copy link
Copy Markdown
Member

Deploy Docs has failed on every main run since Sep 7. The docs generator (docgen) dropped <name> placeholders from option descriptions because it parsed them as HTML tags. A later hand-edit (d3dd7aa) put one back into reference/modules.mdx unescaped, and MDX treats it as an unclosed JSX tag.

The fix is in the generator:

  • Placeholders are kept and written escaped as \<name\>.
  • It also fixes two frontmatter bugs that a full regeneration would hit. MDX escaping no longer rewrites the YAML frontmatter, and CLI descriptions are quoted (with backslashes escaped).
  • There are 2 new end-to-end docgen tests that fail on the old generator.
  • 11 generated pages get a one-line change each, matching the fixed generator's output exactly.

Verification by the implementer:

  • In the devshell, gofmt and vet are clean, go build passes, and all 26 docgen tests pass.
  • bun run build in apps/docs (Deploy Docs' build step) builds all 495 pages.
  • The original modules.mdx reproduces the CI error exactly.

Refs stackpanel-thq.23

Deploy Docs on main has failed since 2026-09-07 because
reference/modules.mdx line 315 has a bare `<name>`, which MDX parses as
an unclosed JSX tag.

docgen's formatDescription parses option descriptions with goldmark and
dropped anything goldmark saw as inline HTML, so "stackpanel.doctor.<name>."
came out as "stackpanel.doctor..". d3dd7aa put the placeholder back by
hand, unescaped. Keep inline HTML as literal text instead: nixos-render-docs
renders option descriptions with HTML disabled, so these are placeholders,
not tags, and the existing escapeMDX pass writes them as `\<name\>`.

A full regeneration would still break the build in two places, both in
frontmatter, which the docs build parses as YAML rather than MDX:
- escapeMDX also rewrote the frontmatter, turning `{` in a quoted module
  description into `\{`, an invalid YAML escape. It now skips frontmatter.
- CLI pages wrote cmd.Short unquoted, and `stack setup`'s "Reconcile the
  project: report, confirm, apply" is invalid YAML (the checked-in page
  had been hand-edited to avoid it). CLI descriptions now go through
  escapeYAMLString, which now also escapes backslashes.

Generated pages: only the lines these fixes change are updated (5
reference, 6 CLI), each identical to the fixed generator's output. A full
`generate-docs` run is left out because the checked-in pages have drifted
from the option definitions (26 files removed, 52 added, 50 changed),
which needs its own change. That full output now builds.

Refs: stackpanel-thq.23
@github-actions

Copy link
Copy Markdown
Contributor

Preview deployed to pr-60 — https://pr-60.stackpanel.com

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Docs preview pr-60 has been destroyed.

@czxtm
cooper (czxtm) merged commit da837c1 into main Sep 23, 2026
14 checks passed
@czxtm
cooper (czxtm) deleted the fix/docs-mdx-escaping branch September 23, 2026 14:11
@linear-code

linear-code Bot commented Sep 23, 2026

Copy link
Copy Markdown

ENG-843

This branch was successfully deployed

2 active deployments
pr-60 — ba83bfce Deployed Sep 23, 2026 by czxtm via deploy #215
docs-preview — ba83bfce Deployed Sep 23, 2026 by czxtm via deploy #200
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.

1 participant