# HG changeset patch # User pmuthuswamy # Date 1556605710 -19800 # Node ID 89f2043ee67a80396f6e85f99dfb80cf6a022bda # Parent c0d9bc9b4e1fbe883a98ccc61928b89b61cbbf88 8221991: Improve the HTML for the inheritance tree for a type Reviewed-by: hannesw diff -r c0d9bc9b4e1f -r 89f2043ee67a src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java --- 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; } /** diff -r c0d9bc9b4e1f -r 89f2043ee67a src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties --- 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 diff -r c0d9bc9b4e1f -r 89f2043ee67a src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css --- 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; diff -r c0d9bc9b4e1f -r 89f2043ee67a test/langtools/jdk/javadoc/doclet/AccessAsciiArt/AccessAsciiArt.java --- 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 - "
  • p1.C
  • ", + "
    p1.C", // Test the second line of the class tree - "
  • p1.SC
  • ", + "
    p1.SC", // Test the third line of the class tree - "
  • p1.subpkg.SSC
  • "); + "
    p1.subpkg.SSC
    \n
    \n
    "); } } diff -r c0d9bc9b4e1f -r 89f2043ee67a test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java --- 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<CE>\n" + "", //Make sure Class Tree has substituted type parameters. - "", + "
    java.lang.Object\n" + + "
    pkg.Parent<CE>\n" + + "
    pkg.Child<CE>
    \n" + + "
    \n
    ", //Make sure "Specified By" has substituted type parameters. "
    Specified by:
    \n" + "
    method" diff -r c0d9bc9b4e1f -r 89f2043ee67a test/langtools/jdk/javadoc/doclet/testOptions/TestOptions.java --- 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, - "
  • Foo
  • "); + "
    Foo
    "); checkOutput("deprecated/Foo.html", true, - "
  • deprecated.Foo
  • "); + "
    deprecated.Foo
    "); javadoc("-d", "out-10a", "-noqualifier", "all", @@ -279,8 +279,8 @@ checkExit(Exit.OK); checkOutput("pkg/Foo.html", true, - "
  • Foo
  • "); + "
    Foo
    "); checkOutput("deprecated/Foo.html", true, - "
  • Foo
  • "); + "
    Foo
    "); } } diff -r c0d9bc9b4e1f -r 89f2043ee67a test/langtools/jdk/javadoc/doclet/testPrivateClasses/TestPrivateClasses.java --- 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 @@ "" + "methodInheritedFromParent", // private class does not show up in tree - "", + "
    java.lang.Object\n" + + "
    pkg.PublicChild
    \n" + + "
    ", // Method is documented as though it is declared in the inheriting method. "
    public void methodInheritedFromParent​(int p1)",
                     "
    \n" diff -r c0d9bc9b4e1f -r 89f2043ee67a test/langtools/jdk/javadoc/doclet/testSingletonLists/TestSingletonLists.java --- 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 +}