Skip to content

Commit 679cb25

Browse files
gselzerctrueden
authored andcommitted
Comment JavadocParameterData
1 parent 91eed21 commit 679cb25

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

scijava/scijava-ops/src/main/java/org/scijava/param/JavadocParameterData.java

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,18 @@ private long getOpParams(Method m) {
165165
.filter(param -> param.getAnnotation(OpDependency.class) == null).count();
166166
}
167167

168+
/**
169+
* Determines whether {@code doc} has enough {@code @param} tags to satisfy
170+
* the number of inputs to the Op ({@code numParams}), as well as enough
171+
* {@code @return} taglets to satisfy the number of Op outputs
172+
* ({@code numReturns}).
173+
*
174+
* @param doc the {@link OtherJavadoc}s found by the javadoc parser.
175+
* @param numParams the desired number of inputs
176+
* @param numReturns the desired number of outputs
177+
* @return true iff there are {@code numParams} inputs and {@code numReturns}
178+
* outputs
179+
*/
168180
private boolean hasVanillaJavadoc(MethodJavadoc doc, long numParams, long numReturns) {
169181
// We require a @param tag for each of the method parameters
170182
boolean sufficientParams = doc.getParams().size() == numParams;
@@ -175,6 +187,19 @@ private boolean hasVanillaJavadoc(MethodJavadoc doc, long numParams, long numRet
175187
return sufficientParams && sufficientReturn;
176188
}
177189

190+
/**
191+
* Determines whether {@code doc} has enough
192+
* {@code @input/@container/@mutable} tags to satisfy the number of inputs to
193+
* the Op ({@code numIns}), as well as enough
194+
* {@code @container/@mutable/@output} taglets to satisfy the number of Op
195+
* outputs ({@code numOuts}).
196+
*
197+
* @param doc the {@link OtherJavadoc}s found by the javadoc parser.
198+
* @param numIns the desired number of inputs
199+
* @param numOuts the desired number of outputs
200+
* @return true iff there are {@code numIns} inputs and {@code numOuts}
201+
* outputs
202+
*/
178203
private boolean hasCustomJavadoc(List<OtherJavadoc> doc, long numIns, long numOuts) {
179204
int ins = 0, outs = 0;
180205
for (OtherJavadoc other : doc) {
@@ -199,12 +224,29 @@ private boolean hasCustomJavadoc(List<OtherJavadoc> doc, long numIns, long numOu
199224
return sufficientIns && sufficientOuts;
200225
}
201226

227+
/**
228+
* Populates {@link JavadocParameterData#paramNames} and
229+
* {@link JavadocParameterData#paramDescriptions} using {@code params}, and
230+
* {@link JavadocParameterData#returnDescription} using {@code returnDoc}.
231+
*
232+
* @param params the {@code @param} tags on the method of interest
233+
* @param returnDoc the string following {@code @return}
234+
*/
202235
private void populateViaParamAndReturn(List<ParamJavadoc> params, Comment returnDoc) {
203236
paramNames = params.stream().map(param -> param.getName()).collect(Collectors.toList());
204237
paramDescriptions = params.stream().map(param -> param.getComment().toString()).collect(Collectors.toList());
205238
returnDescription = returnDoc.toString();
206239
}
207240

241+
/**
242+
* Populates {@link JavadocParameterData#paramNames},
243+
* {@link JavadocParameterData#paramDescriptions}, and, and
244+
* {@link JavadocParameterData#returnDescription} using
245+
* {@code @input/@output/@container/@mutable} taglets.
246+
*
247+
* @param doc the {@link List} of {@link OtherJavadoc}s containing all of the
248+
* taglets we need to parse
249+
*/
208250
private void populateViaCustomTaglets(List<OtherJavadoc> doc) {
209251
paramNames = new ArrayList<>();
210252
paramDescriptions = new ArrayList<>();
@@ -226,6 +268,13 @@ private void populateViaCustomTaglets(List<OtherJavadoc> doc) {
226268
}
227269
}
228270

271+
/**
272+
* Determines if {@code tagType} is one of the tags that we are interested in
273+
* scraping.
274+
*
275+
* @param tagType the tag we might need to scrape
276+
* @return true iff it is interesting to us
277+
*/
229278
private boolean validParameterTag(String tagType) {
230279
if (tagType.equals("input")) return true;
231280
if (tagType.equals("mutable")) return true;
@@ -234,6 +283,12 @@ private boolean validParameterTag(String tagType) {
234283
return false;
235284
}
236285

286+
/**
287+
* Synthesizes a set of {@link Parameter}s using the data present in the
288+
* javadoc, as well as {@code fmts}.
289+
*
290+
* @param fmts the list of inputs, outputs, and other types required by the Op
291+
*/
237292
@Override
238293
public List<Parameter> synthesizeAnnotations(List<FunctionalMethodType> fmts) {
239294
List<Parameter> params = new ArrayList<>();

0 commit comments

Comments
 (0)