UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

105 lines 3.7 kB
import type * as tae from 'typescript-api-extractor'; import { type FormattedParameter, 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"; /** * Class type from typescript-api-extractor. * Defined here since ClassNode may not be exported from older versions. */ export interface ClassNode { kind: 'class'; typeName: tae.TypeName | undefined; constructSignatures: Array<{ parameters: tae.Parameter[]; documentation: tae.Documentation | undefined; }>; properties: Array<{ name: string; type: tae.AnyType; documentation: tae.Documentation | undefined; optional: boolean; readonly: boolean; isStatic: boolean; }>; methods: Array<{ name: string; callSignatures: Array<{ parameters: tae.Parameter[]; returnValueType: tae.AnyType; }>; documentation: tae.Documentation | undefined; isStatic: boolean; }>; typeParameters: tae.TypeName[] | undefined; } /** * Formatted class metadata with plain text types and parsed markdown descriptions. * * Type highlighting (type → HAST, shortType, detailedType) is deferred to * the loadServerTypes stage via highlightTypesMeta() after highlightTypes(). */ export type ClassTypeMeta = { name: string; description?: HastRoot; /** Plain text version of description for markdown generation */ descriptionText?: string; /** Constructor parameters */ constructorParameters: FormattedParameter[]; /** Public instance properties */ properties: Record<string, FormattedProperty>; /** Public instance methods */ methods: Record<string, FormattedMethod>; /** Type parameters (generics) if any */ typeParameters?: string[]; }; /** * Formatted property metadata for class properties. */ export interface FormattedProperty { name: string; typeText: string; description?: HastRoot; descriptionText?: string; optional: boolean; readonly: boolean; isStatic: boolean; } /** * Formatted method metadata for class methods. */ export interface FormattedMethod { name: string; description?: HastRoot; descriptionText?: string; parameters: FormattedParameter[]; returnValue: string; returnValueDescription?: HastRoot; returnValueDescriptionText?: string; isStatic: boolean; } export interface FormatClassOptions { /** 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; } /** * Formats class export data into a structured metadata object. * * @param classExport - The class export node from typescript-api-extractor * @param typeNameMap - Map for transforming type names * @param rewriteContext - Context for type string rewriting including type compatibility map * @param options - Formatting options * @returns Formatted class metadata with constructor and methods */ export declare function formatClassData(classExport: tae.ExportNode, typeNameMap: Record<string, string>, rewriteContext: TypeRewriteContext, options?: FormatClassOptions): Promise<ClassTypeMeta>; /** * Type guard to check if an export node is a public class. * * @param exportNode - The export node to check * @returns true if the export is a public class that should be documented */ export declare function isPublicClass(exportNode: tae.ExportNode): boolean;