feat show author

This commit is contained in:
songhaozhi 2019-12-15 15:48:43 +08:00
parent 1361c449be
commit b0dfa64272
8 changed files with 49 additions and 33 deletions

View File

@ -60,25 +60,26 @@ public class SourceBuilder {
private String appUrl;
private boolean isUseMD5;
private boolean isAdoc;
private boolean isShowAuthor;
/**
* if isStrict value is true,it while check all method
*
* @param isStrict strict flag
* @param isStrict strict flag
* @param projectBuilder JavaProjectBuilder
*/
public SourceBuilder(boolean isStrict,JavaProjectBuilder projectBuilder) {
loadJavaFiles(null,projectBuilder);
public SourceBuilder(boolean isStrict, JavaProjectBuilder projectBuilder) {
loadJavaFiles(null, projectBuilder);
this.isStrict = isStrict;
}
/**
* use custom config
*
* @param config config
* @param config config
* @param projectBuilder JavaProjectBuilder
*/
public SourceBuilder(ApiConfig config,JavaProjectBuilder projectBuilder) {
public SourceBuilder(ApiConfig config, JavaProjectBuilder projectBuilder) {
if (null == config) {
throw new NullPointerException("ApiConfig can't be null.");
}
@ -93,7 +94,8 @@ public class SourceBuilder {
this.packageMatch = config.getPackageFilters();
this.isStrict = config.isStrict();
this.isAdoc = config.isAdoc();
loadJavaFiles(config.getSourceCodePaths(),projectBuilder);
this.isShowAuthor = config.isShowAuthor();
loadJavaFiles(config.getSourceCodePaths(), projectBuilder);
this.headers = config.getRequestHeaders();
if (CollectionUtil.isNotEmpty(config.getCustomResponseFields())) {
@ -183,6 +185,10 @@ public class SourceBuilder {
if (StringUtil.isEmpty(apiNoteValue)) {
apiNoteValue = method.getComment();
}
String authorValue = DocUtil.getNormalTagComments(method, DocTags.AUTHOR, cls.getName());
if(this.isShowAuthor && StringUtil.isNotEmpty(authorValue)){
apiMethodDoc.setAuthor(authorValue);
}
apiMethodDoc.setDetail(apiNoteValue);
List<JavaAnnotation> annotations = method.getAnnotations();
String url = null;
@ -324,8 +330,8 @@ public class SourceBuilder {
*
* @param paths list of SourcePath
*/
private void loadJavaFiles(List<SourceCodePath> paths,JavaProjectBuilder builder) {
if(Objects.isNull(builder)) {
private void loadJavaFiles(List<SourceCodePath> paths, JavaProjectBuilder builder) {
if (Objects.isNull(builder)) {
builder = new JavaProjectBuilder();
}
if (CollectionUtil.isEmpty(paths)) {
@ -1289,7 +1295,7 @@ public class SourceBuilder {
|| DocAnnotationConstants.SHORT_REST_CONTROLLER.equals(annotationName)
|| DocGlobalConstants.REST_CONTROLLER_FULLY.equals(annotationName)
|| DocGlobalConstants.CONTROLLER_FULLY.equals(annotationName)
) {
) {
return true;
}
}

View File

@ -25,6 +25,11 @@ public class DocTags {
*/
public static final String API_NOTE = "apiNote";
/**
* java author tag for method author
*/
public static final String AUTHOR = "author";
/**
* custom ignore tag
*/

View File

@ -52,6 +52,11 @@ public class ApiMethodDoc implements Serializable {
*/
private String type;
/**
* http request author
*/
private String author;
/**
* only used for generate markdown and adoc
* http readers
@ -201,4 +206,12 @@ public class ApiMethodDoc implements Serializable {
public void setDetail(String detail) {
this.detail = detail;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
}

View File

@ -27,7 +27,9 @@ for(doc in api.list){
*URL:* ${doc.url}
*Type:* ${doc.type}
<%if(isNotEmpty(doc.author)){%>
*Author:* ${doc.author}
<%}%>
*Description:* ${doc.detail}
*Content-Type:* ${doc.contentType}

View File

@ -25,6 +25,10 @@ for(doc in api.list){
**Type:** ${doc.type}
<%if(isNotEmpty(doc.author)){%>
**Author:** ${doc.author}
<%}%>
**Content-Type:** ${doc.contentType}
**Description:** ${doc.detail}

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,10 @@ for(doc in list){
*Type:* `${doc.type}`
<%if(isNotEmpty(doc.author)){%>
*Author:* ${doc.author}
<%}%>
*Content-Type:* `${doc.contentType}`
*Description:* ${doc.detail}

View File

@ -8,6 +8,10 @@ for(doc in list){
**Type:** `${doc.type}`
<%if(isNotEmpty(doc.author)){%>
**Author:** ${doc.author}
<%}%>
**Content-Type:** `${doc.contentType}`
**Description:** ${doc.detail}