From f4b1e8dcda45d081d2773af5ea3dc8d4602d2499 Mon Sep 17 00:00:00 2001 From: Sameer Mahant <3286086+sameermahant@users.noreply.github.com> Date: Mon, 31 Jul 2023 12:19:02 +0530 Subject: [PATCH] Fixed return value documentation comments for getter of property element (#1541) Fixed return value documentation comments for getter of property element --------- Signed-off-by: Sameer Mahant <3286086+sameermahant@users.noreply.github.com> --- .../templates/java/JavaMethodComment.mustache | 29 ++++++++++++------- .../example/smoke/AttributesWithComments.java | 1 + .../smoke/AttributesWithDeprecated.java | 1 + .../android/com/example/smoke/Comments.java | 1 + .../com/example/smoke/CommentsInterface.java | 1 + .../example/smoke/DeprecationComments.java | 2 ++ .../smoke/DeprecationCommentsOnly.java | 1 + .../com/example/smoke/ExcludedComments.java | 1 + .../example/smoke/ExcludedCommentsOnly.java | 1 + 9 files changed, 28 insertions(+), 10 deletions(-) diff --git a/gluecodium/src/main/resources/templates/java/JavaMethodComment.mustache b/gluecodium/src/main/resources/templates/java/JavaMethodComment.mustache index ff08b99627..486902636d 100644 --- a/gluecodium/src/main/resources/templates/java/JavaMethodComment.mustache +++ b/gluecodium/src/main/resources/templates/java/JavaMethodComment.mustache @@ -21,17 +21,26 @@ {{#ifPredicate "hasAnyComment"}} /** {{prefixPartial "combinedComment" " * "}} - */{{#if attributes.deprecated}} -@Deprecated{{/if}}{{/ifPredicate}}{{!! + */ +{{#if attributes.deprecated}}@Deprecated{{/if}} +{{/ifPredicate}} -}}{{+combinedComment}}{{resolveName comment}}{{#if comment.isExcluded}} -@hidden{{/if}}{{#if attributes.deprecated}} -@deprecated {{resolveName attributes.deprecated.message}}{{/if}}{{!! +{{+combinedComment}}{{!! +}}{{resolveName comment}}{{!! +}}{{#if comment.isExcluded}} +{{!!}}@hidden{{!! +}}{{/if}}{{!! +}}{{#if attributes.deprecated}} +{{!!}}@deprecated {{resolveName attributes.deprecated.message}}{{!! +}}{{/if}}{{!! }}{{#parameters}} -@param {{resolveName}} {{#resolveName comment}}{{prefix this " " skipFirstLine=true}}{{/resolveName}}{{/parameters}}{{!! -}}{{#unless isConstructor returnType.isVoid isGetter logic="and"}}{{!! document the return value if -it's neither a constructor nor returning void nor a getter}} -@return {{#resolveName returnType.comment}}{{prefix this " " skipFirstLine=true}}{{/resolveName}}{{/unless}}{{!! +{{!!}}@param {{resolveName}} {{#resolveName comment}}{{prefix this " " skipFirstLine=true}}{{/resolveName}}{{!! +}}{{/parameters}}{{!! +}}{{!! document the return value if it's neither a constructor nor returning void }}{{!! +}}{{#unless isConstructor returnType.isVoid logic="and"}} +{{!!}}@return {{#resolveName returnType.comment}}{{prefix this " " skipFirstLine=true}}{{/resolveName}}{{!! +}}{{/unless}}{{!! }}{{#if thrownType}} -@throws {{resolveName exception "" "ref"}} {{#resolveName thrownType.comment}}{{prefix this " " skipFirstLine=true}}{{/resolveName}}{{/if}}{{!! +{{!!}}@throws {{resolveName exception "" "ref"}} {{#resolveName thrownType.comment}}{{prefix this " " skipFirstLine=true}}{{/resolveName}}{{!! +}}{{/if}}{{!! }}{{/combinedComment}} diff --git a/gluecodium/src/test/resources/smoke/attributes/output/android/com/example/smoke/AttributesWithComments.java b/gluecodium/src/test/resources/smoke/attributes/output/android/com/example/smoke/AttributesWithComments.java index 271617aad5..c02f4166d7 100644 --- a/gluecodium/src/test/resources/smoke/attributes/output/android/com/example/smoke/AttributesWithComments.java +++ b/gluecodium/src/test/resources/smoke/attributes/output/android/com/example/smoke/AttributesWithComments.java @@ -47,6 +47,7 @@ public void disposeNative(long handle) { public native void veryFun(); /** *

Getter comment + * @return

Property comment */ @OnPropertyInClass @NonNull diff --git a/gluecodium/src/test/resources/smoke/attributes/output/android/com/example/smoke/AttributesWithDeprecated.java b/gluecodium/src/test/resources/smoke/attributes/output/android/com/example/smoke/AttributesWithDeprecated.java index b24b8ea0ec..90fd4b7cb8 100644 --- a/gluecodium/src/test/resources/smoke/attributes/output/android/com/example/smoke/AttributesWithDeprecated.java +++ b/gluecodium/src/test/resources/smoke/attributes/output/android/com/example/smoke/AttributesWithDeprecated.java @@ -53,6 +53,7 @@ public void disposeNative(long handle) { /** * * @deprecated + * @return */ @Deprecated @OnPropertyInClass diff --git a/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/Comments.java b/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/Comments.java index 2b03595522..5277e8d522 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/Comments.java +++ b/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/Comments.java @@ -188,6 +188,7 @@ public void disposeNative(long handle) { public native String returnCommentOnly(@NonNull final String undocumented); /** *

Gets some very useful property. + * @return

Some very useful property. */ public native boolean isSomeProperty(); /** diff --git a/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/CommentsInterface.java b/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/CommentsInterface.java index 78ed768c7f..48f25e0508 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/CommentsInterface.java +++ b/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/CommentsInterface.java @@ -92,6 +92,7 @@ public SomeStruct(final boolean someField) { void someMethodWithoutReturnTypeOrInputParameters(); /** *

Gets some very useful property. + * @return

Some very useful property. */ boolean isSomeProperty(); /** diff --git a/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/DeprecationComments.java b/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/DeprecationComments.java index 540d931aa4..73aa106577 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/DeprecationComments.java +++ b/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/DeprecationComments.java @@ -74,6 +74,7 @@ public SomeStruct() { *

Gets some very useful property. * @deprecated

Unfortunately, this property's getter is deprecated. * Use {@link com.example.smoke.Comments#isSomeProperty} instead. + * @return

Some very useful property. */ @Deprecated boolean isSomeProperty(); @@ -88,6 +89,7 @@ public SomeStruct() { /** *

Gets the property but not accessors. * @deprecated

Will be removed in v3.2.1. + * @return

Describes the property but not accessors. */ @Deprecated @NonNull diff --git a/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/DeprecationCommentsOnly.java b/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/DeprecationCommentsOnly.java index 3a026460a1..508c6912c8 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/DeprecationCommentsOnly.java +++ b/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/DeprecationCommentsOnly.java @@ -53,6 +53,7 @@ public SomeStruct() { /** * * @deprecated

Unfortunately, this property's getter is deprecated. + * @return */ @Deprecated boolean isSomeProperty(); diff --git a/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/ExcludedComments.java b/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/ExcludedComments.java index ed05fac017..eaa7e3ff7e 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/ExcludedComments.java +++ b/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/ExcludedComments.java @@ -128,6 +128,7 @@ public void disposeNative(long handle) { /** *

Gets some very useful property. * @hidden + * @return

Some very useful property. */ public native boolean isSomeProperty(); /** diff --git a/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/ExcludedCommentsOnly.java b/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/ExcludedCommentsOnly.java index 2ac7859372..882b351b2c 100644 --- a/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/ExcludedCommentsOnly.java +++ b/gluecodium/src/test/resources/smoke/comments/output/android/com/example/smoke/ExcludedCommentsOnly.java @@ -114,6 +114,7 @@ public void disposeNative(long handle) { /** * * @hidden + * @return */ public native boolean isSomeProperty(); /**