Merge branch 'dev'
This commit is contained in:
commit
539c214723
2
pom.xml
2
pom.xml
|
@ -5,7 +5,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>smart-doc</artifactId>
|
<artifactId>smart-doc</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>1.9.3</version>
|
<version>1.9.4</version>
|
||||||
|
|
||||||
<name>smart-doc</name>
|
<name>smart-doc</name>
|
||||||
<url>https://github.com/smart-doc-group/smart-doc.git</url>
|
<url>https://github.com/smart-doc-group/smart-doc.git</url>
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
package com.power.doc.template;
|
package com.power.doc.template;
|
||||||
|
|
||||||
import com.power.common.util.StringUtil;
|
import com.power.common.util.StringUtil;
|
||||||
|
import com.power.common.util.ValidateUtil;
|
||||||
import com.power.doc.builder.ProjectDocConfigBuilder;
|
import com.power.doc.builder.ProjectDocConfigBuilder;
|
||||||
import com.power.doc.constants.DocAnnotationConstants;
|
import com.power.doc.constants.DocAnnotationConstants;
|
||||||
import com.power.doc.constants.DocGlobalConstants;
|
import com.power.doc.constants.DocGlobalConstants;
|
||||||
|
@ -41,6 +42,8 @@ import com.power.doc.utils.JavaClassValidateUtil;
|
||||||
import com.thoughtworks.qdox.model.*;
|
import com.thoughtworks.qdox.model.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.power.doc.constants.DocTags.IGNORE;
|
import static com.power.doc.constants.DocTags.IGNORE;
|
||||||
|
|
||||||
|
@ -49,28 +52,42 @@ import static com.power.doc.constants.DocTags.IGNORE;
|
||||||
*/
|
*/
|
||||||
public class RpcDocBuildTemplate implements IDocBuildTemplate<RpcApiDoc> {
|
public class RpcDocBuildTemplate implements IDocBuildTemplate<RpcApiDoc> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* api index
|
||||||
|
*/
|
||||||
|
private final AtomicInteger atomicInteger = new AtomicInteger(1);
|
||||||
|
|
||||||
public List<RpcApiDoc> getApiData(ProjectDocConfigBuilder projectBuilder) {
|
public List<RpcApiDoc> getApiData(ProjectDocConfigBuilder projectBuilder) {
|
||||||
ApiConfig apiConfig = projectBuilder.getApiConfig();
|
ApiConfig apiConfig = projectBuilder.getApiConfig();
|
||||||
List<RpcApiDoc> apiDocList = new ArrayList<>();
|
List<RpcApiDoc> apiDocList = new ArrayList<>();
|
||||||
int order = 0;
|
int order = 0;
|
||||||
|
boolean setCustomOrder = false;
|
||||||
for (JavaClass cls : projectBuilder.getJavaProjectBuilder().getClasses()) {
|
for (JavaClass cls : projectBuilder.getJavaProjectBuilder().getClasses()) {
|
||||||
if (!checkDubboInterface(cls)) {
|
if (!checkDubboInterface(cls)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (StringUtil.isNotEmpty(apiConfig.getPackageFilters())) {
|
if (StringUtil.isNotEmpty(apiConfig.getPackageFilters())) {
|
||||||
if (DocUtil.isMatch(apiConfig.getPackageFilters(), cls.getCanonicalName())) {
|
if (!DocUtil.isMatch(apiConfig.getPackageFilters(), cls.getCanonicalName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String strOrder = JavaClassUtil.getClassTagsValue(cls, DocTags.ORDER, Boolean.TRUE);
|
||||||
order++;
|
order++;
|
||||||
|
if (ValidateUtil.isNonnegativeInteger(strOrder)) {
|
||||||
|
order = Integer.parseInt(strOrder);
|
||||||
|
setCustomOrder = true;
|
||||||
|
}
|
||||||
List<JavaMethodDoc> apiMethodDocs = buildServiceMethod(cls, apiConfig, projectBuilder);
|
List<JavaMethodDoc> apiMethodDocs = buildServiceMethod(cls, apiConfig, projectBuilder);
|
||||||
this.handleJavaApiDoc(cls, apiDocList, apiMethodDocs, order, projectBuilder);
|
this.handleJavaApiDoc(cls, apiDocList, apiMethodDocs, order, projectBuilder);
|
||||||
}
|
}
|
||||||
} else {
|
// sort
|
||||||
order++;
|
|
||||||
List<JavaMethodDoc> apiMethodDocs = buildServiceMethod(cls, apiConfig, projectBuilder);
|
|
||||||
this.handleJavaApiDoc(cls, apiDocList, apiMethodDocs, order, projectBuilder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (apiConfig.isSortByTitle()) {
|
if (apiConfig.isSortByTitle()) {
|
||||||
Collections.sort(apiDocList);
|
Collections.sort(apiDocList);
|
||||||
|
} else if (setCustomOrder) {
|
||||||
|
// while set custom oder
|
||||||
|
return apiDocList.stream()
|
||||||
|
.sorted(Comparator.comparing(RpcApiDoc::getOrder))
|
||||||
|
.peek(p -> p.setOrder(atomicInteger.getAndAdd(1))).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
return apiDocList;
|
return apiDocList;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +114,7 @@ public class RpcDocBuildTemplate implements IDocBuildTemplate<RpcApiDoc> {
|
||||||
throw new RuntimeException("Unable to find comment for method " + method.getName() + " in " + cls.getCanonicalName());
|
throw new RuntimeException("Unable to find comment for method " + method.getName() + " in " + cls.getCanonicalName());
|
||||||
}
|
}
|
||||||
boolean deprecated = false;
|
boolean deprecated = false;
|
||||||
//设置当前接口是否过时
|
//Deprecated
|
||||||
List<JavaAnnotation> annotations = method.getAnnotations();
|
List<JavaAnnotation> annotations = method.getAnnotations();
|
||||||
for (JavaAnnotation annotation : annotations) {
|
for (JavaAnnotation annotation : annotations) {
|
||||||
String annotationName = annotation.getType().getName();
|
String annotationName = annotation.getType().getName();
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate<ApiDoc> {
|
||||||
/**
|
/**
|
||||||
* api index
|
* api index
|
||||||
*/
|
*/
|
||||||
private AtomicInteger atomicInteger = new AtomicInteger(1);
|
private final AtomicInteger atomicInteger = new AtomicInteger(1);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ApiDoc> getApiData(ProjectDocConfigBuilder projectBuilder) {
|
public List<ApiDoc> getApiData(ProjectDocConfigBuilder projectBuilder) {
|
||||||
|
@ -90,13 +90,9 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate<ApiDoc> {
|
||||||
Collections.sort(apiDocList);
|
Collections.sort(apiDocList);
|
||||||
} else if (setCustomOrder) {
|
} else if (setCustomOrder) {
|
||||||
// while set custom oder
|
// while set custom oder
|
||||||
List<ApiDoc> sortedApiDoc = apiDocList.stream()
|
return apiDocList.stream()
|
||||||
.sorted(Comparator.comparing(ApiDoc::getOrder))
|
.sorted(Comparator.comparing(ApiDoc::getOrder))
|
||||||
.map(p -> {
|
.peek(p -> p.setOrder(atomicInteger.getAndAdd(1))).collect(Collectors.toList());
|
||||||
p.setOrder(atomicInteger.getAndAdd(1));
|
|
||||||
return p;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
return sortedApiDoc;
|
|
||||||
}
|
}
|
||||||
return apiDocList;
|
return apiDocList;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue