Skip to content

[docs-infra] Support metadata declared as named constants - #1713

Merged
Janpot merged 6 commits into
masterfrom
worktree-docs-infra-constant-groups
Aug 25, 2026
Merged

[docs-infra] Support metadata declared as named constants#1713
Janpot merged 6 commits into
masterfrom
worktree-docs-infra-constant-groups

Conversation

@Janpot

@Janpot Janpot commented Jul 24, 2026

Copy link
Copy Markdown
Member

Metadata files (*DataAttributes.ts, *CssVars.ts) had to declare their members as a string enum named after the file. This adds named literal constants as an equivalent form, so application bundlers can inline and tree-shake the values instead of retaining a runtime enum object. Both forms are normalized to a single constant group named after its file, so everything downstream — component matching, table rendering, markdown generation — is untouched.

Unblocks mui/base-ui#5248, which converts every Base UI metadata file to constants. Verified with a new data-attr-esm demo whose generated types.md table is byte-identical to the enum demo's, and a full docs:validate that regenerated nothing across the existing 62 types files.

@code-infra-dashboard

code-infra-dashboard Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploy preview

Bundle size

Total Size Change: 0B(0.00%) - Total Gzip Change: 0B(0.00%)
Files: 69 total (0 added, 0 removed, 0 changed)

Show details for 69 more bundles

@mui/internal-docs-infra/abstractCreateDemoparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/abstractCreateDemoClientparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/abstractCreateStreamparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/abstractCreateTypesparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/ChunkProviderparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/cliparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeControllerContextparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeExternalsContextparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeHighlighterparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeHighlighter/errorsparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeHighlighter/typesparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CodeProviderparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CoordinatedLazyparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/CoordinatedLazy/typesparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/createDemoDataparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/createDemoData/typesparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/createSitemapparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/createSitemap/typesparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCodeparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCodeWindowparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCoordinatedparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCopierparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useCrossTabStateparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useDemoparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useDemoControllerparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useErrorsparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useLocalStorageStateparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/usePreferenceparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useScrollAnchorparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useSearchparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useSearch/typesparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useStreamparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useStream/typesparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useTypeparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useTypesparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/useUrlHashStateparsed: 0B(0.00%) gzip: 0B(0.00%)
@mui/internal-docs-infra/withDocsInfraparsed: 0B(0.00%) gzip: 0B(0.00%)
addLineGuttersparsed: 0B(0.00%) gzip: 0B(0.00%)
BuildEngineparsed: 0B(0.00%) gzip: 0B(0.00%)
CodeHighlighterChunkparsed: 0B(0.00%) gzip: 0B(0.00%)
CodeHighlighterClientparsed: 0B(0.00%) gzip: 0B(0.00%)
CodeInitialSourceLoaderparsed: 0B(0.00%) gzip: 0B(0.00%)
CodeSourceLoaderparsed: 0B(0.00%) gzip: 0B(0.00%)
compileCssWithPostcssparsed: 0B(0.00%) gzip: 0B(0.00%)
createFrameparsed: 0B(0.00%) gzip: 0B(0.00%)
createParseSourceWorkerClientparsed: 0B(0.00%) gzip: 0B(0.00%)
EditingEngineparsed: 0B(0.00%) gzip: 0B(0.00%)
embedTransformsparsed: 0B(0.00%) gzip: 0B(0.00%)
enhanceCodeEmphasisparsed: 0B(0.00%) gzip: 0B(0.00%)
findExpandingRangesparsed: 0B(0.00%) gzip: 0B(0.00%)
getHastTextContentparsed: 0B(0.00%) gzip: 0B(0.00%)
grammarLoadersparsed: 0B(0.00%) gzip: 0B(0.00%)
grammarsparsed: 0B(0.00%) gzip: 0B(0.00%)
isFrameSpanparsed: 0B(0.00%) gzip: 0B(0.00%)
loadIsomorphicCodeVariantparsed: 0B(0.00%) gzip: 0B(0.00%)
parseSourceparsed: 0B(0.00%) gzip: 0B(0.00%)
rolldown-runtimeparsed: 0B(0.00%) gzip: 0B(0.00%)
source.cssparsed: 0B(0.00%) gzip: 0B(0.00%)
source.jsparsed: 0B(0.00%) gzip: 0B(0.00%)
source.jsonparsed: 0B(0.00%) gzip: 0B(0.00%)
source.mdxparsed: 0B(0.00%) gzip: 0B(0.00%)
source.shellparsed: 0B(0.00%) gzip: 0B(0.00%)
source.tsparsed: 0B(0.00%) gzip: 0B(0.00%)
source.tsxparsed: 0B(0.00%) gzip: 0B(0.00%)
source.yamlparsed: 0B(0.00%) gzip: 0B(0.00%)
text.html.basicparsed: 0B(0.00%) gzip: 0B(0.00%)
text.mdparsed: 0B(0.00%) gzip: 0B(0.00%)
TransformEngineparsed: 0B(0.00%) gzip: 0B(0.00%)
transpileSourceparsed: 0B(0.00%) gzip: 0B(0.00%)

Details of bundle changes

Performance

Total duration: 15.17 ms -0.20 ms(-1.3%) | Renders: 5 (+0) | Paint: 59.27 ms +0.32 ms(+0.5%)

Test Duration Renders
DataGrid mount with paint timing 1.98 ms ▼-0.73 ms(-27.0%) 1 (+0)
Counter click 4.11 ms -0.09 ms(-2.1%) 2 (+0)

5 tests within noise — details

Metric alarms

Test Metric Change
Counter click bench:paint 🔺 +3.60 ms

Check out the code infra dashboard for more information about this PR.

@Janpot

Janpot commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

@claude review

@github-actions

This comment has been minimized.

@Janpot
Janpot force-pushed the worktree-docs-infra-constant-groups branch 2 times, most recently from 3b8b486 to 6a1faf9 Compare July 24, 2026 14:52
@Janpot Janpot added the scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305). label Jul 24, 2026
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jul 27, 2026
@Janpot
Janpot force-pushed the worktree-docs-infra-constant-groups branch from d37ff26 to 97e8235 Compare July 28, 2026 08:09
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jul 28, 2026
@Janpot

Janpot commented Jul 30, 2026

Copy link
Copy Markdown
Member Author

@claude review

@github-actions

This comment was marked as resolved.

Janpot added 4 commits August 18, 2026 19:16
Metadata files declared their data attributes and CSS variables as a
string enum named after the file. Recognize named literal constants as
an equivalent form so application bundlers can inline and tree-shake the
values, and normalize both to a single constant group named after its
file.
Replace the console.warn with a thrown error when a metadata file mixes
non-constant exports with constants — the group replaces the file's
exports wholesale, so a stray export (including a constant widened off
its literal type) would be documented nowhere. Failing the build is
better than dropping it silently.

Inline parseSources into transformConstantGroup.test.ts and drop
parseSources.testUtils.ts, so the PR doesn't introduce a .testUtils.ts
file that the build ships as dead code.
@Janpot
Janpot force-pushed the worktree-docs-infra-constant-groups branch from 4964da8 to 725e9cd Compare August 18, 2026 17:17
The demo test added here still used the path.dirname(...).split('/app') snippet
that #1795 replaced everywhere with appRoute(import.meta.url); bring it in line.
@Janpot
Janpot marked this pull request as ready for review August 18, 2026 18:12
@Janpot
Janpot requested review from a team and jjenzz August 18, 2026 18:12
@jjenzz
jjenzz requested a review from atomiks August 24, 2026 10:23
@atomiks

This comment has been minimized.

@Janpot

Janpot commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

Fixed the architecture wording in a9b7274.

The two silent misclassification cases are real, but the root cause sits in the extractor: it emits identical literal nodes for export type X = 'x' and an annotated constant export const x: X = 'x', so any fix here would be a type-shape heuristic that fails on exactly those inputs. Opened michaldudak/typescript-api-extractor#226 to expose the declaration spaces on exports; the transformConstantGroup tightening is prepared in #1812, blocked on that PR landing in a release.

@Janpot
Janpot enabled auto-merge (squash) August 25, 2026 10:37
@Janpot
Janpot merged commit ad1f569 into master Aug 25, 2026
16 checks passed
@Janpot
Janpot deleted the worktree-docs-infra-constant-groups branch August 25, 2026 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants