简介
smart-doc 是一款Java接口文档生成工具,不会使用任何注解侵入业务代码中
注意:我们项目中的类、方法、属性,都必须使用文档注释!
配置文件
resource 目录下新建一个 smart-doc.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| { "serverUrl": "http://localhost:8080", "pathPrefix": "", "allInOne": true, "outPath": "D://projectDoc", "style": "xt256", "createDebugPage": false, "revisionLogs": [ { "version": "1.0", "revisionTime": "2023-11-09 10:30", "status": "创建", "author": "luckyNwa", "remarks": "xxx管理系统" } ] }
|
配置说明
allInOne: 设为 true 时生成单个 index.html 文件;设为 false 时生成 api.html、dict.html 和 error.html 多个文件
createDebugPage: 设为 true 后,双击 smart-doc:html 选项可生成带接口调用功能的文档,双击 debug-all.html 即可使用
高级配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| { "isStrict": false, "style": "xt256", "pathPrefix": "/ffee-wiring", "showAuthor": true, "requestFieldToUnderline": true, "responseFieldToUnderline": true, "inlineEnum": true, "ignoreRequestParams": [ "org.springframework.ui.ModelMap" ], "requestHeaders": [ { "name": "token", "type": "string", "desc": "desc", "value": "token 请求头的值", "required": false, "since": "-", "pathPatterns": "/app/test/**", "excludePathPatterns": "/app/page/**" } ] }
|
Maven 插件配置
在 pom.xml 文件的 plugins 标签中添加:
1 2 3 4 5 6 7 8 9
| <plugin> <groupId>com.github.shalousun</groupId> <artifactId>smart-doc-maven-plugin</artifactId> <version>2.6.4</version> <configuration> <configFile>./src/main/resources/smart-doc.json</configFile> <projectName>员工系统接口文档</projectName> </configuration> </plugin>
|
生成文档
项目右侧的 maven 打开,查找这个插件,双击 smart-doc:html 就可以生成 html 格式的接口文档