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

Enable Option to Disable Javadoc-Formatting for Google Java Format #1501

Closed
FireRedDev opened this issue Jan 18, 2023 · 1 comment
Closed

Comments

@FireRedDev
Copy link

FireRedDev commented Jan 18, 2023

Hey! GJF added the option to disable formatting of javadoc.
EDIT: #1287 already handles this but:
i would in general just like for the formatter to ignore comments, google java format still seems to format linebreaks in javadocs
is this possible to set? i couldnt find it in the example

@nedtwigg
Copy link
Member

i would in general just like for the formatter to ignore comments, google java format still seems to format linebreaks in javadocs

Spotless is mostly a switchboard for other formatters. We do have spotless:off/on tags which you can use to preserve a specific section.

It would be possible to use that same technique to store all comments and then restore them after gjf or other steps have mangled them, but it would be very difficult. I don't think it's worth the effort, but I'd be happy to merge a PR which supports full comment preservation. My recommendation would be to

  • Look at this PR first, which implements the easy part of what you'll need
  • Now write the docs for your new step and open a draft PR to get feedback on the plan
  • Now you'll need to parse comments, save them as per the PR above, and then restore them into the newly changed code (hard!!!)

Or, you can submit a PR to GJF or maybe palantir-java-format to get them to ignore comments. Once they have the feature, turning it on in Spotless would be easy.

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