Skip to content

Don't introduce line break at beginning of <code> #84

Open
@mernst

Description

@mernst

Consider this file:

public class LineBreakCode {

  /**
   * File with list of checkouts.  Set it to /dev/null to suppress reading.
   * Defaults to <code>$HOME/.mvc-checkouts</code>.
   */
  public String checkouts = "~/.mvc-checkouts";
}

The Javadoc comment gets reformatted as:

   * File with list of checkouts. Set it to /dev/null to suppress reading. Defaults to <code>
   * $HOME/.mvc-checkouts</code>.

Note that a line break has been introduced between <code> and the subsequent character, where there was no whitespace before. I think this makes the Javadoc comment harder to read.

Furthermore, the space is not closed up when google-java-format runs again, even if there is an opportunity to do so. If I subsequently add a few words to the first line of the reformatted comment:

   * File with list of checkouts. You can set it to /dev/null to suppress reading. Defaults to <code>
   * $HOME/.mvc-checkouts</code>.

and re-run google-java-format, then the result is:

   * File with list of checkouts. You can set it to /dev/null to suppress reading. Defaults to
   * <code>
   * $HOME/.mvc-checkouts</code>.

which carefully preserves the undesired line break that google-java-format added.

I should note that all versions of this look the same in the generated HTML API documentation, so my concern is to avoid unnecessarily munging the source code.

I think the best solution would be for google-java-format to not introduce whitespace immediately after a formatting tag such as <code>.

I have attached files that reproduce the behavior described above.
linebreakcode.zip

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