Introduce a "validate only" mode for docs generation

The API documentation generation is useful (in `--strict` mode) to
determine whether all our APIs have sufficient documentation. Add a
`--validate-only` mode that will run the validation without emitting the
API JSON. This is useful for ensuring that the documentation is
complete.
This commit is contained in:
Edward Thomson
2024-11-26 20:47:31 +00:00
parent 07c77d497b
commit 0bd5e479b2
3 changed files with 7 additions and 2 deletions

1
script/api-docs/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
node_modules/

View File

@@ -63,6 +63,7 @@ async function headerPaths(p) {
paths.push(...(await fs.readdir(fullPath)).
filter((filename) => filename.endsWith('.h')).
filter((filename) => !fileIgnoreList.includes(filename)).
filter((filename) => filename !== 'deprecated.h' || !options.deprecateHard).
map((filename) => `${fullPath}/${filename}`));
}
@@ -1494,6 +1495,7 @@ program.option('--output <filename>')
.option('--include <filename>', undefined, joinArguments)
.option('--no-includes')
.option('--deprecate-hard')
.option('--validate-only')
.option('--strict');
program.parse();
@@ -1535,7 +1537,9 @@ if (options['include'] && !options['includes']) {
const simplified = simplify(results);
simplified['info'] = metadata;
console.log(JSON.stringify(simplified, null, 2));
if (!options.validateOnly) {
console.log(JSON.stringify(simplified, null, 2));
}
} catch (e) {
console.error(e);
process.exit(1);

View File

@@ -1,5 +1,5 @@
{
"name": "_generator",
"name": "api-docs",
"lockfileVersion": 3,
"requires": true,
"packages": {