const parseArgs = require('minimist'); const fs = require('fs'); const assert = require('assert'); const { resolve } = require('path'); const IDENT = ' '; class MyDoc { constructor() { this.workDir = './'; } async init() { await this.convert(); } async convert() { this.env = fs.readFileSync(`${this.workDir}env.json`, 'utf8'); this.data = ` { if (item.name.slice(-3) == '.js' && item.name != 'common.js') { const c = require(resolve('./') + '/' + item.name.slice(0, -3)); this.convertClass(new c()); } }); } async convertClass(c) { c.apis.forEach( (item) => { const method = item.method ? 'GET' : item.method; this.data += ` /** * @api ${method} ${item.url} * @apiPermission * @apiGroup ${item.group} * @apiVersion 1.0 * @apiDescription ${item.desc} `; if (item.is_json_params) { } else { } this.data += ` */ `; } ); console.log(this.data); } } (new MyDoc).init();