UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

45 lines 1.92 kB
import type { DemoPageRequirement } from "./loadNextConfig.mjs"; export interface EnsureDemoPagesOptions { /** Workspace root used to resolve glob patterns. */ baseDir: string; /** Patterns extracted from next.config that opted into `page.tsx` generation. */ requirements: DemoPageRequirement[]; } export interface EnsureDemoPagesResult { /** Total number of demo `index.ts` files matched across all patterns. */ demoCount: number; /** Workspace-relative paths of files that were created. */ updatedFiles: string[]; /** Errors encountered during the run. */ errors: { filePath: string; message: string; }[]; } /** * Generates the contents for an auto-created demo `page.tsx`. The page renders * the demo's named export from the sibling `index.ts` inside a `Page` component, * so the demo renders as its own route. * * Exported for tests and reuse. */ export declare function generatePageFileContent(exportName: string): string; /** * Reads the demo's export name from a demo `index.ts` by reusing the same * `create*` factory parser the precomputed code highlighter loader uses to load * variants. Returns `null` when no named `export const X = create*(...)` is * found (e.g. an anonymous default export), since a re-export page needs a name * to import. * * Exported for tests. */ export declare function findDemoExportName(source: string, filePath: string): Promise<string | null>; /** * Ensures every demo `index.ts` matched by the configured demo patterns has a * sibling `page.tsx` that renders the demo as the route's default export. * * Existing `page.tsx`/`page.ts` files are left untouched so developers can * customise the page (e.g. wrap the demo with additional layout). Returns the * list of files that were created, plus any errors encountered. */ export declare function ensureDemoPages(options: EnsureDemoPagesOptions): Promise<EnsureDemoPagesResult>;