@@ -13,7 +13,6 @@ import { defaultHandlers, parse as docgenParse, ReactDocgenApi } from 'react-doc
1313import { unstable_generateUtilityClass as generateUtilityClass } from '@mui/utils' ;
1414import { renderInline as renderMarkdownInline } from '@mui/markdown' ;
1515import { LANGUAGES } from 'docs/config' ;
16-
1716import muiDefaultPropsHandler from '../utils/defaultPropsHandler' ;
1817import parseTest from '../utils/parseTest' ;
1918import generatePropTypeDescription , { getChained } from '../utils/generatePropTypeDescription' ;
@@ -24,6 +23,7 @@ import generatePropDescription from '../utils/generatePropDescription';
2423import parseStyles , { Styles } from '../utils/parseStyles' ;
2524import { ComponentInfo } from '../buildApiUtils' ;
2625import { TypeScriptProject } from '../utils/createTypeScriptProject' ;
26+ import parseSlots , { Slot } from '../utils/parseSlots' ;
2727
2828const DEFAULT_PRETTIER_CONFIG_PATH = path . join ( process . cwd ( ) , 'prettier.config.js' ) ;
2929
@@ -47,6 +47,7 @@ export interface ReactApi extends ReactDocgenApi {
4747 */
4848 src : string ;
4949 styles : Styles ;
50+ slots : Slot [ ] ;
5051 propsTable : _ . Dictionary < {
5152 default : string | undefined ;
5253 required : boolean | undefined ;
@@ -58,6 +59,7 @@ export interface ReactApi extends ReactDocgenApi {
5859 componentDescription : string ;
5960 propDescriptions : { [ key : string ] : string | undefined } ;
6061 classDescriptions : { [ key : string ] : { description : string ; conditions ?: string } } ;
62+ slotDescriptions : { [ key : string ] : string | undefined } ;
6163 } ;
6264}
6365
@@ -350,6 +352,7 @@ const generateApiPage = (outputDirectory: string, reactApi: ReactApi) => {
350352 ) ,
351353 name : reactApi . styles . name ,
352354 } ,
355+ slots : reactApi . slots ,
353356 spread : reactApi . spread ,
354357 forwardsRefTo : reactApi . forwardsRefTo ,
355358 filename : toGitHubPath ( reactApi . filename ) ,
@@ -404,6 +407,7 @@ const attachTranslations = (reactApi: ReactApi) => {
404407 componentDescription : reactApi . description ,
405408 propDescriptions : { } ,
406409 classDescriptions : { } ,
410+ slotDescriptions : { } ,
407411 } ;
408412 Object . entries ( reactApi . props ! ) . forEach ( ( [ propName , propDescriptor ] ) => {
409413 let prop : DescribeablePropDescriptor | null ;
@@ -418,6 +422,8 @@ const attachTranslations = (reactApi: ReactApi) => {
418422
419423 if ( propName === 'classes' ) {
420424 description += ' See <a href="#css">CSS API</a> below for more details.' ;
425+ } else if ( propName === 'slots' ) {
426+ description += ' See <a href="#slots">Slots API</a> below for more details.' ;
421427 } else if ( propName === 'sx' ) {
422428 description +=
423429 ' See the <a href="/system/getting-started/the-sx-prop/">`sx` page</a> for more details.' ;
@@ -427,9 +433,10 @@ const attachTranslations = (reactApi: ReactApi) => {
427433 } ) ;
428434
429435 /**
430- * CSS class descriptiohs .
436+ * CSS class descriptions .
431437 */
432438 translations . classDescriptions = extractClassConditions ( reactApi . styles . descriptions ) ;
439+ // translations.slotDescriptions = generateSlotDescriptions(reactApi.slots.descriptions);
433440
434441 reactApi . translations = translations ;
435442} ;
@@ -597,7 +604,7 @@ const generateComponentApi = async (componentInfo: ComponentInfo, project: TypeS
597604 reactApi . spread = testInfo . spread ?? spread ;
598605 reactApi . inheritance = getInheritance ( testInfo . inheritComponent ) ;
599606 reactApi . styles = await parseStyles ( { project, componentName : reactApi . name } ) ;
600-
607+ reactApi . slots = parseSlots ( { project , componentName : reactApi . name } ) ;
601608 if ( reactApi . styles . classes . length > 0 && ! reactApi . name . endsWith ( 'Unstyled' ) ) {
602609 reactApi . styles . name = reactApi . muiName ;
603610 }
0 commit comments