Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParameterSpec generated Javadoc is missing line breaks between @param #128

Open
Marcono1234 opened this issue Nov 24, 2024 · 3 comments
Open

Comments

@Marcono1234
Copy link
Contributor

Version

0.5.0
0.6.0-SNAPSHOT 351beba

What happened?

When having multiple parameters with ParameterSpec.builder(...).addJavadoc(...), the generated code does not add line breaks between the @param Javadoc tags. Instead they all appear in a single line:

var param1 = ParameterSpec.builder(int.class, "first")
    .addJavadoc("text1")
    .build();
var param2 = ParameterSpec.builder(int.class, "second")
    .addJavadoc("text2")
    .build();
MethodSpec method = MethodSpec.methodBuilder("method")
    .addParameter(param1)
    .addParameter(param2)
    .build();
System.out.println(method.toString());

Generated:

/**
 * @param first text1@param second text2
 */

What did you want to happen?

Line breaks between @param tags:

/**
 * @param first text1
 * @param second text2
 */
@pkoenig10
Copy link
Member

We don't really want this library to be in the business of formatting code. There are too many different opinions and conventions regarding formatting - we can't provide a formatting output that satisfies everyone.

We will ensure that the generated code produces something reasonable. Personally, I think it's more natural/standard for there to not be newlines between parameters.

If you want a specific format, you can run the generated code through a formatter. This is actually what we do - we even have a library for this!

https://github.com/palantir/goethe

@Marcono1234
Copy link
Contributor Author

@pkoenig10, I think you misunderstood this. JavaPoet generates all @param tags on the same line. This is not about style, this is about correctness. JavaPoet is generating malformed Javadoc.

@pkoenig10
Copy link
Member

Ah sorry, you're right. I did misunderstand.

@pkoenig10 pkoenig10 reopened this Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants