-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
update-readmes.js
executable file
·71 lines (67 loc) · 1.6 KB
/
update-readmes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env node
const path = require( 'path' );
const { promisify } = require( 'util' );
const spawn = promisify( require( 'child_process' ).spawn );
const packages = [
'a11y',
'autop',
'blob',
'block-editor',
'block-library',
'block-serialization-default-parser',
'blocks',
'compose',
//'data',
'date',
'deprecated',
'dom',
'dom-ready',
'e2e-test-utils',
'edit-post',
'element',
'escape-html',
'html-entities',
'i18n',
'keycodes',
'plugins',
'priority-queue',
'redux-routine',
'rich-text',
'shortcode',
'url',
'viewport',
'wordcount',
];
const getArgsForPackage = ( packageName ) => {
switch ( packageName ) {
case 'rich-text':
return [
`packages/${ packageName }/src/index.js`,
`--output packages/${ packageName }/README.md`,
'--to-token',
'--ignore "unstable|experimental|^apply$|^changeListType$|^charAt$|^getSelectionStart$|^getSelectionEnd$|^indentListItems$|^insertLineBreak$|^insertLineSeparator$|^isEmptyLine$|^LINE_SEPARATOR$|^outdentListItems$"',
];
default:
return [
`packages/${ packageName }/src/index.js`,
`--output packages/${ packageName }/README.md`,
'--to-token',
'--ignore "unstable|experimental"',
];
}
};
Promise.all( packages.map( async ( packageName ) => {
const args = getArgsForPackage( packageName );
const pathToDocGen = path.join( __dirname, '..', 'node_modules', '.bin', 'docgen' );
const { status, stderr } = await spawn(
pathToDocGen,
args,
{ shell: true },
);
if ( status !== 0 ) {
throw stderr.toString();
}
} ) ).catch( ( error ) => {
process.stderr.write( `${ error }\n` );
process.exit( 1 );
} );