diff --git a/tools/mydoc/app.js b/tools/mydoc/app.js index 1a568ce0..ea9f78de 100644 --- a/tools/mydoc/app.js +++ b/tools/mydoc/app.js @@ -1,6 +1,9 @@ const parseArgs = require('minimist'); const fs = require('fs'); const assert = require('assert'); +const { resolve } = require('path'); + +const IDENT = ' '; class MyDoc { @@ -14,25 +17,49 @@ class MyDoc { async convert() { this.env = fs.readFileSync(`${this.workDir}env.json`, 'utf8'); - let data = ` + this.data = ` { if (item.name.slice(-3) == '.js' && - item.name != 'common.js') { - //console.log(require('./' + item.name.slice(0, -3))); - console.log(require('/home/azw/pub/game2006go/doc/admin/User')); + 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();