Skip to content

Markdown javadoc formatting does not respect option to never join lines in javadoc comments #5261

Description

@sciwhiz12

There's an option org.eclipse.jdt.core.formatter.join_line_comments, named as "Never join lines in javadoc/block comments" in Eclipse IDE (but inverted, so it being ticked in Eclipse means it is false in the config file), which controls whether manual line breaks are removed from javadoc and block comments for adjacent lines—that is, lines not separated by an entirely blank line.

Markdown javadoc formatting does not respect this option, despite the name in Eclipse suggesting it should respect it.

We use that option alongside a virtually-unlimited line length (of 1000) to delegate line wrapping to developers.

Here is our formatter-config.xml, which is configured for, among others: formatting both Markdown and Classic javadocs, line length of 1000, and never join lines (org.eclipse.jdt.core.formatter.join_line_comments is set to false).

Given the following code:

/// Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
/// Duis sit amet diam nec libero accumsan blandit. 
/// Quisque non ornare lacus. Suspendisse porta dolor id diam maximus, sed gravida nunc finibus. 
/// Aenean vulputate, mi non iaculis sagittis, erat nibh gravida elit, eget feugiat purus tortor sed sem.  
void main() {}

/**
 * Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Duis sit amet diam nec libero accumsan blandit.
 * Quisque non ornare lacus. Suspendisse porta dolor id diam maximus, sed gravida nunc finibus.
 * Aenean vulputate, mi non iaculis sagittis, erat nibh gravida elit, eget feugiat purus tortor sed sem.  
 */
void main2() {}

Formatting it with the config above without any changes causes the entire Markdown javadoc to collapse to one line, while the Classic javadoc remains unchanged.

The expected behavior here is that both Markdown and Classic javadocs remain unchanged, respecting the option to never join lines in comments.

If org.eclipse.jdt.core.formatter.join_line_comments is set to true (corresponding to the "Never join lines in javadoc/block comments" being unticked in Eclipse), then both comments are collapsed into one line, as expected.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions