Skip to content

Commit 7436995

Browse files
authored
fix: format method types and table in Client Overview (#2361)
1 parent 6847489 commit 7436995

File tree

34 files changed

+1522
-1479
lines changed

34 files changed

+1522
-1479
lines changed

gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/comment/ServiceClientCommentComposer.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.List;
3232
import java.util.Map;
3333
import java.util.Optional;
34+
import java.util.stream.Collectors;
3435

3536
public class ServiceClientCommentComposer {
3637
// Tokens.
@@ -231,15 +232,17 @@ private static String createTableOfMethods(List<MethodAndVariants> methodAndVari
231232
StringBuilder tableBuilder = new StringBuilder();
232233
tableBuilder
233234
.append("<table>\n")
235+
.append(" <caption>Methods</caption>\n")
234236
.append(" <tr>\n")
235237
.append(" <th>Method</th>\n")
236238
.append(" <th>Description</th>\n")
237-
.append(" <th>Method Variants</th>\n");
239+
.append(" <th>Method Variants</th>\n")
240+
.append(" </tr>\n");
238241
for (MethodAndVariants method : methodAndVariantsList) {
239242
tableBuilder
240243
.append(" <tr>\n")
241244
.append(" <td>")
242-
.append(method.method)
245+
.append(CommentFormatter.formatAsJavaDocComment(method.method, null))
243246
.append("</td>\n")
244247
.append(" <td>")
245248
.append(CommentFormatter.formatAsJavaDocComment(method.description, null))
@@ -253,18 +256,25 @@ private static String createTableOfMethods(List<MethodAndVariants> methodAndVari
253256
generateUnorderedListMethodVariants(tableBuilder, CALLABLE_METHODS, method.callableVariants);
254257
tableBuilder.append(" </td>\n").append(" </tr>\n");
255258
}
256-
tableBuilder.append(" </tr>\n").append(" </table>\n");
259+
tableBuilder.append(" </table>\n");
257260
return tableBuilder.toString();
258261
}
259262

260263
private static void generateUnorderedListMethodVariants(
261264
StringBuilder tableBuilder, String methodType, List<String> methodVariants) {
265+
List<String> formattedMethodVariants =
266+
methodVariants.stream()
267+
.map(
268+
methodVariant ->
269+
CommentFormatter.formatAsJavaDocComment(
270+
methodVariant, null)) // Apply the formatting to each element
271+
.collect(Collectors.toList());
262272
if (!methodVariants.isEmpty()) {
263273
tableBuilder
264274
.append(" " + methodType + " ")
265275
.append("<ul>\n")
266276
.append(" <li>")
267-
.append(String.join("\n <li>", methodVariants))
277+
.append(String.join("\n <li>", formattedMethodVariants))
268278
.append("\n")
269279
.append(" </ul>")
270280
.append("\n");

gapic-generator-java/src/test/java/com/google/api/generator/engine/writer/goldens/GrpcServiceClientWithNestedClassImport.golden

+5-4
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,26 @@ import javax.annotation.Generated;
3232
* calls close().
3333
*
3434
* <table>
35+
* <caption>Methods</caption>
3536
* <tr>
3637
* <th>Method</th>
3738
* <th>Description</th>
3839
* <th>Method Variants</th>
40+
* </tr>
3941
* <tr>
40-
* <td>NestedMessageMethod</td>
42+
* <td><p> NestedMessageMethod</td>
4143
* <td><p> </td>
4244
* <td>
4345
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
4446
* <ul>
45-
* <li>nestedMessageMethod(Outer.Middle request)
47+
* <li><p> nestedMessageMethod(Outer.Middle request)
4648
* </ul>
4749
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
4850
* <ul>
49-
* <li>nestedMessageMethodCallable()
51+
* <li><p> nestedMessageMethodCallable()
5052
* </ul>
5153
* </td>
5254
* </tr>
53-
* </tr>
5455
* </table>
5556
*
5657
* <p>See the individual methods for example code.

gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/BookshopClient.golden

+7-6
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,31 @@ import javax.annotation.Generated;
3232
* threads. In the example above, try-with-resources is used, which automatically calls close().
3333
*
3434
* <table>
35+
* <caption>Methods</caption>
3536
* <tr>
3637
* <th>Method</th>
3738
* <th>Description</th>
3839
* <th>Method Variants</th>
40+
* </tr>
3941
* <tr>
40-
* <td>GetBook</td>
42+
* <td><p> GetBook</td>
4143
* <td><p> </td>
4244
* <td>
4345
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
4446
* <ul>
45-
* <li>getBook(GetBookRequest request)
47+
* <li><p> getBook(GetBookRequest request)
4648
* </ul>
4749
* <p>"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.</p>
4850
* <ul>
49-
* <li>getBook(int booksCount, List<Book> books)
50-
* <li>getBook(String booksList, List<Book> books)
51+
* <li><p> getBook(int booksCount, List&lt;Book&gt; books)
52+
* <li><p> getBook(String booksList, List&lt;Book&gt; books)
5153
* </ul>
5254
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
5355
* <ul>
54-
* <li>getBookCallable()
56+
* <li><p> getBookCallable()
5557
* </ul>
5658
* </td>
5759
* </tr>
58-
* </tr>
5960
* </table>
6061
*
6162
* <p>See the individual methods for example code.

gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/DeprecatedServiceClient.golden

+8-7
Original file line numberDiff line numberDiff line change
@@ -31,39 +31,40 @@ import javax.annotation.Generated;
3131
* close().
3232
*
3333
* <table>
34+
* <caption>Methods</caption>
3435
* <tr>
3536
* <th>Method</th>
3637
* <th>Description</th>
3738
* <th>Method Variants</th>
39+
* </tr>
3840
* <tr>
39-
* <td>FastFibonacci</td>
41+
* <td><p> FastFibonacci</td>
4042
* <td><p> </td>
4143
* <td>
4244
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
4345
* <ul>
44-
* <li>fastFibonacci(FibonacciRequest request)
46+
* <li><p> fastFibonacci(FibonacciRequest request)
4547
* </ul>
4648
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
4749
* <ul>
48-
* <li>fastFibonacciCallable()
50+
* <li><p> fastFibonacciCallable()
4951
* </ul>
5052
* </td>
5153
* </tr>
5254
* <tr>
53-
* <td>SlowFibonacci</td>
55+
* <td><p> SlowFibonacci</td>
5456
* <td><p> </td>
5557
* <td>
5658
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
5759
* <ul>
58-
* <li>slowFibonacci(FibonacciRequest request)
60+
* <li><p> slowFibonacci(FibonacciRequest request)
5961
* </ul>
6062
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
6163
* <ul>
62-
* <li>slowFibonacciCallable()
64+
* <li><p> slowFibonacciCallable()
6365
* </ul>
6466
* </td>
6567
* </tr>
66-
* </tr>
6768
* </table>
6869
*
6970
* <p>See the individual methods for example code.

gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/EchoClient.golden

+42-41
Original file line numberDiff line numberDiff line change
@@ -53,158 +53,159 @@ import javax.annotation.Generated;
5353
* threads. In the example above, try-with-resources is used, which automatically calls close().
5454
*
5555
* <table>
56+
* <caption>Methods</caption>
5657
* <tr>
5758
* <th>Method</th>
5859
* <th>Description</th>
5960
* <th>Method Variants</th>
61+
* </tr>
6062
* <tr>
61-
* <td>Echo</td>
63+
* <td><p> Echo</td>
6264
* <td><p> </td>
6365
* <td>
6466
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
6567
* <ul>
66-
* <li>echo(EchoRequest request)
68+
* <li><p> echo(EchoRequest request)
6769
* </ul>
6870
* <p>"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.</p>
6971
* <ul>
70-
* <li>echo()
71-
* <li>echo(ResourceName parent)
72-
* <li>echo(Status error)
73-
* <li>echo(FoobarName name)
74-
* <li>echo(String content)
75-
* <li>echo(String name)
76-
* <li>echo(String parent)
77-
* <li>echo(String content, Severity severity)
72+
* <li><p> echo()
73+
* <li><p> echo(ResourceName parent)
74+
* <li><p> echo(Status error)
75+
* <li><p> echo(FoobarName name)
76+
* <li><p> echo(String content)
77+
* <li><p> echo(String name)
78+
* <li><p> echo(String parent)
79+
* <li><p> echo(String content, Severity severity)
7880
* </ul>
7981
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
8082
* <ul>
81-
* <li>echoCallable()
83+
* <li><p> echoCallable()
8284
* </ul>
8385
* </td>
8486
* </tr>
8587
* <tr>
86-
* <td>Expand</td>
88+
* <td><p> Expand</td>
8789
* <td><p> </td>
8890
* <td>
8991
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
9092
* <ul>
91-
* <li>expandCallable()
93+
* <li><p> expandCallable()
9294
* </ul>
9395
* </td>
9496
* </tr>
9597
* <tr>
96-
* <td>Collect</td>
98+
* <td><p> Collect</td>
9799
* <td><p> </td>
98100
* <td>
99101
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
100102
* <ul>
101-
* <li>collectCallable()
103+
* <li><p> collectCallable()
102104
* </ul>
103105
* </td>
104106
* </tr>
105107
* <tr>
106-
* <td>Chat</td>
108+
* <td><p> Chat</td>
107109
* <td><p> </td>
108110
* <td>
109111
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
110112
* <ul>
111-
* <li>chatCallable()
113+
* <li><p> chatCallable()
112114
* </ul>
113115
* </td>
114116
* </tr>
115117
* <tr>
116-
* <td>ChatAgain</td>
118+
* <td><p> ChatAgain</td>
117119
* <td><p> </td>
118120
* <td>
119121
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
120122
* <ul>
121-
* <li>chatAgainCallable()
123+
* <li><p> chatAgainCallable()
122124
* </ul>
123125
* </td>
124126
* </tr>
125127
* <tr>
126-
* <td>PagedExpand</td>
128+
* <td><p> PagedExpand</td>
127129
* <td><p> </td>
128130
* <td>
129131
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
130132
* <ul>
131-
* <li>pagedExpand(PagedExpandRequest request)
133+
* <li><p> pagedExpand(PagedExpandRequest request)
132134
* </ul>
133135
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
134136
* <ul>
135-
* <li>pagedExpandPagedCallable()
136-
* <li>pagedExpandCallable()
137+
* <li><p> pagedExpandPagedCallable()
138+
* <li><p> pagedExpandCallable()
137139
* </ul>
138140
* </td>
139141
* </tr>
140142
* <tr>
141-
* <td>SimplePagedExpand</td>
143+
* <td><p> SimplePagedExpand</td>
142144
* <td><p> </td>
143145
* <td>
144146
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
145147
* <ul>
146-
* <li>simplePagedExpand(PagedExpandRequest request)
148+
* <li><p> simplePagedExpand(PagedExpandRequest request)
147149
* </ul>
148150
* <p>"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.</p>
149151
* <ul>
150-
* <li>simplePagedExpand()
152+
* <li><p> simplePagedExpand()
151153
* </ul>
152154
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
153155
* <ul>
154-
* <li>simplePagedExpandPagedCallable()
155-
* <li>simplePagedExpandCallable()
156+
* <li><p> simplePagedExpandPagedCallable()
157+
* <li><p> simplePagedExpandCallable()
156158
* </ul>
157159
* </td>
158160
* </tr>
159161
* <tr>
160-
* <td>Wait</td>
162+
* <td><p> Wait</td>
161163
* <td><p> </td>
162164
* <td>
163165
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
164166
* <ul>
165-
* <li>waitAsync(WaitRequest request)
167+
* <li><p> waitAsync(WaitRequest request)
166168
* </ul>
167169
* <p>Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.</p>
168170
* <ul>
169-
* <li>waitAsync(Duration ttl)
170-
* <li>waitAsync(Timestamp endTime)
171+
* <li><p> waitAsync(Duration ttl)
172+
* <li><p> waitAsync(Timestamp endTime)
171173
* </ul>
172174
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
173175
* <ul>
174-
* <li>waitOperationCallable()
175-
* <li>waitCallable()
176+
* <li><p> waitOperationCallable()
177+
* <li><p> waitCallable()
176178
* </ul>
177179
* </td>
178180
* </tr>
179181
* <tr>
180-
* <td>Block</td>
182+
* <td><p> Block</td>
181183
* <td><p> </td>
182184
* <td>
183185
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
184186
* <ul>
185-
* <li>block(BlockRequest request)
187+
* <li><p> block(BlockRequest request)
186188
* </ul>
187189
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
188190
* <ul>
189-
* <li>blockCallable()
191+
* <li><p> blockCallable()
190192
* </ul>
191193
* </td>
192194
* </tr>
193195
* <tr>
194-
* <td>CollideName</td>
196+
* <td><p> CollideName</td>
195197
* <td><p> </td>
196198
* <td>
197199
* <p>Request object method variants only take one parameter, a request object, which must be constructed before the call.</p>
198200
* <ul>
199-
* <li>collideName(EchoRequest request)
201+
* <li><p> collideName(EchoRequest request)
200202
* </ul>
201203
* <p>Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.</p>
202204
* <ul>
203-
* <li>collideNameCallable()
205+
* <li><p> collideNameCallable()
204206
* </ul>
205207
* </td>
206208
* </tr>
207-
* </tr>
208209
* </table>
209210
*
210211
* <p>See the individual methods for example code.

0 commit comments

Comments
 (0)