Warning
This is an internal project, and is not intended for public use. No support or stability guarantees are provided.
This guide covers how to set up your development environment and contribute to @mui/internal-docs-infra.
npm install -g pnpm@10.14.0)# Clone the repository
git clone https://github.com/mui/mui-public.git
cd mui-public
# Install dependencies
pnpm install --no-frozen-lockfile
# Build all packages
pnpm release:build
# Start dev server
pnpm docs:dev
| Command | Description |
|---|---|
pnpm docs:dev | Start docs dev server |
pnpm docs:build | Build docs site |
pnpm docs:validate | Validate docs files |
pnpm release:build | Build all packages |
pnpm typescript | Type check |
pnpm eslint | Lint code |
pnpm prettier | Format code |
pnpm test --run | Run all tests |
pnpm test --run {name} | Run specific test file |
Important
Always run
pnpm prettier,pnpm eslint,pnpm typescript, andpnpm docs:validatebefore submitting a PR.
Create or modify tests before changing implementation. When fixing bugs, write a failing test that reproduces the issue first:
src/{functionName}/{functionName}.test.ts # Unit tests
src/{functionName}/user.spec.ts # Integration tests
src/{functionName}/optimization.test.ts # Performance tests
Document public functions in MDX:
docs/app/docs-infra/{category}/{function-name}/page.mdx
docs/app/docs-infra/{category}/{function-name}/demos/{demo-name}/index.ts
Follow the Architecture patterns for consistency.
pnpm release:build && pnpm typescript && pnpm eslint && pnpm prettier && pnpm test --run
packages/docs-infra/
├── src/
│ ├── CodeHighlighter/ # React components
│ ├── useCode/ # React hooks
│ ├── pipeline/ # Build-time processing
│ │ ├── loadPrecomputed*/ # Webpack loaders
│ │ ├── loadServer*/ # Server-side loaders
│ │ ├── syncTypes/ # Type extraction
│ │ └── transform*/ # Markdown transformers
│ ├── abstractCreate*/ # Factory utilities
│ └── cli/ # CLI commands
└── build/ # Built output
docs/app/docs-infra/
├── architecture/ # System design docs
├── components/ # Component documentation
├── hooks/ # Hook documentation
├── functions/ # Function documentation
├── patterns/ # Architectural patterns
└── commands/ # CLI documentation
Functions are named {Purpose}{Object} for alphabetical sorting:
| Prefix | Purpose | Example |
|---|---|---|
load | Load data from files/network | loadServerSource |
parse | Parse strings into structures | parseSource |
transform | Transform data structures | transformMarkdownCode |
sync | Update committed files | syncTypes |
create | Factory functions | createDemo |
abstract | Factory factory functions | abstractCreateDemo |
use | React hooks | useCode |
with | Configuration plugins | withDocsInfra |
React components use {Object}{Purpose}: CodeHighlighter, CodeProvider.
src/{functionName}/
├── {functionName}.ts # Main implementation
├── {functionName}.test.ts # Unit tests
├── {helperFunction}.ts # Split out large helpers
├── types.ts # Complex/shared types
├── errors.ts # Custom error classes
├── constants.ts # Large string constants
└── index.ts # Re-exports
any, prefer unknown with narrowing.then() chainsPromise.all() for independent async operationsButton, Checkbox)describe('parseSource', () => {
it('highlights TypeScript code', () => {
const result = parseSource('const x = 1', 'example.ts');
expect(result.type).toBe('root');
});
});
// user.spec.ts
describe('user can highlight code', () => {
it('renders highlighted TypeScript', async () => {
// Test the full pipeline
});
});
src/{functionName}/{functionName}.tssrc/{functionName}/{functionName}.test.tssrc/{functionName}/index.tspackage.json exportsdocs/app/docs-infra/functions/{function-name}/page.mdxsrc/{ComponentName}/{ComponentName}.tsx.ts files'use client'docs/app/docs-infra/components/{component-name}/page.mdxsrc/pipeline/loadPrecomputed{Name}/loadPrecomputed{Name}.tswithDocsInfra default patterns if appropriateThis extends Next.js filesystem conventions with special handling for documentation files.
./app/**/demos/*/index.ts - loadPrecomputedCodeHighlighterWhen working with workspace packages, use the -F flag:
# Add a dependency
pnpm -F @mui/internal-docs-infra add lodash
# Remove a dependency
pnpm -F @mui/internal-docs-infra remove lodash
# Always dedupe after adding dependencies
pnpm dedupe
Warning
Do not manually edit
package.jsonto add/remove dependencies. Use pnpm commands to keep ordering deterministic.
The package uses 0.x.0 versioning to allow breaking changes while working toward a stable 1.0.0. Breaking changes should improve developer experience and be documented in the changelog.