Skip to content

docs(useSyntaxTheme): add hook docs and a keyword color example block - #11236

Merged
cixzhang merged 4 commits into
meta:mainfrom
popsiclelmlm:docs/use-syntax-theme
Nov 13, 2026
Merged

cixzhang merged 4 commits into
meta:mainfrom
popsiclelmlm:docs/use-syntax-theme

Conversation

@popsiclelmlm

Copy link
Copy Markdown
Contributor

Part of #11207

Reader impact

A builder cannot find useSyntaxTheme: astryx hook does not return it, and the hook has no docsite page or runnable example. After this change the hook has a page, astryx hook and astryx search return it, and astryx template useSyntaxThemeHookUsage copies the example.

Source of truth

useSyntaxTheme in packages/core/src/theme/syntax/SyntaxTheme.tsx returns null without a SyntaxTheme, and otherwise the theme name, mode, and token colors. architecture:knowledge-contracts INV28.

Correction

Adds a HookDoc next to the syntax theme, and blocks/components/SyntaxTheme/useSyntaxThemeHookUsage (exampleFor: 'useSyntaxTheme'). The block paints const with token('keyword') inside GitHub Light.

Evidence

use-syntax-theme-hook-usage.test.tsx expects the keyword fill to be the GitHub Light keyword color.

Scope

Components: SyntaxTheme, useSyntaxTheme

  • This PR changes documentation only, or names every necessary generated artifact.
  • Runtime, API, visual, and policy changes were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

vitest run packages/cli/api/template/use-syntax-theme-hook-usage.test.tsx

Hook docs for `useSyntaxTheme`, so `astryx hook useSyntaxTheme` and `astryx search` return it, and a `useSyntaxTheme — Keyword color` example block: the word const painted with the keyword color of the GitHub Light syntax theme.
@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 13, 2026 1:56pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 13, 2026, 2:10 PM UTC

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review labels Nov 11, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 11, 2026
@popsiclelmlm
popsiclelmlm marked this pull request as ready for review November 11, 2026 13:51

@astracat-bot astracat-bot Bot 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.

Changes are still needed: the new useSyntaxTheme page and example are picked up by astryx hook, astryx search and astryx template, but three small fixes remain.

  • The example draws nothing under right-to-left, because <text x="0"> inherits direction: rtl and const renders left of its 120 px SVG, where it is clipped; add direction="ltr" to the <text> in useSyntaxThemeHookUsage.tsx.
  • The hook doc's mode row (useSyntaxTheme.doc.mjs line 27, and the dense text at line 73) presents following prefers-color-scheme as the hook's contract, while component:SyntaxTheme FR2 says the hook follows the nearest Theme's mode and lists the operating-system read as a known gap, so please say that under a forced <Theme mode> the colors can differ from the code around them.
  • Line 5 of useSyntaxThemeHookUsage.tsx is longer than Prettier's 80 columns, so the Lint workflow's changed-file formatting check will fail; run pnpm exec prettier --write on the file.

One smaller point: data-syntax-keyword only serves the test, but astryx template useSyntaxThemeHookUsage copies it into every app, so the test can select svg[role="img"] text instead.

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec c859461

…ract

Right-to-left layout clipped the sample word. The doc now says a forced Theme mode can disagree with nearby code, because the hook still reads the operating-system color scheme.
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · c6e70e6

Storybook · Sandbox · built from this PR's head

Package size:

  • @astryxdesign/cli 4.23 MB packed (+324 B); no new dependencies
  • @astryxdesign/core 7.52 MB packed (+666 B); no new dependencies

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec cc085b2

@astracat-bot astracat-bot Bot 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.

Approved pending CI: CI has not run on this head yet, so a maintainer needs to add the ci:run label, which takes effect on the next push, a close and reopen, or marking the pull request ready.

The useSyntaxTheme hook doc and the keyword color example match what the hook does, and the three earlier points are fixed: the example keeps const inside its frame on right-to-left pages, the mode description names the forced-mode limit, and the import is formatted.

Claims and files checked
  • Changeset: astryx hook useSyntaxTheme returns the new hook doc. Verified: hook discovery finds packages/core/src/theme/syntax/useSyntaxTheme.doc.mjs, and the base has no doc for the hook.
  • Changeset: astryx search returns the hook. Verified: search gathers hooks through the same discovery and reads the doc's keywords and usage.
  • Changeset: the example paints const in GitHub Light's keyword color. Verified: useSyntaxThemeHookUsage.tsx:22 reads token('keyword') under githubLight, whose keyword is #cf222e.
  • Description: before this change the hook had no doc page and no runnable example. Verified: the base has no hook doc and no block that names the hook.
  • Description: astryx template useSyntaxThemeHookUsage copies the example. Verified: block templates are looked up by their file name.
  • Description: the hook returns null without a SyntaxTheme, and otherwise the theme name, mode and token colors. Verified: SyntaxTheme.tsx:98-150.
  • Description: the test expects GitHub Light's keyword fill. Verified: use-syntax-theme-hook-usage.test.tsx:51; it runs once CI runs.
  • Description: documentation only, with the generated route entries included and no runtime, API or visual change. Verified.
  • .changeset/hook-doc-use-syntax-theme.md: clear
  • apps/sandbox/scripts/next-export-routes.json: clear
  • internal/shadcn-registry/routes.lock.json: clear
  • packages/cli/api/template/use-syntax-theme-hook-usage.test.tsx: clear
  • packages/cli/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs: clear
  • packages/cli/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx: clear
  • packages/core/src/theme/syntax/useSyntaxTheme.doc.mjs: clear

Automated review (maintainer link)

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 13, 2026
@cixzhang
cixzhang marked this pull request as draft November 13, 2026 12:31
@cixzhang
cixzhang marked this pull request as ready for review November 13, 2026 12:32
@cixzhang cixzhang removed the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 13, 2026
…merge

The useSyntaxTheme doc now records defineSyntaxTheme and presets, so their
fallback entries open it, and the docs index has one more entry, so the
icon-set search reports 397 results. Regenerated with vitest -u.
@cixzhang
cixzhang marked this pull request as draft November 13, 2026 13:47
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec c6e70e6

@astracat-bot astracat-bot Bot 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.

Approved pending CI: CI has not run on this head yet. The pull request is still a draft from a fork, so CI runs once it is marked ready for review and carries the ci:run label, which a maintainer adds.

The useSyntaxTheme hook doc and the keyword color example match what the hook does. astryx hook, astryx search and astryx template now find them, the example takes its color from the hook, and const stays inside its frame on right-to-left pages. The regenerated resolution fixture and search goldens match what the CLI now produces.

Claims and files checked
  • Changeset: a docs patch for the core and CLI packages. Verified: the changeset check passes, and both packages have changed files.
  • Changeset and description: astryx hook useSyntaxTheme returns the new hook doc. Verified: it prints the page on this head; on main it answers "No hook named".
  • Changeset and description: astryx search returns the hook. Verified: a search for useSyntaxTheme returns the hook and the example block on this head, and neither on main.
  • Changeset and description: the example paints const in GitHub Light's keyword color. Verified: useSyntaxThemeHookUsage.tsx:22 reads token('keyword') under githubLight (keyword #cf222e), and the rendered fill is rgb(207, 34, 46).
  • Description: before this change the hook had no doc page and no runnable example. Verified: main's docs data has no entry for the hook, and the example-coverage report lists it as missing both.
  • Description: the hook now has a docsite page. Verified: the docs data generator emits the hook entry on this head, and the preview deployment succeeded.
  • Description: astryx template useSyntaxThemeHookUsage copies the example. Verified: it resolves the block and prints its source on this head (a path argument writes it into the project); on main the template is unknown.
  • Description: the hook returns null without a SyntaxTheme, and otherwise the theme name, mode and token colors. Verified: SyntaxTheme.tsx:98-150.
  • Description: the doc sits next to the syntax theme, and the block names the hook as its example target. Verified: packages/core/src/theme/syntax/useSyntaxTheme.doc.mjs and useSyntaxThemeHookUsage.doc.mjs:6.
  • Description: the test expects GitHub Light's keyword fill. Verified: use-syntax-theme-hook-usage.test.tsx:51, and the test passes.
  • Description: documentation only, with every generated file included and no runtime, API or visual change. Verified: the route lock, sandbox route list, resolution fixture and search goldens match their checks, and the public API surface is unchanged.
  • Description: no internal context. Verified: no internal names or new links in the changes, commits, title or body.
  • .changeset/hook-doc-use-syntax-theme.md: clear
  • apps/sandbox/scripts/next-export-routes.json: clear
  • internal/shadcn-registry/routes.lock.json: clear
  • packages/cli/api/component/__fixtures__/resolutions/modules.txt: clear
  • packages/cli/api/template/use-syntax-theme-hook-usage.test.tsx: clear
  • packages/cli/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs: clear
  • packages/cli/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx: clear
  • packages/cli/test/__golden__/no-icon-set/search-icon-set.json: clear
  • packages/cli/test/__golden__/no-icon-set/search-icon-set.txt: clear
  • packages/core/src/theme/syntax/useSyntaxTheme.doc.mjs: clear

Automated review (maintainer link)

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 13, 2026
@cixzhang
cixzhang marked this pull request as ready for review November 13, 2026 14:15
@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Nov 13, 2026
@cixzhang
cixzhang merged commit 4da09b8 into meta:main Nov 13, 2026
142 checks passed

This branch was successfully deployed

1 active deployment
Preview — c6e70e6a Deployed Nov 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants