@@ -1049,6 +1049,28 @@ function getComponentDescription(componentName, file) {
10491049 return null ;
10501050}
10511051
1052+ function getJsDocData ( node ) {
1053+ const docs = typeof node ?. getJsDocs === 'function' ? node . getJsDocs ( ) : [ ] ;
1054+ const tags = docs . flatMap ( doc => doc . getTags ( ) ) ;
1055+
1056+ return {
1057+ description : docs
1058+ . map ( doc => doc . getDescription ( ) . replace ( / \n + / g, ' ' ) . trim ( ) )
1059+ . find ( Boolean ) || '' ,
1060+ defaultValue : tags . find ( tag => tag . getTagName ( ) === 'default' ) ?. getCommentText ( ) || '' ,
1061+ selector : tags . find ( tag => tag . getTagName ( ) === 'selector' ) ?. getCommentText ( ) || '' ,
1062+ deprecated : tags . some ( tag => tag . getTagName ( ) === 'deprecated' ) ,
1063+ private : tags . some ( tag => tag . getTagName ( ) === 'private' )
1064+ } ;
1065+ }
1066+
1067+ function shouldOmitSymbol ( sym ) {
1068+ return ( sym . getDeclarations ?. ( ) || [ ] ) . some ( decl => {
1069+ const docData = getJsDocData ( decl ) ;
1070+ return docData . deprecated || docData . private ;
1071+ } ) ;
1072+ }
1073+
10521074/**
10531075 * Build a markdown table of props for the given component by analyzing its interface.
10541076 */
@@ -1086,25 +1108,17 @@ function generatePropTable(componentName, file) {
10861108
10871109 const propSymbols = iface . getType ( ) . getProperties ( ) ;
10881110
1089- const rows = propSymbols . map ( ( sym ) => {
1111+ const rows = propSymbols . flatMap ( ( sym ) => {
1112+ if ( shouldOmitSymbol ( sym ) ) {
1113+ return [ ] ;
1114+ }
1115+
10901116 const name = sym . getName ( ) ;
10911117 const decl = sym . getDeclarations ( ) ?. [ 0 ] ;
10921118 const type = cleanTypeText ( sym . getTypeAtLocation ( iface ) . getText ( iface ) ) ;
1119+ const docData = getJsDocData ( decl ) ;
10931120
1094- let description = '' ;
1095- let defVal = '' ;
1096- if ( decl && typeof decl . getJsDocs === 'function' ) {
1097- const docsArr = decl . getJsDocs ( ) ;
1098- if ( docsArr . length ) {
1099- description = docsArr [ 0 ] . getDescription ( ) . replace ( / \n + / g, ' ' ) . trim ( ) ;
1100- const defaultTag = docsArr [ 0 ] . getTags ( ) . find ( ( t ) => t . getTagName ( ) === 'default' ) ;
1101- if ( defaultTag ) {
1102- defVal = defaultTag . getCommentText ( ) ;
1103- }
1104- }
1105- }
1106-
1107- return { name, type, defVal, description} ;
1121+ return [ { name, type, defVal : docData . defaultValue , description : docData . description } ] ;
11081122 } ) ;
11091123
11101124 if ( ! rows . length ) {
@@ -1164,6 +1178,10 @@ function generateInterfaceTable(interfaceName, file) {
11641178 const methods = [ ] ;
11651179
11661180 for ( const sym of propSymbols ) {
1181+ if ( shouldOmitSymbol ( sym ) ) {
1182+ continue ;
1183+ }
1184+
11671185 const name = sym . getName ( ) ;
11681186 const decl = sym . getDeclarations ( ) ?. [ 0 ] ;
11691187
@@ -1184,15 +1202,10 @@ function generateInterfaceTable(interfaceName, file) {
11841202 let defVal = '' ;
11851203 let optional = false ;
11861204
1187- if ( decl && typeof decl . getJsDocs === 'function' ) {
1188- const docsArr = decl . getJsDocs ( ) ;
1189- if ( docsArr . length ) {
1190- description = docsArr [ 0 ] . getDescription ( ) . replace ( / \n + / g, ' ' ) . trim ( ) ;
1191- const defaultTag = docsArr [ 0 ] . getTags ( ) . find ( ( t ) => t . getTagName ( ) === 'default' ) ;
1192- if ( defaultTag ) {
1193- defVal = defaultTag . getCommentText ( ) ;
1194- }
1195- }
1205+ if ( decl ) {
1206+ const docData = getJsDocData ( decl ) ;
1207+ description = docData . description ;
1208+ defVal = docData . defaultValue ;
11961209 }
11971210
11981211 if ( decl && decl . hasQuestionToken ?. ( ) ) {
@@ -2617,7 +2630,8 @@ function generateClassAPITable(className, file) {
26172630 // Generate properties documentation
26182631 const properties = classDecl . getProperties ( ) . filter ( p => {
26192632 const scope = p . getScope ( ) ;
2620- return scope === undefined || scope === 1 ; // public properties only
2633+ const docData = getJsDocData ( p ) ;
2634+ return ( scope === undefined || scope === 1 ) && ! docData . deprecated && ! docData . private ; // public, non-deprecated, non-private properties only
26212635 } ) ;
26222636
26232637 if ( properties . length > 0 ) {
@@ -2678,29 +2692,22 @@ function generateStateTable(renderPropsName, {showOptional = false, hideSelector
26782692
26792693 // Build rows
26802694 const rows = propSymbols . map ( sym => {
2695+ if ( shouldOmitSymbol ( sym ) ) {
2696+ return null ;
2697+ }
2698+
26812699 const name = sym . getName ( ) ;
26822700
26832701 const decl = sym . getDeclarations ( ) ?. [ 0 ] ;
2684- let description = '' ;
2685- let selector = '' ;
26862702 let optional = false ;
26872703
26882704 if ( decl ) {
26892705 optional = decl . hasQuestionToken ?. ( ) || false ;
2690- if ( typeof decl . getJsDocs === 'function' ) {
2691- const docsArr = decl . getJsDocs ( ) ;
2692- if ( docsArr . length ) {
2693- description = docsArr [ 0 ] . getDescription ( ) . replace ( / \n + / g, ' ' ) . trim ( ) ;
2694- const selTag = docsArr [ 0 ] . getTags ( ) . find ( t => t . getTagName ( ) === 'selector' ) ;
2695- if ( selTag ) {
2696- selector = selTag . getCommentText ( ) ;
2697- }
2698- }
2699- }
27002706 }
27012707
2702- return { name, selector : selector || '—' , description, optional} ;
2703- } ) ;
2708+ const docData = getJsDocData ( decl ) ;
2709+ return { name, selector : docData . selector || '—' , description : docData . description , optional} ;
2710+ } ) . filter ( Boolean ) ;
27042711
27052712 // Filter optional props if showOptional is false
27062713 const filteredRows = showOptional ? rows : rows . filter ( r => ! r . optional ) ;
0 commit comments