UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

71 lines 3.47 kB
import type * as tae from 'typescript-api-extractor'; /** * Metadata for an external type discovered during formatting. * These are types referenced in props/params that are not publicly exported, * but whose definitions may be useful for documentation (e.g., union types). */ export interface ExternalTypeMeta { /** The type name (e.g., "Orientation") */ name: string; /** The type definition as a string (e.g., "'horizontal' | 'vertical'") */ definition: string; } /** * Collector for external types discovered during formatting. * Pass this to formatType/formatProperties/formatParameters to collect * external types as they are encountered in the formatted output. */ export interface ExternalTypesCollector { /** Map to accumulate results (type name -> ExternalTypeMeta) */ collected: Map<string, ExternalTypeMeta>; /** All exports in the module, used to identify own types */ allExports: tae.ExportNode[]; /** Optional pattern to filter which external types to include */ pattern?: RegExp; /** Map of original export names to dotted display names, used to identify renamed own types */ typeNameMap?: Record<string, string>; } /** * Checks if a type name belongs to a built-in namespace that should be skipped * during external type collection. */ export declare function isBuiltInTypeName(typeName: tae.TypeName): boolean; /** * Checks whether a type name belongs to one of the module's own exports. * Matches both direct export names (e.g., `AlertDialogRootChangeEventReason`) * and short names that appear as the last segment of a typeNameMap value * (e.g., `ChangeEventReason` matching `AlertDialog.Root.ChangeEventReason`). */ export declare function isOwnTypeName(typeName: string, collector: ExternalTypesCollector): boolean; /** * Formats an external type definition as a simple type string. * This produces a concise representation suitable for documentation. * Note: This function always expands types - it's used for showing the full * definition in the "External Types" section, not for inline type display. */ export declare function formatExternalTypeDefinition(type: tae.AnyType): string; /** * Formats a function type signature for external type documentation. * Produces a readable representation like `(data: { side: Side; align: Align }) => number`. */ export declare function formatFunctionSignature(type: tae.FunctionNode): string; /** * Attempts to collect a named union type as an external type during formatting. * Only collects if: * - The type has a name * - ALL members are literals or simple intrinsics (string, number, boolean) * - The type is not in allExports (not an own type) * - The type is not a built-in namespace * - The optional pattern filter matches */ export declare function maybeCollectExternalUnion(type: tae.UnionNode, collector: ExternalTypesCollector): void; /** * Attempts to collect a named function type as an external type during formatting. * Only collects named function types that aren't ComponentRenderFn, own types, or built-in. */ export declare function maybeCollectExternalFunction(type: tae.FunctionNode, collector: ExternalTypesCollector): void; /** * Attempts to collect an external type reference (from node_modules) as an external type. * Looks up the type in allExports to see if it's a re-exported union/literal. */ export declare function maybeCollectExternalReference(type: tae.ExternalTypeNode, collector: ExternalTypesCollector): void;