upgrade 1.7.5

This commit is contained in:
oppofind 2019-11-06 15:53:13 +08:00
parent 250b0189a8
commit bc5dd886b0
9 changed files with 41 additions and 28 deletions

View File

@ -28,13 +28,13 @@ which looks a html like generated by `asciidoctor-maven-plugin` plugin.
<dependency>
<groupId>com.github.shalousun</groupId>
<artifactId>smart-doc</artifactId>
<version>1.7.4</version>
<version>1.7.5</version>
<scope>test</scope>
</dependency>
```
#### gradle
```
testCompile 'com.github.shalousun:smart-doc:1.7.4'
testCompile 'com.github.shalousun:smart-doc:1.7.5'
```
### Create a unit test
Just running a unit test will allow Smart-doc to generate a very concise api document for you,
@ -96,6 +96,13 @@ public class ApiDocTest {
RevisionLog.getLog().setRevisionTime("2018/12/16").setAuthor("chen2").setRemarks("test2").setStatus("update").setVersion("V2.0")
);
//since 1.7.5
//add data dictionary
config.setDataDictionaries(
ApiDataDictionary.dict().setTitle("Order status").setEnumClass(OrderEnum.class).setValueField("code").setDescField("desc"),
ApiDataDictionary.dict().setTitle("Order status1").setEnumClass(OrderEnum.class).setValueField("code").setDescField("desc")
);
long start = System.currentTimeMillis();
//Generating Markdown documentation
ApiDocBuilder.builderControllersApi(config);

View File

@ -29,13 +29,13 @@ smart-doc使用和测试可参考[smart-doc demo](https://gitee.com/sunyureposit
<dependency>
<groupId>com.github.shalousun</groupId>
<artifactId>smart-doc</artifactId>
<version>1.7.4</version>
<version>1.7.5</version>
<scope>test</scope>
</dependency>
```
#### gradle
```
testCompile 'com.github.shalousun:smart-doc:1.7.4'
testCompile 'com.github.shalousun:smart-doc:1.7.5'
```
### Create a unit test
通过运行一个单元测试来让Smart-doc为你生成一个简洁明了的api文档
@ -110,6 +110,13 @@ public class ApiDocTest {
RevisionLog.getLog().setRevisionTime("2018/12/16").setAuthor("chen2").setRemarks("测试2").setStatus("修改").setVersion("V2.0")
);
//since 1.7.5
//文档添加数据字典
config.setDataDictionaries(
ApiDataDictionary.dict().setTitle("订单状态").setEnumClass(OrderEnum.class).setValueField("code").setDescField("desc"),
ApiDataDictionary.dict().setTitle("订单状态1").setEnumClass(OrderEnum.class).setValueField("code").setDescField("desc")
);
long start = System.currentTimeMillis();
ApiDocBuilder.builderControllersApi(config);

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>smart-doc</artifactId>
<packaging>jar</packaging>
<version>1.7.4</version>
<version>1.7.5</version>
<name>smart-doc</name>
<url>https://github.com/shalousun/smart-doc.git</url>
@ -59,7 +59,7 @@
<dependency>
<groupId>com.github.shalousun</groupId>
<artifactId>common-util</artifactId>
<version>1.8.7</version>
<version>1.8.8</version>
</dependency>
<!--markdown to html-->
<dependency>

View File

@ -172,11 +172,11 @@ public class DocBuilderTemplate {
* @return list of ApiDocDict
*/
public List<ApiDocDict> buildDictionary(ApiConfig config) {
List<ApiDataDictConfig> apiDataDictionaryList = config.getDataDictConfigs();
List<ApiDataDictionary> apiDataDictionaryList = config.getDataDictionaries();
List<ApiDocDict> apiDocDictList = new ArrayList<>();
try {
int order = 0;
for (ApiDataDictConfig apiDataDictionary : apiDataDictionaryList) {
for (ApiDataDictionary apiDataDictionary : apiDataDictionaryList) {
order++;
ApiDocDict apiDocDict = new ApiDocDict();
apiDocDict.setOrder(order);

View File

@ -268,7 +268,7 @@ public class SourceBuilder {
if (null != method.getTagByName(IGNORE_TAG)) {
continue;
}
url = url.replaceAll("\"", "").trim();
url = StringUtil.removeQuotes(url);
apiMethodDoc.setType(methodType);
url = this.appUrl + "/" + baseUrl + "/" + url;
apiMethodDoc.setUrl(UrlUtil.simplifyUrl(url));
@ -918,7 +918,6 @@ public class SourceBuilder {
}
boolean containsBrace = apiMethodDoc.getUrl().contains("{");
Map<String, String> paramsMap = new LinkedHashMap<>();
boolean hasFile = false;
for (JavaParameter parameter : parameterList) {
JavaType javaType = parameter.getType();
String simpleTypeName = javaType.getValue();

View File

@ -94,7 +94,7 @@ public class ApiConfig {
/**
* api data dictionary
*/
private List<ApiDataDictConfig> dataDictConfigs;
private List<ApiDataDictionary> dataDictionaries;
/**
* @since 1.7.5
@ -209,12 +209,12 @@ public class ApiConfig {
this.adoc = adoc;
}
public List<ApiDataDictConfig> getDataDictConfigs() {
return dataDictConfigs;
public List<ApiDataDictionary> getDataDictionaries() {
return dataDictionaries;
}
public void setDataDictConfigs(ApiDataDictConfig... dataDictConfigs) {
this.dataDictConfigs = CollectionUtil.asList(dataDictConfigs);
public void setDataDictionaries(ApiDataDictionary... dataDictConfigs) {
this.dataDictionaries = CollectionUtil.asList(dataDictConfigs);
}
public boolean isCoverOld() {

View File

@ -3,7 +3,7 @@ package com.power.doc.model;
/**
* @author yu 2019/10/31.
*/
public class ApiDataDictConfig {
public class ApiDataDictionary {
/**
* Dictionary
@ -31,15 +31,15 @@ public class ApiDataDictConfig {
private String descField;
public static ApiDataDictConfig dict() {
return new ApiDataDictConfig();
public static ApiDataDictionary dict() {
return new ApiDataDictionary();
}
public String getTitle() {
return title;
}
public ApiDataDictConfig setTitle(String title) {
public ApiDataDictionary setTitle(String title) {
this.title = title;
return this;
}
@ -48,7 +48,7 @@ public class ApiDataDictConfig {
return enumClass;
}
public ApiDataDictConfig setEnumClass(Class enumClass) {
public ApiDataDictionary setEnumClass(Class enumClass) {
this.enumClass = enumClass;
return this;
}
@ -57,7 +57,7 @@ public class ApiDataDictConfig {
return valueField;
}
public ApiDataDictConfig setValueField(String valueField) {
public ApiDataDictionary setValueField(String valueField) {
this.valueField = valueField;
return this;
}
@ -66,7 +66,7 @@ public class ApiDataDictConfig {
return descField;
}
public ApiDataDictConfig setDescField(String descField) {
public ApiDataDictionary setDescField(String descField) {
this.descField = descField;
return this;
}
@ -75,7 +75,7 @@ public class ApiDataDictConfig {
return enumClassName;
}
public ApiDataDictConfig setEnumClassName(String enumClassName) {
public ApiDataDictionary setEnumClassName(String enumClassName) {
this.enumClassName = enumClassName;
return this;
}

View File

@ -95,7 +95,7 @@ for(dict in dictList){
### ${dict.title}
Code |Type|Description
---|---
---|---|---
<%
for(dataDict in dict.dataDictList){
%>

View File

@ -52,8 +52,8 @@ public class ApiDocTest {
//SourcePath.path().setPath("F:\\Personal\\project\\smart\\src\\main\\java")
//SourcePath.path().setDesc("加载项目外代码").setPath("E:\\ApplicationPower\\ApplicationPower\\Common-util\\src\\main\\java")
);
config.setDataDictConfigs(
ApiDataDictConfig.dict().setTitle("订单字典").setEnumClass(OrderEnum.class).setValueField("code").setDescField("desc")
config.setDataDictionaries(
ApiDataDictionary.dict().setTitle("订单字典").setEnumClass(OrderEnum.class).setValueField("code").setDescField("desc")
);
//设置请求头如果没有请求头可以不用设置
/* config.setRequestHeaders(
@ -76,11 +76,11 @@ public class ApiDocTest {
RevisionLog.getLog().setRevisionTime("2018/12/16").setAuthor("chen2").setRemarks("测试2").setStatus("修改").setVersion("V2.0")
);
List<ApiDataDictConfig> apiDataDictionaryList = config.getDataDictConfigs();
List<ApiDataDictionary> apiDataDictionaryList = config.getDataDictionaries();
try {
List<ApiDocDict> apiDocDictList = new ArrayList<>();//模板中遍历这个字典表生成字典文档
int order = 0;
for (ApiDataDictConfig apiDataDictionary : apiDataDictionaryList) {
for (ApiDataDictionary apiDataDictionary : apiDataDictionaryList) {
System.out.println("dictionary" + apiDataDictionary.getTitle());
order++;
ApiDocDict apiDocDict = new ApiDocDict();