mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 02:23:31 +01:00
Give the docgen a facelift
This commit is contained in:
@@ -1,34 +1,29 @@
|
||||
/* eslint no-console:0 no-return-assign:0 */
|
||||
const GEN_VERSION = require('./config.json').GEN_VERSION;
|
||||
const compress = require('./config.json').COMPRESS;
|
||||
const DocumentationScanner = require('./doc-scanner');
|
||||
const Documentation = require('./documentation');
|
||||
/* eslint-disable no-console */
|
||||
const fs = require('fs-extra');
|
||||
const zlib = require('zlib');
|
||||
const jsdoc2md = require('jsdoc-to-markdown');
|
||||
const Documentation = require('./documentation');
|
||||
const custom = require('../custom/index');
|
||||
const config = require('./config');
|
||||
|
||||
const docScanner = new DocumentationScanner(this);
|
||||
process.on('unhandledRejection', console.error);
|
||||
|
||||
function parseDocs(json) {
|
||||
console.log(`${json.length} items found`);
|
||||
const documentation = new Documentation(json, custom);
|
||||
console.log('serializing');
|
||||
console.log(`Using format version ${config.GEN_VERSION}.`);
|
||||
console.log('Parsing JSDocs in source files...');
|
||||
|
||||
jsdoc2md.getTemplateData({ files: [`./src/*.js`, `./src/**/*.js`] }).then(data => {
|
||||
console.log(`${data.length} items found.`);
|
||||
const documentation = new Documentation(data, custom);
|
||||
console.log('Serializing...');
|
||||
let output = JSON.stringify(documentation.serialize(), null, 0);
|
||||
if (compress) {
|
||||
console.log('compressing');
|
||||
if (config.compress) {
|
||||
console.log('Compressing...');
|
||||
output = zlib.deflateSync(output).toString('utf8');
|
||||
}
|
||||
if (!process.argv.slice(2).includes('silent')) {
|
||||
console.log('writing to docs.json');
|
||||
console.log('Writing to docs.json...');
|
||||
fs.writeFileSync('./docs/docs.json', output);
|
||||
}
|
||||
console.log('done!');
|
||||
console.log('Done!');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
console.log(`using format version ${GEN_VERSION}`);
|
||||
console.log('scanning for documentation');
|
||||
|
||||
docScanner.scan('./src/')
|
||||
.then(parseDocs)
|
||||
.catch(console.error);
|
||||
}).catch(console.error);
|
||||
|
||||
Reference in New Issue
Block a user