8221991: Improve the HTML for the inheritance tree for a type
Reviewed-by: hannesw
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java Wed Apr 24 09:10:45 2019 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java Tue Apr 30 11:58:30 2019 +0530
@@ -40,7 +40,9 @@
import javax.lang.model.util.SimpleElementVisitor8;
import com.sun.source.doctree.DocTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
@@ -295,26 +297,17 @@
*/
private Content getClassInheritenceTree(TypeMirror type) {
TypeMirror sup;
- HtmlTree classTreeUl = new HtmlTree(HtmlTag.UL);
- classTreeUl.setStyle(HtmlStyle.inheritance);
- Content liTree = null;
+ HtmlTree classTree = null;
do {
sup = utils.getFirstVisibleSuperClass(type);
- if (sup != null) {
- HtmlTree ul = new HtmlTree(HtmlTag.UL);
- ul.setStyle(HtmlStyle.inheritance);
- ul.add(getTreeForClassHelper(type));
- if (liTree != null)
- ul.add(liTree);
- Content li = HtmlTree.LI(ul);
- liTree = li;
- type = sup;
- } else
- classTreeUl.add(getTreeForClassHelper(type));
+ HtmlTree htmlElement = HtmlTree.DIV(HtmlStyle.inheritance, getTreeForClassHelper(type));
+ if (classTree != null)
+ htmlElement.add(classTree);
+ classTree = htmlElement;
+ type = sup;
} while (sup != null);
- if (liTree != null)
- classTreeUl.add(liTree);
- return classTreeUl;
+ classTree.put(HtmlAttr.TITLE, contents.getContent("doclet.Inheritance_Tree").toString());
+ return classTree;
}
/**
@@ -324,25 +317,25 @@
* @return a content tree for class helper
*/
private Content getTreeForClassHelper(TypeMirror type) {
- Content li = new HtmlTree(HtmlTag.LI);
+ Content content = new ContentBuilder();
if (type.equals(typeElement.asType())) {
Content typeParameters = getTypeParameterLinks(
new LinkInfoImpl(configuration, LinkInfoImpl.Kind.TREE,
typeElement));
if (configuration.shouldExcludeQualifier(utils.containingPackage(typeElement).toString())) {
- li.add(utils.asTypeElement(type).getSimpleName());
- li.add(typeParameters);
+ content.add(utils.asTypeElement(type).getSimpleName());
+ content.add(typeParameters);
} else {
- li.add(utils.asTypeElement(type).getQualifiedName());
- li.add(typeParameters);
+ content.add(utils.asTypeElement(type).getQualifiedName());
+ content.add(typeParameters);
}
} else {
Content link = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS_TREE_PARENT, type)
.label(configuration.getClassName(utils.asTypeElement(type))));
- li.add(link);
+ content.add(link);
}
- return li;
+ return content;
}
/**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties Wed Apr 24 09:10:45 2019 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties Tue Apr 30 11:58:30 2019 +0530
@@ -94,6 +94,7 @@
doclet.Interfaces=Interfaces
doclet.Enclosing_Class=Enclosing class:
doclet.Enclosing_Interface=Enclosing interface:
+doclet.Inheritance_Tree=Inheritance Tree
doclet.System_Property=System Property
doclet.Window_Source_title=Source code
doclet.Window_Help_title=API Help
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css Wed Apr 24 09:10:45 2019 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css Tue Apr 30 11:58:30 2019 +0530
@@ -364,18 +364,12 @@
display:inline;
font-size:0.9em;
}
-ul.inheritance {
+div.inheritance {
margin:0;
padding:0;
}
-ul.inheritance li {
- display:inline;
- list-style:none;
-}
-ul.inheritance li ul.inheritance {
- margin-left:15px;
- padding-left:15px;
- padding-top:1px;
+div.inheritance div.inheritance {
+ margin-left:2em;
}
ul.blockList, ul.blockListLast {
margin:10px 0 10px 0;
--- a/test/langtools/jdk/javadoc/doclet/AccessAsciiArt/AccessAsciiArt.java Wed Apr 24 09:10:45 2019 -0700
+++ b/test/langtools/jdk/javadoc/doclet/AccessAsciiArt/AccessAsciiArt.java Tue Apr 30 11:58:30 2019 +0530
@@ -50,10 +50,10 @@
checkOutput("p1/subpkg/SSC.html", true,
// Test the top line of the class tree
- "<li><a href=\"../C.html\" title=\"class in p1\">p1.C</a></li>",
+ "<div class=\"inheritance\"><a href=\"../C.html\" title=\"class in p1\">p1.C</a>",
// Test the second line of the class tree
- "<li><a href=\"../SC.html\" title=\"class in p1\">p1.SC</a></li>",
+ "<div class=\"inheritance\"><a href=\"../SC.html\" title=\"class in p1\">p1.SC</a>",
// Test the third line of the class tree
- "<li>p1.subpkg.SSC</li>");
+ "<div class=\"inheritance\">p1.subpkg.SSC</div>\n</div>\n</div>");
}
}
--- a/test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java Wed Apr 24 09:10:45 2019 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java Tue Apr 30 11:58:30 2019 +0530
@@ -85,20 +85,11 @@
+ "Interface</a><CE></code></dd>\n"
+ "</dl>",
//Make sure Class Tree has substituted type parameters.
- "<ul class=\"inheritance\">\n"
- + "<li>java.lang.Object</li>\n"
- + "<li>\n"
- + "<ul class=\"inheritance\">\n"
- + "<li><a href=\"Parent.html\" title=\"class in pkg\">"
- + "pkg.Parent</a><CE></li>\n"
- + "<li>\n"
- + "<ul class=\"inheritance\">\n"
- + "<li>pkg.Child<CE></li>\n"
- + "</ul>\n"
- + "</li>\n"
- + "</ul>\n"
- + "</li>\n"
- + "</ul>",
+ "<div class=\"inheritance\" title=\"Inheritance Tree\">java.lang.Object\n"
+ + "<div class=\"inheritance\"><a href=\"Parent.html\""
+ + " title=\"class in pkg\">pkg.Parent</a><CE>\n"
+ + "<div class=\"inheritance\">pkg.Child<CE></div>\n"
+ + "</div>\n</div>",
//Make sure "Specified By" has substituted type parameters.
"<dt><span class=\"overrideSpecifyLabel\">Specified by:</span></dt>\n"
+ "<dd><code><a href=\"Interface.html#method()\">method</a>"
--- a/test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java Wed Apr 24 09:10:45 2019 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java Tue Apr 30 11:58:30 2019 +0530
@@ -268,9 +268,9 @@
checkExit(Exit.OK);
checkOutput("pkg/Foo.html", true,
- "<li>Foo</li>");
+ "<div class=\"inheritance\">Foo</div>");
checkOutput("deprecated/Foo.html", true,
- "<li>deprecated.Foo</li>");
+ "<div class=\"inheritance\">deprecated.Foo</div>");
javadoc("-d", "out-10a",
"-noqualifier", "all",
@@ -279,8 +279,8 @@
checkExit(Exit.OK);
checkOutput("pkg/Foo.html", true,
- "<li>Foo</li>");
+ "<div class=\"inheritance\">Foo</div>");
checkOutput("deprecated/Foo.html", true,
- "<li>Foo</li>");
+ "<div class=\"inheritance\">Foo</div>");
}
}
--- a/test/langtools/jdk/javadoc/doclet/testPrivateClasses/TestPrivateClasses.java Wed Apr 24 09:10:45 2019 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testPrivateClasses/TestPrivateClasses.java Tue Apr 30 11:58:30 2019 +0530
@@ -66,14 +66,9 @@
"<a href=\"#methodInheritedFromParent(int)\">"
+ "methodInheritedFromParent</a>",
// private class does not show up in tree
- "<ul class=\"inheritance\">\n"
- + "<li>java.lang.Object</li>\n"
- + "<li>\n"
- + "<ul class=\"inheritance\">\n"
- + "<li>pkg.PublicChild</li>\n"
- + "</ul>\n"
- + "</li>\n"
- + "</ul>",
+ "<div class=\"inheritance\" title=\"Inheritance Tree\">java.lang.Object\n"
+ + "<div class=\"inheritance\">pkg.PublicChild</div>\n"
+ + "</div>",
// Method is documented as though it is declared in the inheriting method.
"<pre class=\"methodSignature\">public void methodInheritedFromParent​(int p1)",
"<dl>\n"
--- a/test/langtools/jdk/javadoc/doclet/testSingletonLists/TestSingletonLists.java Wed Apr 24 09:10:45 2019 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testSingletonLists/TestSingletonLists.java Tue Apr 30 11:58:30 2019 +0530
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8219998
+ * @bug 8219998 8221991
* @summary Eliminate inherently singleton lists
* @library /tools/lib ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -275,10 +275,6 @@
case "ul": case "ol": case "dl":
counts.push(new TreeMap<>());
- if (!attrs.isEmpty() && attrs.containsKey("class")
- && attrs.containsValue("inheritance")) {
- inheritanceClass = true;
- }
break;
case "li": case "dd": case "dt": {
@@ -297,11 +293,7 @@
if (c.get("li") == 0) {
error(currFile, getLineNumber(), "empty list");
} else if (c.get("li") == 1 && fileName != null && !excludeFiles.contains(fileName)) {
- if (!inheritanceClass) {
- error(currFile, getLineNumber(), "singleton list");
- } else {
- inheritanceClass = false;
- }
+ error(currFile, getLineNumber(), "singleton list");
}
break;
}
@@ -319,5 +311,4 @@
}
}
}
-
-}
\ No newline at end of file
+}