@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
39 lines • 2.06 kB
text/typescript
import type { Root as HastRoot } from 'hast';
import { type TransformHtmlCodeBlockOptions } from "../transformHtmlCodeBlock/transformHtmlCodeBlock.mjs";
import { type TypesMeta } from "../loadServerTypesMeta/index.mjs";
import { type TypesOutputFormat } from "./hastTypeUtils.mjs";
/**
* Result of the highlightTypes function.
*/
export interface HighlightTypesResult {
/** Types with highlighted markdown content */
types: TypesMeta[];
/** Map of export names to their highlighted type definitions for expansion */
highlightedExports: Record<string, HastRoot>;
}
/**
* Applies syntax highlighting to code blocks in descriptions and examples.
*
* This function processes all TypesMeta objects and applies transformHtmlCodeBlock
* to expand any code blocks in markdown content (descriptions and examples) with precomputed
* syntax highlighting. It operates in parallel for maximum performance.
*
* Note: Type strings (typeText, defaultText) remain as plain text at this stage.
* Highlighting of types and generation of shortType/detailedType is deferred to
* highlightTypesMeta() which runs after this function.
*
* The transform is applied to:
* - Component and hook descriptions (markdown with code blocks)
* - Prop/parameter examples (markdown with code blocks)
* - Prop/parameter descriptions (markdown with code blocks)
* - Data attribute and CSS variable descriptions (markdown with code blocks)
*
* Additionally, this function builds a highlightedExports map that maps
* export names to their highlighted type definitions, enabling type reference
* expansion in highlightTypesMeta().
*
* @param types - The types array to process
* @param externalTypes - External types discovered during formatting (type name -> definition)
* @returns Result object with transformed types and highlightedExports map
*/
export declare function highlightTypes(types: TypesMeta[], externalTypes?: Record<string, string>, output?: TypesOutputFormat, codeBlockEmphasisOptions?: TransformHtmlCodeBlockOptions): Promise<HighlightTypesResult>;