apiDoc creates a documentation from API annotations in your source code
apiDoc是一个接口文档,它的建立方式是基于你的源代码的接口备注。咱们只须要给接口写好相应的文档,而后使用apiDoc生成接口文档工具生成文档,便于管理和查看。前端
1.安装apidoc(npm是啥???本身问前端同窗吧。。)git
npm install apidoc -g
安装http-servergithub
npm install http-server -g
2.给接口添加文档(官方示例),添加在Controller入口方法前面。npm
/** * @api {get} /user/:id Request User information * @apiName GetUser * @apiGroup User * * @apiParam {Number} id Users unique ID. * * @apiSuccess {String} firstname Firstname of the User. * @apiSuccess {String} lastname Lastname of the User. */
3.建立apidoc.json(官方示例)json
{ "name": "example", "version": "0.1.0", "description": "apiDoc basic example", "apidoc": { "title": "Custom apiDoc browser title", "url" : "https://api.github.com/v1" } }
4.生成apiDocapi
apidoc -i app/Http/Controllers -o apidoc/
5.运行app
http-server api/doc