Skip to content

fix(ts-document): resolve hyphenated locale tags in markdown tables - #237

Open
tallneil wants to merge 2 commits into
childrentime:mainfrom
tallneil:neil/fix-zhhant-tag-lookup
Open

tallneil wants to merge 2 commits into
childrentime:mainfrom
tallneil:neil/fix-zhhant-tag-lookup

Conversation

@tallneil

@tallneil tallneil commented Sep 22, 2026 •

Copy link
Copy Markdown

Description

Fixes #234. Traditional Chinese argument tables rendered simplified descriptions.

default.ts points the zh-Hant description column at tag.zh-Hant, but the field regex in generateMarkdown.ts captured \w+, which stops at the hyphen. It matched tag.zh and looked up the simplified tag. Only table columns pass through that regex, which is why the table header and the Returns section were already correct.

Two options were considered

Regex only, as proposed in the issue: /tag\.(\w+)/ → /tag\.([\w-]+)/. This regresses. 146 of the 447 documented parameters carry @zh with no @zh-Hant, and an exact-match lookup returns - for every one of them — 148 argument rows lose their description entirely. Wrong-script text replaced by no text is not an improvement.

Regex plus a base-language fallback, taken here: prefer the exact tag, fall back to the tag without the subtag. generate.ts:118 already applies this rule to hook-level tags, so this makes parameter tags behave the same way. Parameters with a translation render traditional; parameters without one keep the text they render today.

regex only regex + fallback
zhHant files changed 89 85
argument rows corrected 252 252
rows blanked 148 0
en / zhHans files touched 0 0

The 146 parameters missing @zh-Hant are a separate content gap, not addressed here.

Commits

Split so the generated diff does not bury the source change:

  • 01a03a4 — the 8-line fix in packages/ts-document/src/generateMarkdown.ts
  • aa57875 — pnpm --filter @reactuses/core gend output, 85 files

Verification

  • pnpm lint clean
  • packages/core typecheck clean
  • packages/core tests: 74 suites, 431 tests passing
  • Regenerated docs from a clean checkout: 85 zhHant files changed, 252 rows corrected, 0 rows blanked, 0 en or zhHans files touched
  • Spot-checked useCounter-README-zhHant.md against the interface source

The packages/ts-document jest suite could not exercise this change — it does not run on main for the reasons in #236. Running gend is the only available verification of generator output.

Building packages/ts-document by hand was needed before gend would run, per #233 / #235.

Type of Change

  • Bug fix
  • New hook
  • Enhancement to existing hook
  • Documentation update
  • Other (please describe)

Checklist

  • I have read the Contributing Guide
  • I have read and understood every line of this diff myself, including any AI-written parts (AI usage policy)
  • My code follows the project's coding style
  • I have added tests for my changes
  • All existing tests pass
  • I have updated the documentation

The tests box is unchecked: the package's suite does not run on main (#236), so there is nowhere to add a regression test yet. Claude Code wrote the fix and this description.

🤖 Generated with Claude Code

tallneil and others added 2 commits September 22, 2026 14:13
The table column schema for `zh-Hant` reads its description from `tag.zh-Hant`, but the field regex captured `\w+`, which stops at the hyphen. It matched `tag.zh` and looked up the simplified tag, so every traditional Chinese argument table rendered simplified descriptions while the header and Returns section were correct.

Allowing hyphens in the capture is not sufficient on its own: 146 of the 447 documented parameters carry `@zh` with no `@zh-Hant`, and an exact-match lookup blanks all of them. The lookup now falls back to the base language, matching the hook-level tag fallback in generate.ts, so untranslated parameters keep the text they render today.

Fixes childrentime#234

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Output of `pnpm --filter @reactuses/core gend` after the tag lookup fix. 85 files, 252 argument descriptions switched from simplified to traditional. No English or simplified Chinese file changes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

Traditional Chinese API docs render argument descriptions in simplified Chinese

1 participant