Skip to content

Add to MethodSpec javadoc methods for @return tag #213

Description

@coe-nathan

For sample code below, I would expect the output to have a place to include documentation for a return value. Nothing currently exists.

public static void main(String[] args) {
    MethodSpec ms = MethodSpec.methodBuilder("methodName")
        .addParameter(ParameterSpec.builder(String.class, "str").addJavadoc("foo").build())
        .addParameter(ParameterSpec.builder(int.class, "num").addJavadoc("bar").build())
        .addJavadoc("@return output")
        .returns(String.class)
        .addStatement("return $S", "baz")
        .build();
    String text = ms.toString();
    System.err.println(text);
}

Current method generation

/**
 * @return output
 * @param str foo@param num bar
 */
java.lang.String methodName(java.lang.String str, int num) {
  return "baz";
}

Desired method generation

/**
 * @param str foo@param num bar
 * @return output
 */
java.lang.String methodName(java.lang.String str, int num) {
  return "baz";
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions