Skip to content

Commit 47f5938

Browse files
committed
Add command params to javadoc
1 parent d947ec2 commit 47f5938

File tree

36 files changed

+1014
-6
lines changed

36 files changed

+1014
-6
lines changed

cdtp-definition-builder/src/main/java/com/github/kklisura/cdtp/definition/builder/support/protocol/builder/CommandBuilder.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public class CommandBuilder {
3737
private static final String EVENT_LISTENER_ARGUMENT_TYPE = "EventHandler";
3838
private static final String EVENT_LISTENER_RESULT = "EventListener";
3939

40+
private static final String NEW_LINE = "\r\n";
41+
42+
private static final String COMMENT_PARAM = "@param";
43+
private static final String EMPTY_SPACE = " ";
44+
4045
private String basePackageName;
4146
private String typesPackageName;
4247
private String eventPackageName;
@@ -175,8 +180,9 @@ private void addCommand(Command command, Domain domain, JavaInterfaceBuilder int
175180
builders);
176181

177182
String returnType = buildReturnType(command, domain, interfaceBuilder, domainTypeResolver, builders);
183+
String description = buildMethodParamDescription(command.getDescription(), command.getParameters());
178184

179-
interfaceBuilder.addMethod(method, command.getDescription(), methodParams, returnType);
185+
interfaceBuilder.addMethod(method, description, methodParams, returnType);
180186

181187
if (Boolean.TRUE.equals(command.getDeprecated())) {
182188
interfaceBuilder.addMethodAnnotation(method, DEPRECATED_ANNOTATION);
@@ -194,6 +200,29 @@ private void addCommand(Command command, Domain domain, JavaInterfaceBuilder int
194200
}
195201
}
196202

203+
private String buildMethodParamDescription(String description, List<Property> parameters) {
204+
StringBuilder result = new StringBuilder();
205+
if (StringUtils.isNotEmpty(description)) {
206+
result.append(description);
207+
}
208+
209+
if (CollectionUtils.isNotEmpty(parameters)) {
210+
result.append(NEW_LINE);
211+
212+
for (Property property : parameters) {
213+
result.append(NEW_LINE);
214+
result.append(COMMENT_PARAM + EMPTY_SPACE);
215+
result.append(property.getName());
216+
if (StringUtils.isNotEmpty(property.getDescription())) {
217+
result.append(EMPTY_SPACE);
218+
result.append(property.getDescription());
219+
}
220+
}
221+
}
222+
223+
return result.toString();
224+
}
225+
197226
private String buildReturnType(Command command, Domain domain, JavaInterfaceBuilder interfaceBuilder,
198227
DomainTypeResolver domainTypeResolver, List<Builder> builders) {
199228
List<Property> returns = command.getReturns();

cdtp-definition-builder/src/test/java/com/github/kklisura/cdtp/definition/builder/support/java/builder/impl/JavaInterfaceBuilderImplTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ public void testBasicInterfaceWithSimpleMethod() throws IOException {
163163
expect(sourceRoot.add(capture(compilationUnitCapture)))
164164
.andReturn(sourceRoot);
165165

166-
interfaceBuilder.addMethod("someMethod1", "Method description", Collections.emptyList(), null);
166+
String description = "Method description\r\n\r\n@param test Test param\r\n@return Returns nothing";
167+
interfaceBuilder.addMethod("someMethod1", description, Collections.emptyList(), null);
167168

168169
replayAll();
169170

@@ -175,6 +176,9 @@ public void testBasicInterfaceWithSimpleMethod() throws IOException {
175176
"\n" +
176177
" /**\n" +
177178
" * Method description\n" +
179+
" *\n" +
180+
" * @param test Test param\n" +
181+
" * @return Returns nothing\n" +
178182
" */\n" +
179183
" void someMethod1();" +
180184
"\n" +

cdtp-definition-builder/src/test/java/com/github/kklisura/cdtp/definition/builder/support/protocol/builder/CommandBuilderTest.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,12 @@ public void testBuildCommandWithMethodWithSimpleParams() {
168168
final StringProperty stringParam = new StringProperty();
169169
stringParam.setName("stringParam1");
170170
stringParam.setDeprecated(Boolean.TRUE);
171+
stringParam.setDescription("String param 1 description");
171172

172173
final NumberProperty numberParam = new NumberProperty();
173174
numberParam.setName("numberParam1");
174175
numberParam.setExperimental(Boolean.TRUE);
176+
numberParam.setDescription("Number param 1 description");
175177

176178
final BooleanProperty booleanReturnParam = new BooleanProperty();
177179
booleanReturnParam.setName("booleanReturn");
@@ -186,17 +188,19 @@ public void testBuildCommandWithMethodWithSimpleParams() {
186188
interfaceBuilder.setJavaDoc("Description");
187189

188190
Capture<List<MethodParam>> methodParamCapture = Capture.newInstance();
189-
interfaceBuilder.addMethod(eq("command"), eq("command description"), capture(methodParamCapture), eq("Boolean"));
191+
Capture<String> methodDescriptionCapture = Capture.newInstance();
192+
interfaceBuilder.addMethod(eq("command"), capture(methodDescriptionCapture), capture(methodParamCapture), eq("Boolean"));
190193

191194
interfaceBuilder.addParametrizedMethodAnnotation("command", "Returns", "booleanReturn");
192195

193-
194196
replayAll();
195197

196198
assertEquals(interfaceBuilder, commandBuilder.build(domain, resolver));
197199

198200
verifyAll();
199201

202+
assertEquals("command description\r\n\r\n@param stringParam1 String param 1 description\r\n@param numberParam1 Number param 1 description", methodDescriptionCapture.getValue());
203+
200204
List<MethodParam> params = methodParamCapture.getValue();
201205
assertEquals(2, params.size());
202206
Assert.assertEquals(stringParam.getName(), params.get(0).getName());
@@ -231,6 +235,7 @@ public void testBuildCommandWithMethodWithComplexParams() throws InstantiationEx
231235
arrayProperty.setName("enumParam1");
232236
arrayProperty.setExperimental(Boolean.TRUE);
233237
arrayProperty.setOptional(Boolean.TRUE);
238+
arrayProperty.setDescription("enum param 1 description");
234239

235240
EnumArrayItem enumArrayItem = new EnumArrayItem();
236241
enumArrayItem.setEnumValues(Arrays.asList("enum1", "enum2"));
@@ -254,11 +259,13 @@ public void testBuildCommandWithMethodWithComplexParams() throws InstantiationEx
254259
.andReturn(interfaceBuilder);
255260
interfaceBuilder.setJavaDoc("Description");
256261

262+
Capture<String> mandatoryMethodDescriptionCapture = Capture.newInstance();
257263
Capture<List<MethodParam>> mandatoryMethodParamCapture = Capture.newInstance();
258-
interfaceBuilder.addMethod(eq("command"), eq("command description"), capture(mandatoryMethodParamCapture), eq("Boolean"));
264+
interfaceBuilder.addMethod(eq("command"), capture(mandatoryMethodDescriptionCapture), capture(mandatoryMethodParamCapture), eq("Boolean"));
259265

266+
Capture<String> allMethodDescriptionCapture = Capture.newInstance();
260267
Capture<List<MethodParam>> allMethodParamCapture = Capture.newInstance();
261-
interfaceBuilder.addMethod(eq("command"), eq("command description"), capture(allMethodParamCapture), eq("Boolean"));
268+
interfaceBuilder.addMethod(eq("command"), capture(allMethodDescriptionCapture), capture(allMethodParamCapture), eq("Boolean"));
262269

263270
final ObjectType resolvedRefType = new ObjectType();
264271
resolvedRefType.setId("TestRef");
@@ -290,6 +297,10 @@ public void testBuildCommandWithMethodWithComplexParams() throws InstantiationEx
290297
assertEquals(javaEnumBuilder, builderList.get(0));
291298
assertEquals(interfaceBuilder, builderList.get(1));
292299

300+
assertEquals("command description\r\n\r\n@param stringParam1", mandatoryMethodDescriptionCapture.getValue());
301+
302+
assertEquals("command description\r\n\r\n@param stringParam1\r\n@param enumParam1 enum param 1 description", allMethodDescriptionCapture.getValue());
303+
293304
List<MethodParam> mandatoryParams = mandatoryMethodParamCapture.getValue();
294305
assertEquals(1, mandatoryParams.size());
295306
assertEquals(refParam.getName(), mandatoryParams.get(0).getName());

cdtp-java-client/src/main/java/com/github/kklisura/cdtp/protocol/commands/Accessibility.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@ public interface Accessibility {
1212

1313
/**
1414
* Fetches the accessibility node and partial accessibility tree for this DOM node, if it exists.
15+
*
16+
* @param nodeId ID of node to get the partial accessibility tree for.
1517
*/
1618
@Experimental
1719
@Returns("nodes")
1820
List<AXNode> getPartialAXTree(@ParamName("nodeId") Integer nodeId);
1921

2022
/**
2123
* Fetches the accessibility node and partial accessibility tree for this DOM node, if it exists.
24+
*
25+
* @param nodeId ID of node to get the partial accessibility tree for.
26+
* @param fetchRelatives Whether to fetch this nodes ancestors, siblings and children. Defaults to true.
2227
*/
2328
@Experimental
2429
@Returns("nodes")

cdtp-java-client/src/main/java/com/github/kklisura/cdtp/protocol/commands/Animation.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,55 @@ public interface Animation {
3333

3434
/**
3535
* Sets the playback rate of the document timeline.
36+
*
37+
* @param playbackRate Playback rate for animations on page
3638
*/
3739
void setPlaybackRate(@ParamName("playbackRate") Double playbackRate);
3840

3941
/**
4042
* Returns the current time of the an animation.
43+
*
44+
* @param id Id of animation.
4145
*/
4246
@Returns("currentTime")
4347
Double getCurrentTime(@ParamName("id") String id);
4448

4549
/**
4650
* Sets the paused state of a set of animations.
51+
*
52+
* @param animations Animations to set the pause state of.
53+
* @param paused Paused state to set to.
4754
*/
4855
void setPaused(@ParamName("animations") List<String> animations, @ParamName("paused") Boolean paused);
4956

5057
/**
5158
* Sets the timing of an animation node.
59+
*
60+
* @param animationId Animation id.
61+
* @param duration Duration of the animation.
62+
* @param delay Delay of the animation.
5263
*/
5364
void setTiming(@ParamName("animationId") String animationId, @ParamName("duration") Double duration, @ParamName("delay") Double delay);
5465

5566
/**
5667
* Seek a set of animations to a particular time within each animation.
68+
*
69+
* @param animations List of animation ids to seek.
70+
* @param currentTime Set the current time of each animation.
5771
*/
5872
void seekAnimations(@ParamName("animations") List<String> animations, @ParamName("currentTime") Double currentTime);
5973

6074
/**
6175
* Releases a set of animations to no longer be manipulated.
76+
*
77+
* @param animations List of animation ids to seek.
6278
*/
6379
void releaseAnimations(@ParamName("animations") List<String> animations);
6480

6581
/**
6682
* Gets the remote object of the Animation.
83+
*
84+
* @param animationId Animation id.
6785
*/
6886
@Returns("remoteObject")
6987
RemoteObject resolveAnimation(@ParamName("animationId") String animationId);

cdtp-java-client/src/main/java/com/github/kklisura/cdtp/protocol/commands/ApplicationCache.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ public interface ApplicationCache {
2727

2828
/**
2929
* Returns manifest URL for document in the given frame.
30+
*
31+
* @param frameId Identifier of the frame containing document whose manifest is retrieved.
3032
*/
3133
@Returns("manifestURL")
3234
String getManifestForFrame(@ParamName("frameId") String frameId);
3335

3436
/**
3537
* Returns relevant application cache data for the document in given frame.
38+
*
39+
* @param frameId Identifier of the frame containing document whose application cache is retrieved.
3640
*/
3741
@Returns("applicationCache")
3842
com.github.kklisura.cdtp.protocol.types.applicationcache.ApplicationCache getApplicationCacheForFrame(@ParamName("frameId") String frameId);

cdtp-java-client/src/main/java/com/github/kklisura/cdtp/protocol/commands/Audits.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,19 @@ public interface Audits {
1414

1515
/**
1616
* Returns the response body and size if it were re-encoded with the specified settings. Only applies to images.
17+
*
18+
* @param requestId Identifier of the network request to get content for.
19+
* @param encoding The encoding to use.
1720
*/
1821
EncodedResponse getEncodedResponse(@ParamName("requestId") String requestId, @ParamName("encoding") Encoding encoding);
1922

2023
/**
2124
* Returns the response body and size if it were re-encoded with the specified settings. Only applies to images.
25+
*
26+
* @param requestId Identifier of the network request to get content for.
27+
* @param encoding The encoding to use.
28+
* @param quality The quality of the encoding (0-1). (defaults to 1)
29+
* @param sizeOnly Whether to only return the size information (defaults to false).
2230
*/
2331
EncodedResponse getEncodedResponse(@ParamName("requestId") String requestId, @ParamName("encoding") Encoding encoding, @Optional @ParamName("quality") Double quality, @Optional @ParamName("sizeOnly") Boolean sizeOnly);
2432
}

cdtp-java-client/src/main/java/com/github/kklisura/cdtp/protocol/commands/Browser.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public interface Browser {
1515

1616
/**
1717
* Get the browser window that contains the devtools target.
18+
*
19+
* @param targetId Devtools agent host id.
1820
*/
1921
WindowForTarget getWindowForTarget(@ParamName("targetId") String targetId);
2022

@@ -25,11 +27,16 @@ public interface Browser {
2527

2628
/**
2729
* Set position and/or size of the browser window.
30+
*
31+
* @param windowId Browser window id.
32+
* @param bounds New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged.
2833
*/
2934
void setWindowBounds(@ParamName("windowId") Integer windowId, @ParamName("bounds") Bounds bounds);
3035

3136
/**
3237
* Get position and size of the browser window.
38+
*
39+
* @param windowId Browser window id.
3340
*/
3441
@Returns("bounds")
3542
Bounds getWindowBounds(@ParamName("windowId") Integer windowId);

0 commit comments

Comments
 (0)