UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

57 lines 2.74 kB
import type * as tae from 'typescript-api-extractor'; import { type FormattedProperty, type FormattedEnumMember, type FormatInlineTypeOptions, type DescriptionReplacement } from "./format.mjs"; import { type TypeRewriteContext } from "./rewriteTypes.mjs"; import type { ExternalTypesCollector } from "./externalTypes.mjs"; import type { HastRoot } from "../../CodeHighlighter/types.mjs"; import type { OrderingConfig } from "../loadServerTypesText/order.mjs"; /** * Complete component type metadata for documentation. */ export type ComponentTypeMeta = { name: string; description?: HastRoot; /** Plain text version of description for markdown generation */ descriptionText?: string; props: Record<string, FormattedProperty>; dataAttributes: Record<string, FormattedEnumMember>; cssVariables: Record<string, FormattedEnumMember>; }; /** * Options for customizing component data formatting. */ export interface FormatComponentOptions { /** Suffix for data attributes enum name (default: 'DataAttributes') */ dataAttributesSuffix?: string; /** Suffix for CSS variables enum name (default: 'CssVars') */ cssVariablesSuffix?: string; /** Pattern/replacement pairs to apply to descriptions */ descriptionReplacements?: DescriptionReplacement[]; /** Options for inline type formatting (e.g., unionPrintWidth) */ formatting?: FormatInlineTypeOptions; /** Collector for external types discovered during formatting */ externalTypes?: ExternalTypesCollector; /** Custom ordering for props, data attributes, and CSS variables */ ordering?: OrderingConfig; } /** * Formats a TypeScript component export into structured documentation metadata. * * This function extracts and formats all relevant component information including * props, data attributes, and CSS variables. It also applies post-processing to * normalize type names across re-exports and hide internal implementation details. * * The component must be validated with `isPublicComponent()` before calling this function. */ export declare function formatComponentData(component: tae.ExportNode & { type: tae.ComponentNode; }, allExports: tae.ExportNode[], typeNameMap: Record<string, string>, rewriteContext: TypeRewriteContext, options?: FormatComponentOptions): Promise<ComponentTypeMeta>; /** * Type guard to check if an export is a public component that should be documented. * * A component is considered public if it's a ComponentNode, doesn't have an @ignore tag, * and is marked as public (not @internal). Use this to filter components before passing * them to `formatComponentData()`. */ export declare function isPublicComponent(exportNode: tae.ExportNode): exportNode is tae.ExportNode & { type: tae.ComponentNode; };