-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a central script instead of one per package to generate docs #14216
Changes from all commits
1884dcb
9ae7104
b15166c
e172a59
4689fea
116d80b
a4e3d4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env node | ||
|
||
const path = require( 'path' ); | ||
const childProcess = require( 'child_process' ); | ||
|
||
const packages = [ | ||
'e2e-test-utils', | ||
]; | ||
|
||
let aggregatedExitCode = 0; | ||
packages.forEach( ( packageName ) => { | ||
const args = [ | ||
`packages/${ packageName }/src/index.js`, | ||
`--output packages/${ packageName }/README.md`, | ||
'--to-token', | ||
]; | ||
const pathToDocGen = path.join( __dirname, '..', 'node_modules', '.bin', 'docgen' ); | ||
const { status, stderr } = childProcess.spawnSync( | ||
pathToDocGen, | ||
args, | ||
{ shell: true }, | ||
); | ||
if ( status !== 0 ) { | ||
aggregatedExitCode = status; | ||
process.stderr.write( `${ stderr }\n` ); | ||
} | ||
} ); | ||
|
||
process.exit( aggregatedExitCode ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,8 +162,7 @@ | |
"predev": "npm run check-engines", | ||
"dev": "npm run build:packages && concurrently \"wp-scripts start\" \"npm run dev:packages\"", | ||
"dev:packages": "node ./bin/packages/watch.js", | ||
"docs:build": "node docs/tool", | ||
"docs:generate": "lerna run docs:generate", | ||
"docs:build": "node ./docs/tool && node ./bin/update-readmes", | ||
"fixtures:clean": "rimraf \"packages/e2e-tests/fixtures/blocks/*.+(json|serialized.html)\"", | ||
"fixtures:server-registered": "docker-compose run -w /var/www/html/wp-content/plugins/gutenberg --rm wordpress ./bin/get-server-blocks.php > test/integration/full-content/server-registered.json", | ||
"fixtures:generate": "npm run fixtures:server-registered && cross-env GENERATE_MISSING_FIXTURES=y npm run test-unit", | ||
|
@@ -204,7 +203,10 @@ | |
"wp-scripts lint-js" | ||
], | ||
"{docs/{toc.json,tool/*.js},packages/{*/README.md,*/src/{actions,selectors}.js,components/src/*/**/README.md}}": [ | ||
"npm run docs:build" | ||
"node ./docs/tool" | ||
], | ||
"packages/**/*.js": [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to ignore files related to tests, but it looks like I can't do that ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also note that although the script updates some |
||
"node ./bin/update-readmes" | ||
] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've a bad habit in our scripts of making them blocking/synchronous when they don't need to be.
See #14295 for a proposed revision.