@@ -30,9 +30,8 @@ class MDOutline {
30
30
const writer = new commonmark . HtmlRenderer ( ) ;
31
31
const html = writer . render ( parsed ) ;
32
32
33
- page . on ( 'console' , msg => {
34
- console . log ( msg . text ( ) ) ;
35
- } ) ;
33
+ const logConsole = msg => console . log ( msg . text ( ) ) ;
34
+ page . on ( 'console' , logConsole ) ;
36
35
// Extract headings.
37
36
await page . setContent ( html ) ;
38
37
const { classes, errors} = await page . evaluate ( ( ) => {
@@ -56,9 +55,11 @@ class MDOutline {
56
55
const name = str . substring ( 0 , str . indexOf ( '<' ) ) . replace ( / \` / g, '' ) . trim ( ) ;
57
56
const type = findType ( str ) ;
58
57
const properties = [ ] ;
59
- const comment = str . substring ( str . indexOf ( '<' ) + type . length + 2 ) . trim ( ) ;
58
+ let comment = str . substring ( str . indexOf ( '<' ) + type . length + 2 ) . trim ( ) ;
60
59
const hasNonEnumProperties = type . split ( '|' ) . some ( part => {
61
- return part !== 'string' && part !== 'number' && part !== 'Array<string>' && ! ( part [ 0 ] === '"' && part [ part . length - 1 ] === '"' ) ;
60
+ const basicTypes = new Set ( [ 'string' , 'number' , 'boolean' ] ) ;
61
+ const arrayTypes = new Set ( [ ...basicTypes ] . map ( type => `Array<${ type } >` ) ) ;
62
+ return ! basicTypes . has ( part ) && ! arrayTypes . has ( part ) && ! ( part . startsWith ( '"' ) && part . endsWith ( '"' ) ) ;
62
63
} ) ;
63
64
if ( hasNonEnumProperties ) {
64
65
for ( const childElement of element . querySelectorAll ( ':scope > ul > li' ) ) {
@@ -77,6 +78,8 @@ class MDOutline {
77
78
property . required = true ;
78
79
properties . push ( property ) ;
79
80
}
81
+ } else if ( ul ) {
82
+ comment += '\n' + parseComment ( ul ) . split ( '\n' ) . map ( l => ` - ${ l } ` ) . join ( '\n' ) ;
80
83
}
81
84
return {
82
85
name,
@@ -214,6 +217,7 @@ class MDOutline {
214
217
return fragment ;
215
218
}
216
219
} ) ;
220
+ page . off ( 'console' , logConsole ) ;
217
221
return new MDOutline ( classes , errors ) ;
218
222
}
219
223
0 commit comments