apiDoc在您的源代碼中經過建立API註釋從而生成api說明文檔。
http://apidocjs.com/#param-ap...html
咱們以express的項目爲例express
1 建立apidoc.jsonjson
{ "name": "abc項目 api 文檔", "version": "1.0.0", "description": "項目描述", "title": "abc項目api文檔", "url" : "localhost:3000/api", "template": { "withCompare": true, "withGenerator": true } }
2 咱們在routes文件夾下創建api文件夾,用於書寫接口註釋說明,例如api
/** * @api {get} /news/newsContent 新聞詳情 * @apiVersion 1.0.0 * @apiName newsContent * @apiGroup news * @apiParam {Number} id 新聞id * @apiSuccess {Number} code 結果標識 * @apiSuccess {String} message 結果說明 * @apiSuccess {Object} data 結果數據 * @apiSuccessExample Success-Response: * HTTP/11 200 OK * { * "code": 1, * "mess": "成功", * "data": {} * } */
3 調用生成命令url
apidoc -i routes/ -o public/apidoc/
以上命令的意思是讀取routes文件夾下的api配置,輸出api說明文檔到public/apidoc/文件夾
打開生成後的index.html便可code