Skip to content

Commit 2de7336

Browse files
eamonnmcmanusgoogle-java-format Team
authored andcommitted
Add a test demonstrating the current broken formatting for markdown javadoc.
The most obvious problem is that wrapped lines start with `//` instead of `///`. PiperOrigin-RevId: 884614790
1 parent d2f234d commit 2de7336

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,4 +1488,46 @@ public void missingSummaryFragment() {
14881488
};
14891489
doFormatTest(input, expected);
14901490
}
1491+
1492+
@Test
1493+
public void simpleMarkdown() {
1494+
String[] input = {
1495+
"package com.example;",
1496+
"",
1497+
"/// # Heading",
1498+
"///",
1499+
"/// A very long line of text, long enough that it will need to be wrapped to fit within the"
1500+
+ " maximum line length.",
1501+
"class Test {",
1502+
" /// Another very long line of text, also long enough that it will need to be wrapped to"
1503+
+ " fit within the maximum line length.",
1504+
" /// @param <T> a generic type",
1505+
" <T> T method() {",
1506+
" return null;",
1507+
" }",
1508+
"}",
1509+
};
1510+
// TODO(emcmanus): Fix the formatter so it doesn't produce this nonsense:
1511+
// - wrapped lines should start with /// not //
1512+
// - blank line before @param
1513+
String[] expected = {
1514+
"package com.example;",
1515+
"",
1516+
"/// # Heading",
1517+
"///",
1518+
"/// A very long line of text, long enough that it will need to be wrapped to fit within the"
1519+
+ " maximum",
1520+
"// line length.",
1521+
"class Test {",
1522+
" /// Another very long line of text, also long enough that it will need to be wrapped to"
1523+
+ " fit within",
1524+
" // the maximum line length.",
1525+
" /// @param <T> a generic type",
1526+
" <T> T method() {",
1527+
" return null;",
1528+
" }",
1529+
"}",
1530+
};
1531+
doFormatTest(input, expected);
1532+
}
14911533
}

0 commit comments

Comments
 (0)