Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.

Commit a057f4b

Browse files
committed
feat(template): ✨ add method to skip documentation for specific methods
- Add `skipMethod` method to `IJavadocDocTemplate` interface - Implement method to filter out methods that should not be documented - Update method processing logic to use the new skipMethod check - Optimize list initialization in methodMap
1 parent d7fb224 commit a057f4b

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

src/main/java/com/ly/doc/template/IJavadocDocTemplate.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,13 @@ default List<T> buildServiceMethod(final JavaClass cls, ApiConfig apiConfig,
356356
if (Objects.nonNull(method.getTagByName(IGNORE))) {
357357
continue;
358358
}
359+
360+
// skip method
361+
boolean skipMethod = this.skipMethod(cls, method, apiConfig, projectBuilder);
362+
if (skipMethod) {
363+
continue;
364+
}
365+
359366
if (StringUtil.isEmpty(method.getComment()) && apiConfig.isStrict()) {
360367
throw new RuntimeException(
361368
"Unable to find comment for method " + method.getName() + " in " + cls.getCanonicalName());
@@ -394,7 +401,7 @@ default List<T> buildServiceMethod(final JavaClass cls, ApiConfig apiConfig,
394401
Function.identity(), this::mergeJavadocMethods, LinkedHashMap::new));
395402

396403
int methodOrder = 0;
397-
List<T> javadocJavaMethods = new ArrayList<>(methodMap.values().size());
404+
List<T> javadocJavaMethods = new ArrayList<>(methodMap.size());
398405
for (T method : methodMap.values()) {
399406
methodOrder++;
400407
method.setOrder(methodOrder);
@@ -443,4 +450,29 @@ default T mergeJavadocMethods(T existing, T replacement) {
443450
return existing;
444451
}
445452

453+
/**
454+
* Determines whether the specified method should be skipped during documentation
455+
* generation.
456+
* <p>
457+
* If this method returns {@code true}, the method will be excluded from the generated
458+
* documentation. If it returns {@code false}, the method will be included.
459+
* </p>
460+
* <p>
461+
* The default implementation always returns {@code false}, meaning no methods are
462+
* skipped by default. Subclasses may override this method to provide custom logic for
463+
* excluding certain methods.
464+
* </p>
465+
* @param cls The Java class containing the method.
466+
* @param method The Java method to check.
467+
* @param apiConfig The API configuration object, used to control documentation
468+
* behavior.
469+
* @param projectBuilder The project documentation configuration builder.
470+
* @return {@code true} if the method should be skipped (not documented),
471+
* {@code false} if it should be included.
472+
*/
473+
default boolean skipMethod(final JavaClass cls, final JavaMethod method, ApiConfig apiConfig,
474+
ProjectDocConfigBuilder projectBuilder) {
475+
return false;
476+
}
477+
446478
}

0 commit comments

Comments
 (0)