Skip to content

[docs-infra] Render one experiment demo through docs-infra - #48961

Draft
brijeshb42 wants to merge 13 commits into
mui:masterfrom
brijeshb42:di-migration-bootstrap
Draft

brijeshb42 wants to merge 13 commits into
mui:masterfrom
brijeshb42:di-migration-bootstrap

Conversation

@brijeshb42

@brijeshb42 brijeshb42 commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Adds @mui/internal-docs-infra to the docs and puts one experiment demo on it. Everything else stays on the current pipeline.

A demo opts in from its marker:

{{"demo": "DemoInDocsDocsInfra.js", "docsInfra": true, "defaultCodeOpen": true, "disableLiveEdit": true}}

The loader precomputes the source graph only for those demos, and RichMarkdownElement renders DocsInfraDemo instead of Demo component. /experiments/docs/docs-infra has both kinds on one page.

Markdown decides which demos migrate; docsInfraDemoFlags decides what that means, currently source loading and highlighting and nothing else. The demo still renders the same bundled component, keeps its toolbar, and its JS/TS toggle still reads the sibling files. Nothing from docs-infra reaches the browser — it's build-time only.

Screenshot 2026-08-13 at 7 13 56 PM

So can be merged into master without worrying about affecting end-user.

Adds @mui/internal-docs-infra to the docs package with a version policy. Demo rendering is unchanged.
@brijeshb42 brijeshb42 added the scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305). label Aug 13, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Aug 13, 2026 •

Copy link
Copy Markdown

Deploy preview

Bundle size

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes


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

@brijeshb42 brijeshb42 changed the title [docs] Render one experiment demo through docs-infra Aug 13, 2026
@brijeshb42
brijeshb42 requested a review from a team August 14, 2026 06:49
@brijeshb42
brijeshb42 marked this pull request as ready for review August 14, 2026 06:49
Adds a per-demo pipeline resolver and an adapter component that owns future docs-infra imports. The allowlist is empty, so every demo keeps rendering through the legacy pipeline.
Moves the allowlist and resolver into @mui/internal-markdown so the build and the runtime read one source of truth without a package cycle.
The Markdown loader branches per marker and precomputes the docs-infra source graph for allowlisted demos only. The selected experiment demo now displays the source docs-infra loaded, still highlighted by Prism, so the page is unchanged.
@brijeshb42
brijeshb42 force-pushed the di-migration-bootstrap branch 2 times, most recently from 7ba05a9 to 9bf420a Compare August 14, 2026 07:14
The loader emits the docs-infra highlighted markup, HighlightedCode accepts pre-highlighted HTML, and the adapter maps the Starry Night scope classes to the existing okaidia palette. Legacy demos are unaffected.
Replaces the page-and-demo allowlist with a "docsInfra": true marker option. The loader collects opted-in demos while scanning markers and the runtime reads the same marker, so the opt-in lives at the call site and marker edits invalidate the loader cache. The capability set stays in code behind a master switch.
The capability set is the single control: the loader precomputes only when source loading is enabled, and turning every capability off returns migrated demos to the legacy rendering.
Replaces the local tarball in docs and @mui/internal-markdown with the pkg.pr.new canary from mui/mui-public#1773.
getHastTextContent and toHtml take HAST nodes, but VariantSource also covers strings and the serialized forms. Checks the shape at runtime instead of assuming the requested output.
Demos keep JSX in their .js files, which the plain JavaScript grammar leaves unclassified. Passes the jsx language to docs-infra and colours JSX element names like the legacy pipeline does.
@brijeshb42
brijeshb42 force-pushed the di-migration-bootstrap branch from 9bf420a to b7044bc Compare August 14, 2026 07:30
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Aug 17, 2026

@silviuaavram silviuaavram left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

did a first pass. investigated some issues raised by codex.

<DemoCodeViewer
key={index}
code={tab.raw}
highlightedHtml={index === 0 ? demo.highlightedHtml : undefined}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In http://localhost:3000/experiments/docs/docs-infra/#docs-infra-transform I've added some typescript related stuff to the demo code, and it shows only the js code, regardless of the active js/ts tab. the copy code button works fine.

this.addDependency(fileURLToPath(dependency));
});

demos[demoName].docsInfra = docsInfra;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

raised by codex, apparently we are sending more data than we should. we only need source and html. so we can string everything else like externals and dependencies. feel free to double check.

@brijeshb42
brijeshb42 marked this pull request as draft August 18, 2026 08:42

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: out-of-date The pull request has merge conflicts and can't be merged. scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305).

2 participants