apiDoc
全局安装,方便用命令创建文档
配置
在你的项目根目录下新建apidoc.json文件,该文件描述了项目对外提供接口的概要信息如名称、版本、描述、文档打开时浏览器显示标题和接口缺省访问地址。
apidoc.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| { "name": "xxx Api", "version": "1.0.0", "description": "xxx Api Documentation", "title": "xxx", "url" : "http://域名/api/v1", "sampleUrl": "http://域名/api/v1",
"template": { "withCompare": true, "withGenerator": true, "forceLanguage":"en" }, //顺序、若有需要可配置(books, student,xxx) Resources Name "order": ["xxx","xxx"] }
|
Sample
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
|
生成
文档初始化或发生改变时,在应用程序根目录执行相应命令
以此项目为例:
apidoc -i api/v1 -o public/apiDoc
1 2 3 4
| -i input -o output
指定文件夹路径
|
具体注释写法参照官网解释:
http://apidocjs.com/#run
public/apiDoc内文件不用上传到代码管理中
可直接执行npm run doc命令自动生成