add support for since tag

This commit is contained in:
oppofind 2019-09-13 13:44:47 +08:00
parent 74d850d19f
commit f2e4d1a20f
3 changed files with 43 additions and 12 deletions

View File

@ -3,6 +3,7 @@ package com.power.doc.builder;
import com.power.common.util.CollectionUtil;
import com.power.common.util.JsonFormatUtil;
import com.power.common.util.StringUtil;
import com.power.doc.constants.DocTags;
import com.power.doc.constants.GlobalConstants;
import com.power.doc.model.*;
import com.power.doc.utils.DocClassUtil;
@ -450,11 +451,20 @@ public class SourceBuilder {
List<JavaAnnotation> javaAnnotations = field.getAnnotations();
List<DocletTag> paramTags = field.getTags();
String since = "";//since tag value
if (!isResp) {
pre:
for (DocletTag docletTag : paramTags) {
if (DocClassUtil.isIgnoreTag(docletTag.getName())) {
continue out;
} else if(DocTags.SINCE.equals(docletTag.getName())) {
since = docletTag.getValue();
}
}
} else {
for (DocletTag docletTag : paramTags) {
if(DocTags.SINCE.equals(docletTag.getName())) {
since = docletTag.getValue();
}
}
}
@ -508,15 +518,17 @@ public class SourceBuilder {
if (StringUtil.isNotEmpty(comment)) {
if (StringUtil.isEmpty(isRequired)) {
params0.append(comment).append("\n");
params0.append(comment).append("|").append(since).append("\n");
} else {
params0.append(comment).append("|").append(strRequired).append("\n");
params0.append(comment).append("|").append(strRequired)
.append("|").append(since).append("\n");
}
} else {
if (StringUtil.isEmpty(isRequired)) {
params0.append("No comments found.").append("\n");
params0.append("No comments found.").append("|").append(since).append("\n");
} else {
params0.append("No comments found.").append("|").append(strRequired).append("\n");
params0.append("No comments found.").append("|").append(strRequired)
.append("|").append(since).append("\n");
}
}
} else {
@ -525,15 +537,17 @@ public class SourceBuilder {
.append(DocClassUtil.processTypeNameForParams(typeSimpleName.toLowerCase())).append("|");
if (StringUtil.isNotEmpty(comment)) {
if (StringUtil.isEmpty(isRequired)) {
params0.append(comment).append("\n");
params0.append(comment).append("|").append(since).append("\n");
} else {
params0.append(comment).append("|").append(strRequired).append("\n");
params0.append(comment).append("|").append(strRequired)
.append("|").append(since).append("\n");
}
} else {
if (StringUtil.isEmpty(isRequired)) {
params0.append("No comments found.").append("\n");
params0.append("No comments found.").append("|").append(since).append("\n");
} else {
params0.append("No comments found|").append(strRequired).append("\n");
params0.append("No comments found|").append(strRequired)
.append("|").append(since).append("\n");
}
}

View File

@ -0,0 +1,17 @@
package com.power.doc.constants;
/**
* @author yu 2019/9/13.
*/
public class DocTags {
/**
* java since tag
*/
public static final String SINCE = "since";
/**
* java required tag
*/
public static final String REQUIRED = "required";
}

View File

@ -21,8 +21,8 @@ ${doc.headers}
<%if(isNotEmpty(doc.requestParams)){%>
**Request-parameters:**
Parameter | Type|Description|Required
---|---|---|---
Parameter | Type|Description|Required|Since
---|---|---|---|---
${doc.requestParams}
<%}%>
@ -35,8 +35,8 @@ ${doc.requestUsage}
<%if(isNotEmpty(doc.responseParams)){%>
**Response-fields:**
Field | Type|Description
---|---|---
Field | Type|Description|Since
---|---|---|---
${doc.responseParams}
<%}%>