File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -14,10 +14,12 @@ const components = apiFiles.map(filePath => {
14
14
return api ;
15
15
} ) ;
16
16
17
- if ( ! fs . existsSync ( COMPONENTS_DOCS_DIR ) ) {
18
- fs . mkdirSync ( COMPONENTS_DOCS_DIR ) ;
17
+ if ( fs . existsSync ( COMPONENTS_DOCS_DIR ) ) {
18
+ childProcess . execSync ( `rm -rf ${ COMPONENTS_DOCS_DIR } ` ) ;
19
19
}
20
20
21
+ fs . mkdirSync ( COMPONENTS_DOCS_DIR ) ;
22
+
21
23
const compoundComponents = components . filter ( c => c . name . includes ( '.' ) ) ;
22
24
const parentComponents = _ . flow ( components => _ . map ( components , c => c . name . split ( '.' ) [ 0 ] ) , _ . uniq ) ( compoundComponents ) ;
23
25
@@ -44,7 +46,17 @@ components.forEach(component => {
44
46
45
47
/* General */
46
48
content += `${ component . description } \n` ;
47
- content += `[(code example)](${ component . example } )\n` ;
49
+ if ( typeof component . example === 'string' ) {
50
+ content += `[(code example)](${ component . example } )\n` ;
51
+ } else if ( Array . isArray ( component . example ) ) {
52
+ content += '(code examples: ' ;
53
+ component . example . forEach ( ( example , index ) => {
54
+ const slashIndex = example . lastIndexOf ( '/' ) ;
55
+ const dotIndex = example . lastIndexOf ( '.' ) ;
56
+ content += `${ index > 0 ? ', ' : '' } [${ example . slice ( slashIndex + 1 , dotIndex ) } ](${ example } )` ;
57
+ } ) ;
58
+ content += ')\n' ;
59
+ }
48
60
49
61
if ( component . extends ) {
50
62
let extendsText = component . extends ?. join ( ', ' ) ;
You can’t perform that action at this time.
0 commit comments