diff --git a/src/generator/docs.ts b/src/generator/docs.ts index 0fd6224df9..a9aab6f7c8 100644 --- a/src/generator/docs.ts +++ b/src/generator/docs.ts @@ -17,7 +17,6 @@ import * as fs from 'fs'; import * as nunjucks from 'nunjucks'; import * as path from 'path'; import {promisify} from 'util'; -import Q from 'p-queue'; const rootPath = path.join(__dirname, '../../..'); const srcPath = path.join(rootPath, 'src'); @@ -35,11 +34,11 @@ export const gfs = { }; /** - * Iterate over each API directory, and use the `compodoc` tool to generate - * reference API documentation in the `docs` folder. This folder is ignored - * in git, so a publish must be done with `npm run publish-docs`. + * Generate reference documentation for all built APIs with JSDoc in the + * `docs` folder. This folder is ignored in git, so a publish must be done with + * `npm run publish-docs`. * - * To use this, run `npm run generate-docs`. + * To use this, run `npm run docs`. */ export async function main() { if (!gfs.exists(docsPath)) { @@ -51,25 +50,13 @@ export async function main() { }); const contents = nunjucks.render(templatePath, {apis: dirs}); await gfs.writeFile(indexPath, contents); - const q = new Q({concurrency: 10}); console.log(`Generating docs for ${dirs.length} APIs...`); - let i = 0; - const promises = dirs.map(dir => { - return q - .add(() => - gfs.execa(process.execPath, [ - '--max-old-space-size=4096', - './node_modules/.bin/jsdoc', - '-c', - '.jsdoc.js', - ]), - ) - .then(() => { - i++; - console.log(`[${i}/${dirs.length}] ${dir}`); - }); - }); - await Promise.all(promises); + await gfs.execa(process.execPath, [ + '--max-old-space-size=4096', + './node_modules/.bin/jsdoc', + '-c', + '.jsdoc.js', + ]); } if (require.main === module) { diff --git a/test/test.docs.ts b/test/test.docs.ts index e344a718ea..c76a2c314e 100644 --- a/test/test.docs.ts +++ b/test/test.docs.ts @@ -23,10 +23,20 @@ describe(__filename, () => { afterEach(() => sandbox.restore()); it('should generate docs', async () => { + sandbox.stub(docs.gfs, 'exists').returns(true); const writeStub = sandbox.stub(docs.gfs, 'writeFile').resolves(); const execStub = sandbox.stub(docs.gfs, 'execa').resolves(); await docs.main(); assert.ok(writeStub.called); - assert.ok(execStub); + assert.strictEqual(execStub.callCount, 1); + assert.deepStrictEqual(execStub.firstCall.args, [ + process.execPath, + [ + '--max-old-space-size=4096', + './node_modules/.bin/jsdoc', + '-c', + '.jsdoc.js', + ], + ]); }); });