Skip to content

Commit f4c9cf7

Browse files
committed
Change internalApi javadoc comment to be additional descriptive text.
1 parent edafba1 commit f4c9cf7

File tree

5 files changed

+26
-21
lines changed

5 files changed

+26
-21
lines changed

gapic-generator-java/src/main/java/com/google/api/generator/engine/ast/JavaDocComment.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ public boolean emptyComments() {
149149
}
150150

151151
public JavaDocComment build() {
152-
// @param, @throws, @return, @deprecated and @internalApi should always get printed at the
152+
// Add additional descriptive text before block tags.
153+
if (!Strings.isNullOrEmpty(internalOnly)) {
154+
componentsList.add(String.format("<p> <b>Warning: </b>%s", HtmlEscaper.process(internalOnly)));
155+
}
156+
// @param, @throws, @return and @deprecated should always get printed at the
153157
// end.
154158
componentsList.addAll(paramsList);
155159
if (!Strings.isNullOrEmpty(throwsType)) {
@@ -159,9 +163,6 @@ public JavaDocComment build() {
159163
if (!Strings.isNullOrEmpty(deprecated)) {
160164
componentsList.add(String.format("@deprecated %s", deprecated));
161165
}
162-
if (!Strings.isNullOrEmpty(internalOnly)) {
163-
componentsList.add(String.format("@internalApi %s", internalOnly));
164-
}
165166
if (!Strings.isNullOrEmpty(returnDescription)) {
166167
componentsList.add(String.format("@return %s", returnDescription));
167168
}

gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/JavaDocCommentTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ void createJavaDocComment_throwsAndDeprecatedAndInternalAndReturn() {
217217
.build();
218218
String expected =
219219
LineFormatter.lines(
220+
"<p> <b>Warning: </b>This method is internal used only. Please do not use directly.\n",
220221
"@throws java.lang.RuntimeException if the remote call fails.\n",
221222
"@deprecated Use the {@link ShelfBookName} class instead.\n",
222-
"@internalApi This method is internal used only. Please do not use directly.\n",
223223
"@return This is the correct method return text.");
224224
assertEquals(expected, javaDocComment.comment());
225225
}
@@ -228,7 +228,7 @@ void createJavaDocComment_throwsAndDeprecatedAndInternalAndReturn() {
228228
void createJavaDocComment_allComponents() {
229229
// No matter what order `setThrows`, `setDeprecated`, and `setReturn` are called,
230230
// They will be printed at the end. And `@param` should be grouped,
231-
// they should always be printed right before `@throws`, `@deprecated`, `@InternalApi` and
231+
// they should always be printed right before `@throws`, `@deprecated` and
232232
// `@return`.
233233
// All other add methods should keep the order of how they are added.
234234
String content = "this is a test comment";
@@ -274,11 +274,11 @@ void createJavaDocComment_allComponents() {
274274
"<li> A request object method.\n",
275275
"<li> A callable method.\n",
276276
"</ol>\n",
277+
"<p> <b>Warning: </b>This method is internal used only. Please do not use directly.\n",
277278
"@param shelfName The name of the shelf where books are published to.\n",
278279
"@param shelf The shelf to create.\n",
279280
"@throws com.google.api.gax.rpc.ApiException if the remote call fails.\n",
280281
"@deprecated Use the {@link ArchivedBookName} class instead.\n",
281-
"@internalApi This method is internal used only. Please do not use directly.\n",
282282
"@return This is the method return text.");
283283
assertEquals(expected, javaDocComment.comment());
284284
}

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

+10-6
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,10 @@ public class EchoServiceShouldGeneratePartialUsualClient implements BackgroundRe
437437
* }
438438
* }</pre>
439439
*
440+
* <p><b>Warning: </b>This method is internal used only. Please do not use directly.
441+
*
440442
* @param request The request object containing all of the parameters for the API call.
441443
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
442-
* @internalApi This method is internal used only. Please do not use directly.
443444
*/
444445
@InternalApi("Internal API. This API is not intended for public consumption.")
445446
public final EchoResponse chatShouldGenerateAsInternal() {
@@ -465,9 +466,10 @@ public class EchoServiceShouldGeneratePartialUsualClient implements BackgroundRe
465466
* }
466467
* }</pre>
467468
*
469+
* <p><b>Warning: </b>This method is internal used only. Please do not use directly.
470+
*
468471
* @param name
469472
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
470-
* @internalApi This method is internal used only. Please do not use directly.
471473
*/
472474
@InternalApi("Internal API. This API is not intended for public consumption.")
473475
public final EchoResponse chatShouldGenerateAsInternal(FoobarName name) {
@@ -494,9 +496,10 @@ public class EchoServiceShouldGeneratePartialUsualClient implements BackgroundRe
494496
* }
495497
* }</pre>
496498
*
499+
* <p><b>Warning: </b>This method is internal used only. Please do not use directly.
500+
*
497501
* @param name
498502
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
499-
* @internalApi This method is internal used only. Please do not use directly.
500503
*/
501504
@InternalApi("Internal API. This API is not intended for public consumption.")
502505
public final EchoResponse chatShouldGenerateAsInternal(String name) {
@@ -527,9 +530,10 @@ public class EchoServiceShouldGeneratePartialUsualClient implements BackgroundRe
527530
* }
528531
* }</pre>
529532
*
533+
* <p><b>Warning: </b>This method is internal used only. Please do not use directly.
534+
*
530535
* @param request The request object containing all of the parameters for the API call.
531536
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
532-
* @internalApi This method is internal used only. Please do not use directly.
533537
*/
534538
@InternalApi("Internal API. This API is not intended for public consumption.")
535539
public final EchoResponse chatShouldGenerateAsInternal(EchoRequest request) {
@@ -563,7 +567,7 @@ public class EchoServiceShouldGeneratePartialUsualClient implements BackgroundRe
563567
* }
564568
* }</pre>
565569
*
566-
* @internalApi This method is internal used only. Please do not use directly.
570+
* <p><b>Warning: </b>This method is internal used only. Please do not use directly.
567571
*/
568572
@InternalApi("Internal API. This API is not intended for public consumption.")
569573
public final UnaryCallable<EchoRequest, EchoResponse> chatShouldGenerateAsInternalCallable() {
@@ -597,7 +601,7 @@ public class EchoServiceShouldGeneratePartialUsualClient implements BackgroundRe
597601
* }
598602
* }</pre>
599603
*
600-
* @internalApi This method is internal used only. Please do not use directly.
604+
* <p><b>Warning: </b>This method is internal used only. Please do not use directly.
601605
*/
602606
@InternalApi("Internal API. This API is not intended for public consumption.")
603607
public final BidiStreamingCallable<EchoRequest, EchoResponse>

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public class EchoServiceShouldGeneratePartialUsualSettings
9696
/**
9797
* Returns the object with the settings used for calls to chatShouldGenerateAsInternal.
9898
*
99-
* @internalApi This method is internal used only. Please do not use directly.
99+
* <p><b>Warning: </b>This method is internal used only. Please do not use directly.
100100
*/
101101
@InternalApi("Internal API. This API is not intended for public consumption.")
102102
public UnaryCallSettings<EchoRequest, EchoResponse> chatShouldGenerateAsInternalSettings() {
@@ -107,7 +107,7 @@ public class EchoServiceShouldGeneratePartialUsualSettings
107107
/**
108108
* Returns the object with the settings used for calls to echoShouldGenerateAsInternal.
109109
*
110-
* @internalApi This method is internal used only. Please do not use directly.
110+
* <p><b>Warning: </b>This method is internal used only. Please do not use directly.
111111
*/
112112
@InternalApi("Internal API. This API is not intended for public consumption.")
113113
public StreamingCallSettings<EchoRequest, EchoResponse> echoShouldGenerateAsInternalSettings() {
@@ -235,7 +235,7 @@ public class EchoServiceShouldGeneratePartialUsualSettings
235235
/**
236236
* Returns the builder for the settings used for calls to chatShouldGenerateAsInternal.
237237
*
238-
* @internalApi This method is internal used only. Please do not use directly.
238+
* <p><b>Warning: </b>This method is internal used only. Please do not use directly.
239239
*/
240240
@InternalApi("Internal API. This API is not intended for public consumption.")
241241
public UnaryCallSettings.Builder<EchoRequest, EchoResponse>
@@ -246,7 +246,7 @@ public class EchoServiceShouldGeneratePartialUsualSettings
246246
/**
247247
* Returns the builder for the settings used for calls to echoShouldGenerateAsInternal.
248248
*
249-
* @internalApi This method is internal used only. Please do not use directly.
249+
* <p><b>Warning: </b>This method is internal used only. Please do not use directly.
250250
*/
251251
@InternalApi("Internal API. This API is not intended for public consumption.")
252252
public StreamingCallSettings.Builder<EchoRequest, EchoResponse>

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public class EchoServiceShouldGeneratePartialUsualStubSettings
115115
/**
116116
* Returns the object with the settings used for calls to chatShouldGenerateAsInternal.
117117
*
118-
* @internalApi This method is internal used only. Please do not use directly.
118+
* <p><b>Warning: </b>This method is internal used only. Please do not use directly.
119119
*/
120120
@InternalApi("Internal API. This API is not intended for public consumption.")
121121
public UnaryCallSettings<EchoRequest, EchoResponse> chatShouldGenerateAsInternalSettings() {
@@ -125,7 +125,7 @@ public class EchoServiceShouldGeneratePartialUsualStubSettings
125125
/**
126126
* Returns the object with the settings used for calls to echoShouldGenerateAsInternal.
127127
*
128-
* @internalApi This method is internal used only. Please do not use directly.
128+
* <p><b>Warning: </b>This method is internal used only. Please do not use directly.
129129
*/
130130
@InternalApi("Internal API. This API is not intended for public consumption.")
131131
public StreamingCallSettings<EchoRequest, EchoResponse> echoShouldGenerateAsInternalSettings() {
@@ -352,7 +352,7 @@ public class EchoServiceShouldGeneratePartialUsualStubSettings
352352
/**
353353
* Returns the builder for the settings used for calls to chatShouldGenerateAsInternal.
354354
*
355-
* @internalApi This method is internal used only. Please do not use directly.
355+
* <p><b>Warning: </b>This method is internal used only. Please do not use directly.
356356
*/
357357
@InternalApi("Internal API. This API is not intended for public consumption.")
358358
public UnaryCallSettings.Builder<EchoRequest, EchoResponse>
@@ -363,7 +363,7 @@ public class EchoServiceShouldGeneratePartialUsualStubSettings
363363
/**
364364
* Returns the builder for the settings used for calls to echoShouldGenerateAsInternal.
365365
*
366-
* @internalApi This method is internal used only. Please do not use directly.
366+
* <p><b>Warning: </b>This method is internal used only. Please do not use directly.
367367
*/
368368
@InternalApi("Internal API. This API is not intended for public consumption.")
369369
public StreamingCallSettings.Builder<EchoRequest, EchoResponse>

0 commit comments

Comments
 (0)