palantir-java-format icon indicating copy to clipboard operation
palantir-java-format copied to clipboard

Add option to IDEA plugin (and CLI) to format JavaDoc #724

Open blutorange opened this issue 5 months ago • 6 comments

As discussed in #724 (as I understand it), I added an option to the IDEA plugin to enable formattting JavaDoc comments.

  • This adds an option to the IDEA plugin (checkbox) to format JavaDoc comments. It is disabled by default.
  • As the IDEA plugin (sometimes) uses the bootstrapping formatter service, which in turn uses the command line tool, this also add an option --format-javadoc to the command line tool.
  • To pass the options to the FormatterService loaded via service provider, I added a method withOptions to the service provided interface, which returns a new (immutable) instance with the updated options. Compared with the suggestion from the issue comment (https://github.com/palantir/palantir-java-format/issues/724#issuecomment-1109804294), this (a) does not require deprecating methods and (b) the options can be set independently of where the formatter is actually used.
  • Since the infrastructure to pass options to the formatter now exists, we could also add more options to the code style select configuration in the IDEA plugin, but I'm not sure if that makes sense (I want to use Palantir, after all).
  • The issue also mentioned API compatibility. The service provider interface is compatible, most other classes and methods are internal. But if somebody more familar with the code base could take another look, that would be great.
  • I also added a few tests for the new option.

Possible downsides?

  • This adds an option that affects the formatter output, and Palantir strives to be an opinionated formatter without any configuration. As discussed in the issue, though, adding an option for fomatting JavaDoc should be ok.

image

blutorange avatar Jan 21 '24 15:01 blutorange