Skip to content

fix(docs): escape bare < for Fern MDX + harden MDX checker#1367

Merged
mchmarny merged 6 commits into
mainfrom
fix/fern-mdx-escape-lt
Jun 15, 2026
Merged

fix(docs): escape bare < for Fern MDX + harden MDX checker#1367
mchmarny merged 6 commits into
mainfrom
fix/fern-mdx-escape-lt

Conversation

@mchmarny

@mchmarny mchmarny commented Jun 15, 2026

Copy link
Copy Markdown
Member

Summary

Unblock the Fern docs publish (MDX) and close the two gaps in the local MDX checker that let the breakage reach the release tag.

Motivation / Context

Fern parses docs as MDX, which treats a bare < followed by a name-start character as a JSX tag. landed <30 s in docs/contributor/inference-perf-fluctuation.md failed the v0.15.0-rc2 Publish Fern Docs job:

Failed to parse ../docs/contributor/inference-perf-fluctuation.md: Unexpected character `3` (U+0033) before name ...

There is already a local gate for this — tools/check-docs-mdx, exposed as make check-docs-mdx and wired into make lint (hence make qualify) and the PR-CI fern-docs-ci.yaml. It should have caught both this and the earlier recipe-health.md breakage, but had two gaps:

  1. Digit gap: the bare-tag check only matched < before a letter (<[a-zA-Z]), so <30 s / <13% slipped through.
  2. Stale exclusion: recipe-health.md was excluded (on a now-obsolete VitePress HTML-marker assumption) — which is why its HTML comment reached the rc1 publish.

(fern check does not catch MDX parse errors, so publish was the first place these surfaced.)

Fixes: N/A
Related: https://github.com/NVIDIA/aicr/actions/runs/27557526326

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Documentation update
  • Build/CI/tooling

Component(s) Affected

  • Docs/examples (docs/, examples/)
  • Other: docs MDX checker (tools/check-docs-mdx, make check-docs-mdx)

Implementation Notes

Three commits:

  1. Doc fix — escape <30 s as \<30 s (literal < in MDX and GitHub CommonMark). <13% on line 162 is inside a code fence, so MDX leaves it literal — consistent with the error pointing at <30 (char 3).
  2. Checker: digit gap — broaden the bare-tag match to <[0-9a-zA-Z], and strip \< / \> individually so a lone \< escape doesn't false-positive.
  3. Checker: exclusion + MDX comments — drop the recipe-health.md exclusion (it is Fern-published and now uses MDX-safe {/* ... */} markers), and teach the checker to treat {/* ... */} comments (single- and multi-line) as safe so the valid markers don't trip the bare-brace check while real hazards on the same line are still caught. container-images.md stays excluded (HTML markers, not Fern-published).

Testing

make check-docs-mdx     # OK on the full tree (now including recipe-health.md)
# probes: bare `<30 s` / `<13%` and `{foo}` are flagged; `\<...\>`, backticked
# `<...>`, and `{/* ... */}` comments are treated as safe.

A sweep of all 31 Fern-nav docs found <30 s to be the only remaining bare-< prose hazard and no stray { hazards beyond valid MDX comments.

Risk Assessment

  • Low — one-char doc escape plus regex/handling fixes in a lint tool; easy to revert.

Rollout notes: With both checker gaps closed, make lint / make qualify now catch this class pre-merge — no separate pre-push hook needed.

Checklist

  • Tests pass locally (make test with -race) — N/A
  • Linter passes (make check-docs-mdx)
  • I did not skip/disable tests to make CI green
  • I updated docs if user-facing behavior changed
  • Changes follow existing patterns in the codebase
  • Commits are cryptographically signed (git commit -S)

Fern parses docs as MDX, which treats a bare `<` followed by a name
character as the start of a JSX tag. `landed <30 s` tripped the
v0.15.0-rc2 Publish Fern Docs job ("Unexpected character `3` before
name"). Escape it as `\<30 s`, which renders as a literal `<` in both
MDX and GitHub CommonMark. A sweep of all 31 Fern-nav docs found this
to be the only remaining bare-`<` prose hazard (the `<13%` on line 162
is inside a fenced code block, which MDX leaves literal).
@mchmarny mchmarny requested a review from a team as a code owner June 15, 2026 15:37
@mchmarny mchmarny added the theme/ci-dx CI pipelines, developer experience, and build tooling label Jun 15, 2026
@mchmarny mchmarny self-assigned this Jun 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: efa27874-e338-4fab-9714-f0d4344b80d6

📥 Commits

Reviewing files that changed from the base of the PR and between c112c43 and 57ff768.

📒 Files selected for processing (1)
  • tools/check-docs-mdx

📝 Walkthrough

Walkthrough

A single sentence in docs/contributor/inference-perf-fluctuation.md is corrected within the RTX PRO 6000 cold-start/serve-readiness timeout analysis section, clarifying that morning runs completed under the 30-second readiness probe threshold and passed, while afternoon runs exceeded approximately 42 seconds and failed. The PR also enhances the tools/check-docs-mdx MDX safety checker by adding explicit support for MDX comment syntax ({/* ... */}), broadening digit-prefixed angle-bracket placeholder detection, removing recipe-health.md from the exclusion list (while keeping container-images.md excluded), updating the tool's documentation, and refreshing the Makefile help text to reflect the new checks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • NVIDIA/aicr#1365: Updates tools/check-docs-mdx to recognize MDX block comments ({/* ... */}) and include recipe-health.md in checks after switching its splice markers from HTML to MDX syntax.
  • NVIDIA/aicr#1304: Earlier changes to tools/check-docs-mdx that handled recipe-health.md exclusion logic differently.

Suggested labels

area/ci, size/S

Suggested reviewers

  • ArangoGutierrez
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: escaping bare < characters for Fern MDX compatibility and improving the MDX checker tool.
Description check ✅ Passed The description thoroughly explains the Fern MDX parse error, the documentation fix, and the checker improvements needed to prevent future breakage.
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
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/fern-mdx-escape-lt

Comment @coderabbitai help to get the list of available commands and usage tips.

tools/check-docs-mdx is the local + PR-CI guard for MDX-unsafe markdown,
but its bare-tag check only matched `<` followed by a letter
(`<[a-zA-Z]`). MDX equally rejects `<` before a digit, so `<30 s` and
`<13%` slipped through and only surfaced when `fern generate` ran on the
release tag (v0.15.0-rc2). Broaden the match to `<[0-9a-zA-Z]`.

Also fix the escape-stripping: it only removed paired `\<...\>`, so a
lone `\<30 s` would now false-positive. Strip `\<` and `\>` individually
instead, matching the documented `\<name\>` escape guidance.

Verified: the checker passes the current tree and flags a bare `<30 s` /
`<13%` while treating `\<...\>` and backticked `<...>` as safe.
@github-actions github-actions Bot added size/S and removed size/XS labels Jun 15, 2026
@mchmarny mchmarny changed the title fix(docs): escape bare < in inference-perf-fluctuation for Fern MDX fix(docs): escape bare < for Fern MDX + close checker gap Jun 15, 2026
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Coverage Report ✅

Metric Value
Coverage 77.1%
Threshold 75%
Status Pass
Coverage Badge
![Coverage](https://img.shields.io/badge/coverage-77.1%25-green)

No Go source files changed in this PR.

tools/check-docs-mdx excluded recipe-health.md on the assumption it
carried HTML-comment splice markers VitePress needs. That file is now
Fern-published and uses MDX-safe {/* ... */} markers, so the exclusion
was a blind spot (it is why the recipe-health.md HTML comment reached
the rc1 publish). Drop the exclusion and teach the checker to treat
{/* ... */} comments (single- and multi-line) as safe, so the valid
markers don't false-positive the bare-brace check while real hazards
after a comment on the same line are still caught.

container-images.md stays excluded (HTML markers, not Fern-published).
Help text for `make check-docs-mdx` updated to list all checks.
@mchmarny mchmarny requested a review from a team as a code owner June 15, 2026 15:45
@mchmarny mchmarny changed the title fix(docs): escape bare < for Fern MDX + close checker gap fix(docs): escape bare < for Fern MDX + harden MDX checker Jun 15, 2026
The greedy gsub(/{/*.*\*/}/) span from the first {/* to the last */} on
a line, deleting any real MDX hazard sitting between two separate
comments (e.g. `{/* a */} <30 s {/* b */}`) before the bare-<tag>,
brace, autolink, and HTML-comment checks ran — so exactly the
Fern-breaking pattern this tool guards against could evade it. Strip one
{/* ... */} segment at a time, preserving text between comments; an
unterminated {/* still opens the multi-line region.

@ArangoGutierrez ArangoGutierrez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pulled the head tree and ran the new checker end to end. It does what the description says:

  • Passes clean on the full docs tree, so the digit broadening doesn't add false positives.
  • Catches a bare <30 s where the old <[a-zA-Z] regex missed it.
  • \<30 s, backticked `<30 s`, and {/* ... */} (single and multi-line) all pass; a hazard after a same-line or multi-line comment close is still flagged.
  • recipe-health.md's license header and BEGIN/END splice markers are handled now that it's scanned.

Two latent edge cases in the comment handling, both inline below. Neither is hit by the current tree, and both are the same gap-class this PR closes, so I'd treat them as a fast follow rather than a blocker.

Separately, there's no regression test for the checker itself. A small testdata/ of pass/fail snippets would lock the behavior in and would have caught both edges below. Happy to send that plus the fixes as a follow-up.

Nothing here blocks unblocking the publish.

Comment thread tools/check-docs-mdx Outdated
Comment thread tools/check-docs-mdx Outdated
@github-actions github-actions Bot added size/M and removed size/S labels Jun 15, 2026
mchmarny and others added 2 commits June 15, 2026 12:03
Two fixes to tools/check-docs-mdx, both raised in review of #1367:

1. Strip inline code spans BEFORE the MDX-comment detection. Previously a
   backticked, unterminated `{/*` (e.g. prose showing `{/*` as an example)
   opened a bogus multi-line comment region that swallowed every following
   line until EOF/`*/}`, hiding real hazards like a bare `<30 s`.

2. Wrap the per-file awk in the `if` condition. The script runs under
   `set -e`, and the awk exits 1 on a hazard, so the scan aborted at the
   first offending file and silently skipped the rest (the violations
   footer never printed). It still gated (non-zero exit) but under-reported;
   now every offending file is listed.

Verified: full docs tree passes; a multi-file probe reports both a
two-comments-on-one-line hazard and a backticked-`{/*` hazard, with the
footer.
@mchmarny mchmarny merged commit 915ed66 into main Jun 15, 2026
30 of 31 checks passed
@mchmarny mchmarny deleted the fix/fern-mdx-escape-lt branch June 15, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs size/M theme/ci-dx CI pipelines, developer experience, and build tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants