Skip to content

Commit 08bfa50

Browse files
johnmarquez12jm041977
and
jm041977
authored
Enhancement for docprocessor (#5028)
Co-authored-by: jm041977 <john.marquez@broadcom.com>
1 parent 01b88fe commit 08bfa50

File tree

3 files changed

+74
-6
lines changed

3 files changed

+74
-6
lines changed

ext/wadl-doclet/src/main/java12/org/glassfish/jersey/wadl/doclet/DocProcessor.java

+43-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,6 +16,7 @@
1616

1717
package org.glassfish.jersey.wadl.doclet;
1818

19+
import jdk.javadoc.doclet.DocletEnvironment;
1920
import org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ClassDocType;
2021
import org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.MethodDocType;
2122
import org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ParamDocType;
@@ -60,6 +61,7 @@ public interface DocProcessor {
6061
* @param classDocType the {@link ClassDocType} to extend. This will later be processed by the
6162
* {@link org.glassfish.jersey.server.wadl.WadlGenerator}s.
6263
*/
64+
@Deprecated
6365
void processClassDoc(TypeElement classDoc, ClassDocType classDocType);
6466

6567
/**
@@ -69,6 +71,7 @@ public interface DocProcessor {
6971
* @param methodDocType the related {@link MethodDocType} that will later be processed by the
7072
* {@link org.glassfish.jersey.server.wadl.WadlGenerator}s.
7173
*/
74+
@Deprecated
7275
void processMethodDoc(ExecutableElement methodDoc, MethodDocType methodDocType);
7376

7477
/**
@@ -79,6 +82,45 @@ public interface DocProcessor {
7982
* @param paramDocType the {@link ParamDocType} to extend. This will later be processed by the
8083
* {@link org.glassfish.jersey.server.wadl.WadlGenerator}s.
8184
*/
85+
@Deprecated
8286
void processParamTag(VariableElement parameter, ParamDocType paramDocType);
8387

88+
/**
89+
* Use this method to extend the provided {@link ClassDocType} with the information from
90+
* the given {@link TypeElement}.
91+
*
92+
* @param classDoc the class javadoc
93+
* @param classDocType the {@link ClassDocType} to extend. This will later be processed by the
94+
* {@link org.glassfish.jersey.server.wadl.WadlGenerator}s.
95+
* @param docEnv the doclet environment used to extract info from classDoc
96+
*/
97+
default void processClassDocWithDocEnv(TypeElement classDoc, ClassDocType classDocType, DocletEnvironment docEnv) {
98+
processClassDoc(classDoc, classDocType);
99+
}
100+
101+
/**
102+
* Process the provided methodDoc and add your custom information to the methodDocType.<br>
103+
*
104+
* @param methodDoc the {@link ExecutableElement} representing the docs of your method.
105+
* @param methodDocType the related {@link MethodDocType} that will later be processed by the
106+
* {@link org.glassfish.jersey.server.wadl.WadlGenerator}s.
107+
* @param docEnv the doclet environment used to extract info from methodDoc
108+
*/
109+
default void processMethodDocWithDocEnv(ExecutableElement methodDoc, MethodDocType methodDocType, DocletEnvironment docEnv) {
110+
processMethodDoc(methodDoc, methodDocType);
111+
}
112+
113+
/**
114+
* Use this method to extend the provided {@link ParamDocType} with the information from the
115+
* given {@link VariableElement}.
116+
*
117+
* @param parameter the parameter (that is documented or not)
118+
* @param paramDocType the {@link ParamDocType} to extend. This will later be processed by the
119+
* {@link org.glassfish.jersey.server.wadl.WadlGenerator}s.
120+
* @param docEnv the Doclet Environment used to extract info from parameter
121+
*/
122+
default void processParamTagWithDocEnv(VariableElement parameter, ParamDocType paramDocType, DocletEnvironment docEnv) {
123+
processParamTag(parameter, paramDocType);
124+
}
125+
84126
}

ext/wadl-doclet/src/main/java12/org/glassfish/jersey/wadl/doclet/DocProcessorWrapper.java

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -20,13 +20,13 @@
2020
import java.util.Arrays;
2121
import java.util.List;
2222

23+
import jdk.javadoc.doclet.DocletEnvironment;
2324
import org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ClassDocType;
2425
import org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.MethodDocType;
2526
import org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ParamDocType;
2627

2728
import javax.lang.model.element.TypeElement;
2829
import javax.lang.model.element.ExecutableElement;
29-
import com.sun.source.doctree.ParamTree;
3030
import javax.lang.model.element.VariableElement;
3131

3232
public class DocProcessorWrapper implements DocProcessor {
@@ -96,4 +96,30 @@ public void processParamTag(VariableElement parameter,
9696
}
9797
}
9898

99+
@Override
100+
public void processClassDocWithDocEnv(TypeElement classDoc,
101+
ClassDocType classDocType,
102+
DocletEnvironment docEnv) {
103+
for (DocProcessor docProcessor : _docProcessors) {
104+
docProcessor.processClassDocWithDocEnv(classDoc, classDocType, docEnv);
105+
}
106+
}
107+
108+
@Override
109+
public void processMethodDocWithDocEnv(ExecutableElement methodDoc,
110+
MethodDocType methodDocType,
111+
DocletEnvironment docEnv) {
112+
for (DocProcessor docProcessor : _docProcessors) {
113+
docProcessor.processMethodDocWithDocEnv(methodDoc, methodDocType, docEnv);
114+
}
115+
}
116+
117+
@Override
118+
public void processParamTagWithDocEnv(VariableElement parameter,
119+
ParamDocType paramDocType,
120+
DocletEnvironment docEnv) {
121+
for (DocProcessor docProcessor : _docProcessors) {
122+
docProcessor.processParamTagWithDocEnv(parameter, paramDocType, docEnv);
123+
}
124+
}
99125
}

ext/wadl-doclet/src/main/java12/org/glassfish/jersey/wadl/doclet/ResourceDoclet.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public boolean run(DocletEnvironment docEnv) {
157157
ClassDocType classDocType = new ClassDocType();
158158
classDocType.setClassName(element.getQualifiedName().toString());
159159
classDocType.setCommentText(getComments(docCommentTree));
160-
docProcessor.processClassDoc(element, classDocType);
160+
docProcessor.processClassDocWithDocEnv(element, classDocType, docEnv);
161161
for (ExecutableElement method : ElementFilter.methodsIn(element.getEnclosedElements())) {
162162
Map<DocTree.Kind, Map<String, String>> tags = getTags(docTrees.getDocCommentTree(method));
163163
MethodTree methodTree = docTrees.getTree(method);
@@ -174,7 +174,7 @@ public boolean run(DocletEnvironment docEnv) {
174174
arguments.append(parameter.asType()).append(COMA);
175175
if (paramDocType != null) {
176176
methodDocType.getParamDocs().add(paramDocType);
177-
docProcessor.processParamTag(parameter, paramDocType);
177+
docProcessor.processParamTagWithDocEnv(parameter, paramDocType, docEnv);
178178
}
179179
}
180180
// Remove last comma if there are parameters
@@ -183,7 +183,7 @@ public boolean run(DocletEnvironment docEnv) {
183183
}
184184
arguments.append(")");
185185
methodDocType.setMethodSignature(arguments.toString());
186-
docProcessor.processMethodDoc(method, methodDocType);
186+
docProcessor.processMethodDocWithDocEnv(method, methodDocType, docEnv);
187187
methodDocType.setRequestDoc(buildRequestDocType(tags));
188188
methodDocType.setResponseDoc(buildResponseDocType(tags));
189189
classDocType.getMethodDocs().add(methodDocType);

0 commit comments

Comments
 (0)