Skip to content

Commit

Permalink
Merge pull request #597 from abing22333/master
Browse files Browse the repository at this point in the history
fix: #573
  • Loading branch information
shalousun authored Sep 11, 2023
2 parents cd4ef33 + c93ad3c commit 18918a1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/com/power/doc/template/IRestDocTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,11 @@ default List<ApiMethodDoc> buildEntryPointMethod(
methodOrder++;
apiMethodDoc.setOrder(methodOrder);
apiMethodDoc.setName(method.getName());
apiMethodDoc.setDesc(method.getComment());
String common = method.getComment();
if (StringUtil.isEmpty(common)) {
common = JavaClassUtil.getSameSignatureMethodCommonFromInterface(cls, method);
}
apiMethodDoc.setDesc(common);
apiMethodDoc.setAuthor(docJavaMethod.getAuthor());
apiMethodDoc.setDetail(docJavaMethod.getDetail());
String methodUid = DocUtil.generateId(clazName + method.getName() + methodOrder);
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/power/doc/utils/JavaClassUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,30 @@ private static List<DocJavaField> getFields(JavaClass cls1, int counter, Map<Str
}


/**
* Get Common for methods with the same signature from interfaces
* @param cls cls
* @param method method
* @return common
*/
public static String getSameSignatureMethodCommonFromInterface(JavaClass cls, JavaMethod method) {

List<JavaMethod> methodsBySignature = cls.getMethodsBySignature(method.getName(), method.getParameterTypes(), true, method.isVarArgs());

for (JavaMethod sameSignatureMethod : methodsBySignature) {
if (sameSignatureMethod == method
|| sameSignatureMethod.getDeclaringClass() == null
|| !sameSignatureMethod.getDeclaringClass().isInterface()) {
continue;
}
if (sameSignatureMethod.getComment() != null){
return sameSignatureMethod.getComment();
}
}
return null;
}


/**
* get enum value
*
Expand Down

0 comments on commit 18918a1

Please sign in to comment.