win10html
文本編輯工具:VSCode(非必要)vue
安裝Nodejsjava
$ node -v v9.9.0 $ npm -v 6.1.0
經過Nodejs的包管理工具安裝apidocnode
$ npm install apidoc -g
apidoc -h Usage: C:\Program Files\nodejs\node.exe apidoc [options] Options: -f, --file-filters RegEx-Filter to select files that should be parsed (multiple -f can be used). [.*\.(clj|cls|coffee|cpp|cs|dart|erl|exs?|go|groovy|ino?|java|js|jsx|kt|litcoffee|lua|p|php?|pl|pm|py|rb|scala|ts|vue)$] -e, --exclude-filters RegEx-Filter to select files / dirs that should not be parsed (many -e can be used). [] -i, --input Input / source dirname. [./] -o, --output Output dirname. [./doc/] -t, --template Use template for output files. [C:\Users\Little\AppData\Roaming\npm\node_modules\apidoc\template\] -c, --config Path to directory containing config file (apidoc.json) [./] -p, --private Include private APIs in output. [false] -v, --verbose Verbose debug output. [false] ......
$ wkhtmltopdf.exe -V wkhtmltopdf 0.12.5 (with patched qt)
{ "name": "Test Api Document", "version": "0.1.0", "description": "This Document is Test Api Document.", "title": "Test Api Document", "url": "http://api.test.com/v1", "sampleUrl": "http://api.test.com/v1", "header": { "title": "GENERAL", "filename": "general.md" }, "template": { "withCompare": true, "withGenerator": true } }
Remove-Item -Force -Recurse doc apidoc -o doc pause .\doc\index.html
/** * @api {post} /auth/token TOKEN * @apiVersion 0.1.0 * @apiName TOKEN * @apiGroup Auth * @apiPermission none * * @apiParam {String} username 用戶名 * @apiParam {String} password 密碼 * * @apiExample Example usage: * curl -X POST \ * -H "Content-Type: application/json" \ * -d '{"username":"test","password":"test"}' \ * https://api.test.com/v1/auth/token * * @apiDescription 登錄認證並獲取token值。 * * @apiSuccess {Number} status 業務的成功或者失敗 * @apiSuccess {String} msg 成功或者失敗描述 * @apiSuccess {Object} data 返回的數據 * @apiSuccess {String} data.access_token 下次請求的訪問token * @apiSuccess {Number} data.expires_in token的過時時間 * * @apiSuccessExample {json} Response: * HTTP/1.1 200 OK * { * "status": 1, * "msg": "Get Token Success.", * "data": { * "access_token": "eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJvcHQiLCJzdWIiOiJhMTE2NDcxNCI * iIsImlhdCI6MTUxNTY1NjYzMiwiZXhwIjox.aoUcjw2EVc2hDchPgMK4tPou * PkWuh_jlcpLerO-w1lG_KTNmFmgiKiGAcgAnrYp7xQFpFEBVfwDu7Q", * "expires_in": 86399 * } * } */
## 概述 這個API文檔用於測試使用。
# 目錄中多了一個doc目錄,打開doc/index.html便可查看api文檔 $ apidoc -o doc
$ wkhtmltopdf.exe -s A3 doc/index.html api.pdf Loading pages (1/6) Counting pages (2/6) Resolving links (4/6) Loading headers and footers (5/6) Printing pages (6/6) Done # 當前目錄下多了一個api.pdf文件