From b4615c67a314bc818419c5cf4fd63355f2f93012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Wed, 9 Dec 2020 09:21:50 +0000 Subject: [PATCH] 8256580: Fault in new grid display Reviewed-by: jjg --- .../formats/html/HtmlDocletWriter.java | 2 +- .../doclets/formats/html/markup/Table.java | 3 +- .../testHtmlTableTags/TestHtmlTableTags.java | 310 ++++++++++++++++++ 3 files changed, 313 insertions(+), 2 deletions(-) diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java index fab8442383d..bb7dcc41179 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java @@ -1253,7 +1253,7 @@ public class HtmlDocletWriter { */ private void addCommentTags(Element element, DocTree holderTag, List tags, boolean depr, boolean first, boolean inSummary, Content htmltree) { - if (options.noComment()){ + if (options.noComment()) { return; } Content div; diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Table.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Table.java index a160bf95b42..b14778187a6 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Table.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Table.java @@ -318,7 +318,8 @@ public class Table extends Content { HtmlStyle cellStyle = (columnStyles == null || colIndex > columnStyles.size()) ? null : columnStyles.get(colIndex); - HtmlTree cell = HtmlTree.DIV(cellStyle, c); + // Replace empty content with HtmlTree.EMPTY to make sure the cell isn't dropped + HtmlTree cell = HtmlTree.DIV(cellStyle, !c.isEmpty() ? c : HtmlTree.EMPTY); if (rowStyle != null) { cell.addStyle(rowStyle); } diff --git a/test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java b/test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java index 03d0fa9d5e3..301669d2e30 100644 --- a/test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java +++ b/test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java @@ -57,6 +57,22 @@ public class TestHtmlTableTags extends JavadocTester { checkHtmlTableTag(); checkHtmlTableCaptions(); checkHtmlTableHeaders(); + checkHtmlTableContents(); + } + + @Test + public void testNoComment() { + javadoc("-d", "out-nocomment", + "-nocomment", + "-sourcepath", testSrc, + "-use", + "pkg1", "pkg2"); + checkExit(Exit.OK); + + checkHtmlTableTag(); + checkHtmlTableCaptions(); + checkHtmlTableHeaders(); + checkHtmlTableContentsNoComment(); } /* @@ -520,4 +536,298 @@ public class TestHtmlTableTags extends JavadocTester {
Package
Description
"""); } + + /* + * Test for validating HTML table contents. + */ + void checkHtmlTableContents() { + //Package summary + checkOutput("pkg1/package-summary.html", true, + """ +
I1
+
+
A sample interface used to test table tags.
+
""", + """ +
C1
+
+
A test class.
+
"""); + + checkOutput("pkg2/package-summary.html", true, + """ +
C2.ModalExclusionType
+
+
A sample enum.
+
""", + """ +
C3
+
+
Test Annotation class.
+
"""); + + // Class documentation + checkOutput("pkg1/C1.html", true, + """ +
C2
+
field
+
+
Test field for class.
+
""", + """ +
void
+
method1​(int a, + int b)
+
+
Method that is implemented.
+
"""); + + checkOutput("pkg2/C2.html", true, + """ +
C1
+
field
+
+
A test field.
+
""", + """ +
C1
+
method​(C1 param)
+
+
A sample method.
+
"""); + + checkOutput("pkg2/C2.ModalExclusionType.html", true, + """ +
NO_EXCLUDE
+
+
Test comment.
+
"""); + + checkOutput("pkg2/C3.html", true, + """ +
value
+
+
Comment.
+
"""); + + checkOutput("pkg2/C4.html", true, + """ +
boolean
+
value
+
 
+ """); + + // Class use documentation + checkOutput("pkg1/class-use/I1.html", true, + """ +
pkg1
+
+
Test package 1 used to test table tags.
+
"""); + + checkOutput("pkg2/class-use/C2.html", true, + """ +
C2
+
C1.<\ + code>field\ +
+
+
Test field for class.
+
""", + """ +
C2
+
C1.<\ + code>method​(C2 \ + ;param)
+
+
Method thats does some processing.
+
"""); + + // Package use documentation + checkOutput("pkg1/package-use.html", true, + """ +
pkg1
+
+
Test package 1 used to test table tags.
+
""", + """ +
C1
+
+
A test class.
+
"""); + + // Deprecated + checkOutput("deprecated-list.html", true, + """ +
pkg2.C2.dep_field
+
+
don't use this field anymore.
+
""", + """ +
pkg1.C1.deprecatedMethod()
+
+
don't use this anymore.
+
"""); + + // Constant values + checkOutput("constant-values.html", true, + """ +
public s\ + tatic final String
+
CO\ + NSTANT1
+
"C1"
+ """); + + // Overview Summary + checkOutput("index.html", true, + """ +
pkg1
+
+
Test package 1 used to test table tags.
+
"""); + } + + /* + * Test for validating HTML table contents with -nocomment option. + */ + void checkHtmlTableContentsNoComment() { + //Package summary + checkOutput("pkg1/package-summary.html", true, + """ +
I1
+
""", + """ +
C1
+
"""); + + checkOutput("pkg2/package-summary.html", true, + """ +
C2.ModalExclusionType
+
""", + """ +
C3
+
"""); + + // Class documentation + checkOutput("pkg1/C1.html", true, + """ +
C2
+
field
+
""", + """ +
void
+
method1​(int a, + int b)
+
"""); + + checkOutput("pkg2/C2.html", true, + """ +
C1
+
field
+
""", + """ +
C1
+
method​(C1 param)
+
"""); + + checkOutput("pkg2/C2.ModalExclusionType.html", true, + """ +
NO_EXCLUDE
+
"""); + + checkOutput("pkg2/C3.html", true, + """ +
value
+
"""); + + checkOutput("pkg2/C4.html", true, + """ +
boolean
+
value
+
+ """); + + // Class use documentation + checkOutput("pkg1/class-use/I1.html", true, + """ +
pkg1
+
"""); + + checkOutput("pkg2/class-use/C2.html", true, + """ +
C2
+
C1.<\ + code>field\ +
+
""", + """ +
C2
+
C1.<\ + code>method​(C2 \ + ;param)
+
"""); + + // Package use documentation + checkOutput("pkg1/package-use.html", true, + """ +
pkg1
+
""", + """ +
C1
+
"""); + + // Deprecated + checkOutput("deprecated-list.html", true, + """ +
pkg2.C2.dep_field
+
""", + """ +
pkg1.C1.deprecatedMethod()
+
"""); + + // Constant values + checkOutput("constant-values.html", true, + """ +
public s\ + tatic final String
+
CO\ + NSTANT1
+
"C1"
+ """); + + // Overview Summary + checkOutput("index.html", true, + """ +
pkg1
+
"""); + } }