8241190: Fix name clash for constants-summary CSS class
Reviewed-by: hannesw
This commit is contained in:
parent
b6783320ca
commit
f0ba0dc6dc
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html
test/langtools/jdk/javadoc/doclet
@ -2095,8 +2095,7 @@ public class HtmlDocletWriter {
|
||||
* @return an HtmlTree for the BODY tag
|
||||
*/
|
||||
public HtmlTree getBody(String title) {
|
||||
HtmlTree body = new HtmlTree(TagName.BODY);
|
||||
body.put(HtmlAttr.CLASS, getBodyClass());
|
||||
HtmlTree body = new HtmlTree(TagName.BODY).setStyle(getBodyStyle());
|
||||
|
||||
this.winTitle = title;
|
||||
// Don't print windowtitle script for overview-frame, allclasses-frame
|
||||
@ -2107,13 +2106,13 @@ public class HtmlDocletWriter {
|
||||
return body;
|
||||
}
|
||||
|
||||
public String getBodyClass() {
|
||||
return getClass().getSimpleName()
|
||||
public HtmlStyle getBodyStyle() {
|
||||
String kind = getClass().getSimpleName()
|
||||
.replaceAll("(Writer)?(Impl)?$", "")
|
||||
.replaceAll("AnnotationType", "Class")
|
||||
.replaceAll("(.)([A-Z])", "$1-$2")
|
||||
.replaceAll("(?i)^(module|package|class)$", "$1-declaration")
|
||||
.toLowerCase(Locale.US);
|
||||
.replaceAll("^(Module|Package|Class)$", "$1Declaration");
|
||||
String page = kind.substring(0, 1).toLowerCase(Locale.US) + kind.substring(1) + "Page";
|
||||
return HtmlStyle.valueOf(page);
|
||||
}
|
||||
|
||||
Script getMainBodyScript() {
|
||||
|
@ -31,6 +31,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.Head;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.TagName;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.Script;
|
||||
@ -104,8 +105,7 @@ public class IndexRedirectWriter extends HtmlDocletWriter {
|
||||
|
||||
bodyContent.add(HtmlTree.P(HtmlTree.A(targetPath, new StringContent(targetPath))));
|
||||
|
||||
Content body = new HtmlTree(TagName.BODY)
|
||||
.put(HtmlAttr.CLASS, "index-redirect");
|
||||
Content body = new HtmlTree(TagName.BODY).setStyle(HtmlStyle.indexRedirectPage);
|
||||
HtmlTree main = HtmlTree.MAIN(bodyContent);
|
||||
body.add(main);
|
||||
|
||||
|
2
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java
2
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java
@ -285,7 +285,7 @@ public class SourceToHTMLConverter {
|
||||
* @return the header content for the HTML file
|
||||
*/
|
||||
private static Content getHeader() {
|
||||
return new HtmlTree(TagName.BODY).setStyle(HtmlStyle.source);
|
||||
return new HtmlTree(TagName.BODY).setStyle(HtmlStyle.sourcePage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,7 +129,6 @@ public enum HtmlStyle {
|
||||
serializedClassDetails,
|
||||
servicesSummary,
|
||||
skipNav,
|
||||
source,
|
||||
sourceContainer,
|
||||
sourceLineNo,
|
||||
subNav,
|
||||
@ -148,7 +147,115 @@ public enum HtmlStyle {
|
||||
typeSummary,
|
||||
useSummary,
|
||||
usesSummary,
|
||||
verticalSeparator;
|
||||
verticalSeparator,
|
||||
|
||||
// The following constants are used for the class of the {@code <body>} element
|
||||
// for the corresponding pages.
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for the "All Classes" index page.
|
||||
*/
|
||||
allClassesIndexPage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for the "All Packages" index page.
|
||||
*/
|
||||
allPackagesIndexPage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for a class-declaration page.
|
||||
*/
|
||||
classDeclarationPage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for a class-use page.
|
||||
*/
|
||||
classUsePage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for the constants-summary page.
|
||||
*/
|
||||
constantsSummaryPage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for the page listing any deprecated items.
|
||||
*/
|
||||
deprecatedListPage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for a "doc-file" page..
|
||||
*/
|
||||
docFilePage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for the "help" page.
|
||||
*/
|
||||
helpPage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for the top-level redirect page.
|
||||
*/
|
||||
indexRedirectPage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for a module-declaration page.
|
||||
*/
|
||||
moduleDeclarationPage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for the module-index page.
|
||||
*/
|
||||
moduleIndexPage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for a package-declaration page.
|
||||
*/
|
||||
packageDeclarationPage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for the package-index page.
|
||||
*/
|
||||
packageIndexPage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for the page for the package hierarchy.
|
||||
*/
|
||||
packageTreePage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for a package-use page.
|
||||
*/
|
||||
packageUsePage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for the serialized-forms page.
|
||||
*/
|
||||
serializedFormPage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for the full single index page.
|
||||
*/
|
||||
singleIndexPage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for a page with the source code for a class.
|
||||
*/
|
||||
sourcePage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for a page in a "split index".
|
||||
*/
|
||||
splitIndexPage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for the system-properties page.
|
||||
*/
|
||||
systemPropertiesPage,
|
||||
|
||||
/**
|
||||
* The class of the {@code body} element for the page for the class hierarchy.
|
||||
*/
|
||||
treePage;
|
||||
|
||||
private final String cssName;
|
||||
|
||||
|
@ -54,10 +54,10 @@ public class JavascriptWinTitle extends JavadocTester {
|
||||
checkExit(Exit.OK);
|
||||
checkOutput("index.html", true,
|
||||
"<script type=\"text/javascript\">",
|
||||
"<body class=\"package-index\">");
|
||||
"<body class=\"package-index-page\">");
|
||||
|
||||
// Test that "onload" is not present in BODY tag:
|
||||
checkOutput("p1/package-summary.html", true, "<body class=\"package-declaration\">");
|
||||
checkOutput("p1/package-summary.html", true, "<body class=\"package-declaration-page\">");
|
||||
|
||||
checkOutput("p1/C.html", true, "<title>C (Window Title)</title>");
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8218998 8219946 8219060
|
||||
* @bug 8218998 8219946 8219060 8241190
|
||||
* @summary Add metadata to generated API documentation files
|
||||
* @library /tools/lib ../../lib
|
||||
* @modules jdk.javadoc/jdk.javadoc.internal.tool
|
||||
@ -137,27 +137,27 @@ public class TestMetadata extends JavadocTester {
|
||||
final Pattern nl = Pattern.compile("[\\r\\n]+");
|
||||
final Pattern bodyPattern = Pattern.compile("<body [^>]*class=\"([^\"]+)\"");
|
||||
final Set<String> allBodyClasses = Set.of(
|
||||
"all-classes-index",
|
||||
"all-packages-index",
|
||||
"class-declaration",
|
||||
"class-use",
|
||||
"constants-summary",
|
||||
"deprecated-list",
|
||||
"doc-file",
|
||||
"help",
|
||||
"index-redirect",
|
||||
"module-declaration",
|
||||
"module-index",
|
||||
"package-declaration",
|
||||
"package-index",
|
||||
"package-tree",
|
||||
"package-use",
|
||||
"serialized-form",
|
||||
"single-index",
|
||||
"source",
|
||||
"split-index",
|
||||
"system-properties",
|
||||
"tree"
|
||||
"all-classes-index-page",
|
||||
"all-packages-index-page",
|
||||
"class-declaration-page",
|
||||
"class-use-page",
|
||||
"constants-summary-page",
|
||||
"deprecated-list-page",
|
||||
"doc-file-page",
|
||||
"help-page",
|
||||
"index-redirect-page",
|
||||
"module-declaration-page",
|
||||
"module-index-page",
|
||||
"package-declaration-page",
|
||||
"package-index-page",
|
||||
"package-tree-page",
|
||||
"package-use-page",
|
||||
"serialized-form-page",
|
||||
"single-index-page",
|
||||
"source-page",
|
||||
"split-index-page",
|
||||
"system-properties-page",
|
||||
"tree-page"
|
||||
);
|
||||
|
||||
void checkBodyClasses() throws IOException {
|
||||
@ -413,4 +413,3 @@ public class TestMetadata extends JavadocTester {
|
||||
return src;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user