MUI Docs Infra

Warning

This is an internal project, and is not intended for public use. No support or stability guarantees are provided.

Validate

The validate command ensures that committed files match the expected output. It processes all page.mdx files to verify parent indexes are up-to-date, and all types.ts files to ensure generated types.md documentation is current.

Usage

pnpm docs-infra validate [paths...]

Arguments

ArgumentTypeDescription
pathsstring[]Optional paths to validate (e.g., docs-infra/components)

Options

OptionTypeDefaultDescription
--commandstringpnpm docs-infra validateCommand to suggest when indexes are out of date
--useVisibleDescriptionbooleanfalseUse first visible paragraph as description
--indexesbooleanfalseOnly validate page.mdx index files
--typesbooleanfalseOnly validate types.ts files

Examples

Validate All Indexes

pnpm docs-infra validate

Processes all page.mdx files in src/app/ and app/ directories.

Validate Specific Sections

pnpm docs-infra validate docs-infra/components docs-infra/functions

Only validates indexes under the specified paths.

Use Visible Description

pnpm docs-infra validate --useVisibleDescription

Uses the first visible paragraph in each page as the description, instead of the meta tag.

Validate Only Indexes

pnpm docs-infra validate --indexes

Only processes page.mdx files, skipping types validation.

Validate Only Types

pnpm docs-infra validate --types

Only processes types.ts files, skipping index validation.


How It Works

Index Validation

  1. Find Files: Searches for all page.mdx files in the app directories
  2. Process Metadata: Runs each file through the unified pipeline with transformMarkdownMetadata
  3. Check Indexes: Compares generated metadata against existing index files
  4. Report Results: Lists which indexes were updated and their paths

Types Validation

  1. Find Files: Searches for all types.ts files in the app directories
  2. Parse Factory Calls: Extracts createTypesMeta calls from each file
  3. Sync Types: Runs syncTypes to regenerate type documentation
  4. Report Results: Lists which types.md files were updated

CI Mode

In CI environments (CI=true), the command exits with error code 1 if any files changed, suggesting the command to run locally.


Output

When All Files Are Current

Validating committed files match expected output...

Processing 47 indexed page.mdx files...

Processing 12 types.md files...

No files needed updating

✓ 0 files updated in 1.23s [indexes: 0.85s, types: 0.38s]

When Files Need Updates

Validating committed files match expected output...

Processing 47 indexed page.mdx files...

Updated index files:
  app/docs-infra/components/page.mdx
  app/docs-infra/functions/page.mdx

Processing 12 types.md files...

Updated types.md files:
  app/docs-infra/components/code-highlighter/types.md

Total: 3 files updated

✓ 3 files updated in 1.45s [indexes: 0.92s, types: 0.53s]

CI Failure

When running in CI (CI=true) and files are out of date:

Updated index files:
  app/docs-infra/components/page.mdx

Updated types.md files:
  app/docs-infra/components/code-highlighter/types.md

Total: 2 files updated

✓ 2 files updated in 1.23s [indexes: 0.85s, types: 0.38s]

✗ Generated files are out of date. Run this command locally:

  pnpm docs-infra validate docs-infra/components

Then commit the results.

Exit code: 1


Marker Files

The command uses marker files to track which indexes were updated:

  • Location: .next/cache/docs-infra/index-updates/
  • These files are temporary and cleaned up before each run
  • Used to determine which paths to suggest in CI error messages

Integration with transformMarkdownMetadata

The validate command uses the transformMarkdownMetadata plugin internally:

const processor = unified()
  .use(remarkParse)
  .use(remarkMdx)
  .use(transformMarkdownMetadata, {
    extractToIndex: {
      include: includePatterns,
      exclude: [],
      baseDir: cwd,
      onlyUpdateIndexes: true,
      markerDir: '.next/cache/docs-infra/index-updates',
      useVisibleDescription,
    },
  });