Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8240136: Cleanup/simplify HTML/CSS for definition lists
Reviewed-by: prappo
  • Loading branch information
jonathan-gibbons committed Feb 28, 2020
1 parent b38f3cf commit 1be89d96405b0d217ff59a9a204b6d59e1631da6
Showing with 88 additions and 96 deletions.
  1. +3 −3 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java
  2. +4 −5 ...are/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
  3. +26 −35 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java
  4. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
  5. +3 −3 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java
  6. +3 −3 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialMethodWriter.java
  7. +1 −1 ...jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java
  8. +1 −0 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java
  9. +14 −4 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java
  10. 0 ...et/{testExternalOverridenMethod → testExternalOverriddenMethod}/TestExternalOverriddenMethod.java
  11. 0 ...ools/jdk/javadoc/doclet/{testExternalOverridenMethod → testExternalOverriddenMethod}/package-list
  12. +1 −1 .../jdk/javadoc/doclet/{testExternalOverridenMethod → testExternalOverriddenMethod}/pkg/XReader.java
  13. +2 −11 test/langtools/jdk/javadoc/doclet/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
  14. +2 −2 test/langtools/jdk/javadoc/doclet/testIndex/TestIndex.java
  15. +4 −4 test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java
  16. +6 −6 test/langtools/jdk/javadoc/doclet/testLambdaFeature/TestLambdaFeature.java
  17. +2 −2 test/langtools/jdk/javadoc/doclet/testLinkTaglet/TestLinkTaglet.java
  18. +4 −4 test/langtools/jdk/javadoc/doclet/testModules/TestModules.java
  19. +3 −3 test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java
  20. +2 −2 test/langtools/jdk/javadoc/doclet/testPackageHtml/TestPackageHtml.java
  21. +4 −4 test/langtools/jdk/javadoc/doclet/testPrivateClasses/TestPrivateClasses.java
  22. +2 −2 test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java
@@ -111,7 +111,7 @@ protected void addContents(Character uc, Collection<? extends Element> memberlis
addHeading(uc, contentTree);
// Display the list only if there are elements to be displayed.
if (!memberlist.isEmpty()) {
Content dl = new HtmlTree(HtmlTag.DL);
HtmlTree dl = HtmlTree.DL(HtmlStyle.index);
for (Element element : memberlist) {
addDescription(dl, element);
}
@@ -124,7 +124,7 @@ protected void addSearchContents(Character uc, List<SearchIndexItem> searchList,
addHeading(uc, contentTree);
// Display the list only if there are elements to be displayed.
if (!searchList.isEmpty()) {
Content dl = new HtmlTree(HtmlTag.DL);
HtmlTree dl = HtmlTree.DL(HtmlStyle.index);
for (SearchIndexItem sii : searchList) {
addDescription(sii, dl);
}
@@ -139,7 +139,7 @@ protected void addContents(Character uc, List<? extends Element> memberlist,
int searchListSize = searchList.size();
int i = 0;
int j = 0;
Content dl = new HtmlTree(HtmlTag.DL);
HtmlTree dl = HtmlTree.DL(HtmlStyle.index);
while (i < memberListSize && j < searchListSize) {
Element elem = memberlist.get(i);
String name = (utils.isModule(elem))
@@ -82,13 +82,12 @@ public void addMemberTree(Content memberSummaryTree, Content memberTree) {
@Override
public void addDefaultValueInfo(Element member, Content annotationDocTree) {
if (utils.isAnnotationType(member)) {
ExecutableElement ee = (ExecutableElement)member;
ExecutableElement ee = (ExecutableElement) member;
AnnotationValue value = ee.getDefaultValue();
if (value != null) {
Content dt = HtmlTree.DT(contents.default_);
Content dl = HtmlTree.DL(dt);
Content dd = HtmlTree.DD(new StringContent(value.toString()));
dl.add(dd);
Content dl = HtmlTree.DL(HtmlStyle.notes);
dl.add(HtmlTree.DT(contents.default_));
dl.add(HtmlTree.DD(new StringContent(value.toString())));
annotationDocTree.add(dl);
}
}
@@ -351,7 +351,7 @@ public void addParamInfo(Content classInfoTree) {
Content paramInfo = (new ParamTaglet()).getTagletOutput(typeElement,
getTagletWriterInstance(false));
if (!paramInfo.isEmpty()) {
classInfoTree.add(HtmlTree.DL(paramInfo).setStyle(HtmlStyle.notes));
classInfoTree.add(HtmlTree.DL(HtmlStyle.notes, paramInfo));
}
}
}
@@ -366,11 +366,9 @@ public void addSubClassInfo(Content classInfoTree) {
}
Set<TypeElement> subclasses = classtree.directSubClasses(typeElement, false);
if (!subclasses.isEmpty()) {
Content label = contents.subclassesLabel;
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
dl.add(getClassLinks(LinkInfoImpl.Kind.SUBCLASSES,
subclasses));
HtmlTree dl = HtmlTree.DL(HtmlStyle.notes);
dl.add(HtmlTree.DT(contents.subclassesLabel));
dl.add(HtmlTree.DD(getClassLinks(LinkInfoImpl.Kind.SUBCLASSES, subclasses)));
classInfoTree.add(dl);
}
}
@@ -381,11 +379,9 @@ public void addSubInterfacesInfo(Content classInfoTree) {
if (utils.isInterface(typeElement)) {
Set<TypeElement> subInterfaces = classtree.allSubClasses(typeElement, false);
if (!subInterfaces.isEmpty()) {
Content label = contents.subinterfacesLabel;
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
dl.add(getClassLinks(LinkInfoImpl.Kind.SUBINTERFACES,
subInterfaces));
Content dl = HtmlTree.DL(HtmlStyle.notes);
dl.add(HtmlTree.DT(contents.subinterfacesLabel));
dl.add(HtmlTree.DD(getClassLinks(LinkInfoImpl.Kind.SUBINTERFACES, subInterfaces)));
classInfoTree.add(dl);
}
}
@@ -403,11 +399,9 @@ public void addInterfaceUsageInfo (Content classInfoTree) {
}
Set<TypeElement> implcl = classtree.implementingClasses(typeElement);
if (!implcl.isEmpty()) {
Content label = contents.implementingClassesLabel;
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
dl.add(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_CLASSES,
implcl));
HtmlTree dl = HtmlTree.DL(HtmlStyle.notes);
dl.add(HtmlTree.DT(contents.implementingClassesLabel));
dl.add(HtmlTree.DD(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_CLASSES, implcl)));
classInfoTree.add(dl);
}
}
@@ -417,10 +411,9 @@ public void addImplementedInterfacesInfo(Content classInfoTree) {
SortedSet<TypeMirror> interfaces = new TreeSet<>(utils.makeTypeMirrorClassUseComparator());
interfaces.addAll(utils.getAllInterfaces(typeElement));
if (utils.isClass(typeElement) && !interfaces.isEmpty()) {
Content label = contents.allImplementedInterfacesLabel;
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
dl.add(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_INTERFACES, interfaces));
HtmlTree dl = HtmlTree.DL(HtmlStyle.notes);
dl.add(HtmlTree.DT(contents.allImplementedInterfacesLabel));
dl.add(HtmlTree.DD(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_INTERFACES, interfaces)));
classInfoTree.add(dl);
}
}
@@ -432,10 +425,9 @@ public void addSuperInterfacesInfo(Content classInfoTree) {
interfaces.addAll(utils.getAllInterfaces(typeElement));

if (utils.isInterface(typeElement) && !interfaces.isEmpty()) {
Content label = contents.allSuperinterfacesLabel;
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
dl.add(getClassLinks(LinkInfoImpl.Kind.SUPER_INTERFACES, interfaces));
HtmlTree dl = HtmlTree.DL(HtmlStyle.notes);
dl.add(HtmlTree.DT(contents.allSuperinterfacesLabel));
dl.add(HtmlTree.DD(getClassLinks(LinkInfoImpl.Kind.SUPER_INTERFACES, interfaces)));
classInfoTree.add(dl);
}
}
@@ -448,11 +440,10 @@ public void addNestedClassInfo(final Content classInfoTree) {
new SimpleElementVisitor8<Void, Void>() {
@Override
public Void visitType(TypeElement e, Void p) {
Content label = utils.isInterface(e)
HtmlTree dl = HtmlTree.DL(HtmlStyle.notes);
dl.add(HtmlTree.DT(utils.isInterface(e)
? contents.enclosingInterfaceLabel
: contents.enclosingClassLabel;
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
: contents.enclosingClassLabel));
Content dd = new HtmlTree(HtmlTag.DD);
dd.add(getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS, e)));
@@ -466,8 +457,8 @@ public Void visitType(TypeElement e, Void p) {
@Override
public void addFunctionalInterfaceInfo (Content classInfoTree) {
if (isFunctionalInterface()) {
Content dt = HtmlTree.DT(contents.functionalInterface);
Content dl = HtmlTree.DL(dt);
HtmlTree dl = HtmlTree.DL(HtmlStyle.notes);
dl.add(HtmlTree.DT(contents.functionalInterface));
Content dd = new HtmlTree(HtmlTag.DD);
dd.add(contents.functionalInterfaceMessage);
dl.add(dd);
@@ -512,27 +503,27 @@ public void addClassDeprecationInfo(Content classInfoTree) {
* @return a content tree for the class list
*/
private Content getClassLinks(LinkInfoImpl.Kind context, Collection<?> list) {
Content dd = new HtmlTree(HtmlTag.DD);
Content content = new ContentBuilder();
boolean isFirst = true;
for (Object type : list) {
if (!isFirst) {
Content separator = new StringContent(", ");
dd.add(separator);
content.add(separator);
} else {
isFirst = false;
}
// TODO: should we simply split this method up to avoid instanceof ?
if (type instanceof TypeElement) {
Content link = getLink(
new LinkInfoImpl(configuration, context, (TypeElement)(type)));
dd.add(HtmlTree.CODE(link));
content.add(HtmlTree.CODE(link));
} else {
Content link = getLink(
new LinkInfoImpl(configuration, context, ((TypeMirror)type)));
dd.add(HtmlTree.CODE(link));
content.add(HtmlTree.CODE(link));
}
}
return dd;
return content;
}

/**
@@ -348,7 +348,7 @@ protected void addTagsInfo(Element e, Content htmlTree) {
if (options.noComment()) {
return;
}
Content dl = new HtmlTree(HtmlTag.DL).setStyle(HtmlStyle.notes);
HtmlTree dl = HtmlTree.DL(HtmlStyle.notes);
if (utils.isExecutableElement(e) && !utils.isConstructor(e)) {
addMethodInfo((ExecutableElement)e, dl);
}
@@ -200,9 +200,9 @@ public void addMemberTags(VariableElement field, Content contentTree) {
TagletWriter.genTagOutput(configuration.tagletManager, field,
configuration.tagletManager.getBlockTaglets(field),
writer.getTagletWriterInstance(false), tagContent);
Content dlTags = new HtmlTree(HtmlTag.DL).setStyle(HtmlStyle.notes);
dlTags.add(tagContent);
contentTree.add(dlTags); // TODO: what if empty?
HtmlTree dl = HtmlTree.DL(HtmlStyle.notes);
dl.add(tagContent);
contentTree.add(dl); // TODO: what if empty?
}

/**
@@ -159,9 +159,9 @@ public void addMemberTags(ExecutableElement member, Content methodsContentTree)
TagletWriter.genTagOutput(tagletManager, member,
tagletManager.getSerializedFormTaglets(),
writer.getTagletWriterInstance(false), tagContent);
Content dlTags = new HtmlTree(HtmlTag.DL).setStyle(HtmlStyle.notes);
dlTags.add(tagContent);
methodsContentTree.add(dlTags);
HtmlTree dl = HtmlTree.DL(HtmlStyle.notes);
dl.add(tagContent);
methodsContentTree.add(dl);
if (name(member).compareTo("writeExternal") == 0
&& utils.getSerialDataTrees(member).isEmpty()) {
serialWarning(member, "doclet.MissingSerialDataTag",
@@ -184,7 +184,7 @@ public Content getClassHeader(TypeElement typeElement) {
*/
@Override
public Content getSerialUIDInfoHeader() {
return new HtmlTree(HtmlTag.DL).setStyle(HtmlStyle.nameValue);
return HtmlTree.DL(HtmlStyle.nameValue);
}

/**
@@ -79,6 +79,7 @@ public enum HtmlStyle {
hierarchy,
horizontal,
implementationLabel,
index,
inheritance,
inheritedList,
interfaceName,
@@ -308,15 +308,25 @@ public static HtmlTree DD(Content body) {
return htmltree;
}

/**
* Generates a DL tag with a given style.
*
* @param style the style
* @return an HtmlTree object for the DL tag
*/
public static HtmlTree DL(HtmlStyle style) {
return new HtmlTree(HtmlTag.DL).setStyle(style);
}

/**
* Generates a DL tag with some content.
*
* @param body content for the tag
* @param style the style for the tag
* @param body content for the tag
* @return an HtmlTree object for the DL tag
*/
public static HtmlTree DL(Content body) {
HtmlTree htmltree = new HtmlTree(HtmlTag.DL, nullCheck(body));
return htmltree;
public static HtmlTree DL(HtmlStyle style, Content body) {
return new HtmlTree(HtmlTag.DL, nullCheck(body)).setStyle(style);
}

/**
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
/*
* @test
* @bug 6786690 6820360 8025633 8026567 8175200 8183511 8186332 8074407 8182765
* 8230136
* @summary This test verifies the nesting of definition list tags.
* @library ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -46,9 +47,6 @@ public static void main(String... args) throws Exception {

@Test
public void test_Comment_Deprecated() {
// tester.run(ARGS1, TEST_ALL, NEGATED_TEST_NO_C5);
// tester.runTestsOnHTML(NO_TEST, NEGATED_TEST_C5);
// tester.runTestsOnHTML(TEST_CMNT_DEPR, NO_TEST);
javadoc("-Xdoclint:none",
"-d", "out-1",
"-sourcepath", testSrc,
@@ -60,9 +58,6 @@ public void test_Comment_Deprecated() {

@Test
public void test_NoComment_Deprecated() {
// tester.run(ARGS2, TEST_ALL, NEGATED_TEST_NO_C5);
// tester.runTestsOnHTML(NO_TEST, NEGATED_TEST_C5);
// tester.runTestsOnHTML(NO_TEST, TEST_CMNT_DEPR);
javadoc("-Xdoclint:none",
"-d", "out-2",
"-nocomment",
@@ -75,8 +70,6 @@ public void test_NoComment_Deprecated() {

@Test
public void test_Comment_NoDeprecated() {
// tester.run(ARGS3, TEST_ALL, NEGATED_TEST_NO_C5);
// tester.runTestsOnHTML(TEST_NODEPR, TEST_NOCMNT_NODEPR);
javadoc("-Xdoclint:none",
"-d", "out-3",
"-nodeprecated",
@@ -90,8 +83,6 @@ public void test_Comment_NoDeprecated() {

@Test
public void testNoCommentNoDeprecated() {
// tester.run(ARGS4, TEST_ALL, NEGATED_TEST_NO_C5);
// tester.runTestsOnHTML(TEST_NOCMNT_NODEPR, TEST_CMNT_DEPR);
javadoc("-Xdoclint:none",
"-d", "out-4",
"-nocomment",
@@ -114,7 +105,7 @@ void checkCommon(boolean checkC5) {
"extends java.lang.Object\n" +
"implements java.io.Serializable</pre>");
checkOutput("pkg1/C4.html", true,
"<dl>\n" +
"<dl class=\"notes\">\n" +
"<dt>Default:</dt>\n" +
"<dd>true</dd>\n" +
"</dl>");
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -63,7 +63,7 @@ public void test() {
+ "<span class=\"typeNameLink\">Coin</span></a> - Enum in "
+ "<a href=\"pkg/package-summary.html\">pkg</a>",
"Class in <a href=\"package-summary.html\">&lt;Unnamed&gt;</a>",
"<dl>\n"
"<dl class=\"index\">\n"
+ "<dt><span class=\"memberNameLink\"><a href=\"pkg/C.html#Java\">"
+ "Java</a></span> - Static variable in class pkg.<a href=\"pkg/C.html\" "
+ "title=\"class in pkg\">C</a></dt>\n"
@@ -71,7 +71,7 @@ public void test() {
"<div class=\"memberSignature\"><span class=\"modifiers\">static final</span>&nbsp;"
+ "<span class=\"returnType\">int</span>&nbsp;<span class=\"memberName\">field</span></div>",
// Make sure known implementing class list is correct and omits type parameters.
"<dl>\n"
"<dl class=\"notes\">\n"
+ "<dt>All Known Implementing Classes:</dt>\n"
+ "<dd><code><a href=\"Child.html\" title=\"class in pkg\">Child"
+ "</a></code>, <code><a href=\"Parent.html\" title=\"class in pkg\">Parent"
@@ -80,7 +80,7 @@ public void test() {

checkOutput("pkg/Child.html", true,
// Make sure "All Implemented Interfaces": has substituted type parameters
"<dl>\n"
"<dl class=\"notes\">\n"
+ "<dt>All Implemented Interfaces:</dt>\n"
+ "<dd><code><a href=\"Interface.html\" title=\"interface in pkg\">"
+ "Interface</a>&lt;CE&gt;</code></dd>\n"
@@ -106,8 +106,8 @@ public void test() {
+ "title=\"type parameter in Child\">CE</a>&gt;</code></dd>");

checkOutput("pkg/Parent.html", true,
//Make sure "Direct Know Subclasses" omits type parameters
"<dl>\n"
//Make sure "Direct Known Subclasses" omits type parameters
"<dl class=\"notes\">\n"
+ "<dt>Direct Known Subclasses:</dt>\n"
+ "<dd><code><a href=\"Child.html\" title=\"class in pkg\">Child"
+ "</a></code></dd>\n"

0 comments on commit 1be89d9

Please sign in to comment.