From 66ef399a89203c55720ba7978342dc95258d3dd9 Mon Sep 17 00:00:00 2001
From: oppofind <836575280@qq.com>
Date: Wed, 25 Dec 2019 23:19:45 +0800
Subject: [PATCH] update README and fix #19
---
README.md | 37 ++++++++++++++++++++++++++-----------
README_CN.md | 31 +++++++++++++++++++------------
2 files changed, 45 insertions(+), 23 deletions(-)
diff --git a/README.md b/README.md
index 98d1ab2..16a007a 100644
--- a/README.md
+++ b/README.md
@@ -31,21 +31,42 @@ which looks a html like generated by `asciidoctor-maven-plugin` plugin.
com.github.shalousun
smart-doc
- 1.7.9
+ 1.8.0
test
```
#### gradle
```
-testCompile 'com.github.shalousun:smart-doc:1.7.9'
+testCompile 'com.github.shalousun:smart-doc:1.8.0'
```
### Create a unit test
Just running a unit test will allow Smart-doc to generate a very concise api document for you,
which is much simpler than swagger.
+
+```
+public class ApiDocTest {
+
+ @Test
+ public void testBuilderControllersApi() {
+ ApiConfig config = new ApiConfig();
+
+ //If the strict mode is set to true, Smart-doc forces that the public method in each interface in the code has a comment.
+ config.setStrict(true);
+
+ //When AllInOne is set to true, the document generation of all interfaces is merged into a Markdown or AsciiDoc document,
+ // and the error code list is output to the bottom of the document.
+ config.setAllInOne(true);
+
+ //Set the api document output path.
+ config.setOutPath("d:\\md");
+
+ //Generating Markdown documentation
+ ApiDocBuilder.builderControllersApi(config);
+ }
+}
+```
+**Detailed use case:**
```
-/**
- * @author yu 2018/06/11.
- */
public class ApiDocTest {
@Test
@@ -81,7 +102,6 @@ public class ApiDocTest {
ApiReqHeader.header().setName("user_uuid").setType("string").setDesc("User Uuid key")
);
-
//Output a list of error codes in the project, using for example:
List errorCodeList = new ArrayList<>();
for (ErrorCodeEnum codeEnum : ErrorCodeEnum.values()) {
@@ -105,13 +125,8 @@ public class ApiDocTest {
ApiDataDictionary.dict().setTitle("Order status").setEnumClass(OrderEnum.class).setCodeField("code").setDescField("desc"),
ApiDataDictionary.dict().setTitle("Order status1").setEnumClass(OrderEnum.class).setCodeField("code").setDescField("desc")
);
-
- long start = System.currentTimeMillis();
//Generating Markdown documentation
ApiDocBuilder.builderControllersApi(config);
-
- long end = System.currentTimeMillis();
- DateTimeUtil.printRunTime(end, start);
}
}
```
diff --git a/README_CN.md b/README_CN.md
index 611de87..0dfe49a 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -30,28 +30,35 @@ smart-doc使用和测试可参考[smart-doc demo](https://gitee.com/sunyureposit
com.github.shalousun
smart-doc
- 1.7.9
+ 1.8.0
test
```
#### gradle
```
-testCompile 'com.github.shalousun:smart-doc:1.7.9'
+testCompile 'com.github.shalousun:smart-doc:1.8.0'
```
### Create a unit test
-通过运行一个单元测试来让Smart-doc为你生成一个简洁明了的api文档
+通过运行一个单元测试来让Smart-doc为你生成一个简洁明了的api文档,最简单例子如下:
+
+```
+@Test
+public void testBuilderControllersApi() {
+ ApiConfig config = new ApiConfig();
+ //true会严格要求代码中必须有java注释,首次体验可关闭,正式产品推荐设置true
+ config.setStrict(true);
+ //当把AllInOne设置为true时,Smart-doc将会把所有接口生成到一个Markdown、HHTML或者AsciiDoc中
+ config.setAllInOne(true);
+ //Set the api document output path.
+ config.setOutPath("d:\\md");
+ //生成Markdown文件
+ ApiDocBuilder.builderControllersApi(config);
+}
+```
+**详细用例:**
```
-/**
- * Description:
- * ApiDoc测试
- *
- * @author yu 2018/06/11.
- */
public class ApiDocTest {
- /**
- * 包括设置请求头,缺失注释的字段批量在文档生成期使用定义好的注释
- */
@Test
public void testBuilderControllersApi() {
ApiConfig config = new ApiConfig();