8310118: Resource files should be moved to appropriate directories

Reviewed-by: jjg
This commit is contained in:
Hannes Wallnöfer 2023-08-09 07:01:15 +00:00
parent 96304f37f8
commit 77e5739f60
44 changed files with 174 additions and 195 deletions

View File

@ -25,13 +25,14 @@
package jdk.javadoc.internal.doclets.formats.html; package jdk.javadoc.internal.doclets.formats.html;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.net.URL;
import java.nio.file.DirectoryStream; import java.nio.file.DirectoryStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.InvalidPathException; import java.nio.file.InvalidPathException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -61,6 +62,7 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder; import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
import jdk.javadoc.internal.doclets.toolkit.util.NewAPIBuilder; import jdk.javadoc.internal.doclets.toolkit.util.NewAPIBuilder;
import jdk.javadoc.internal.doclets.toolkit.util.PreviewAPIListBuilder; import jdk.javadoc.internal.doclets.toolkit.util.PreviewAPIListBuilder;
import jdk.javadoc.internal.doclets.toolkit.util.ResourceIOException;
/** /**
* The class with "start" method, calls individual Writers. * The class with "start" method, calls individual Writers.
@ -107,12 +109,6 @@ public class HtmlDoclet extends AbstractDoclet {
*/ */
private WriterFactory writerFactory; private WriterFactory writerFactory;
/**
* Base path for resources for this doclet.
*/
private static final DocPath DOCLET_RESOURCES = DocPath
.create("/jdk/javadoc/internal/doclets/formats/html/resources");
@Override // defined by Doclet @Override // defined by Doclet
public void init(Locale locale, Reporter reporter) { public void init(Locale locale, Reporter reporter) {
configuration = new HtmlConfiguration(initiatingDoclet, locale, reporter); configuration = new HtmlConfiguration(initiatingDoclet, locale, reporter);
@ -232,13 +228,13 @@ public class HtmlDoclet extends AbstractDoclet {
return; return;
} }
boolean nodeprecated = options.noDeprecated(); boolean nodeprecated = options.noDeprecated();
performCopy(options.helpFile(), DocPath.empty); copyFile(options.helpFile(), DocPath.empty);
performCopy(options.stylesheetFile(), DocPath.empty); copyFile(options.stylesheetFile(), DocPaths.RESOURCE_FILES);
for (String stylesheet : options.additionalStylesheets()) { for (String stylesheet : options.additionalStylesheets()) {
performCopy(stylesheet, DocPath.empty); copyFile(stylesheet, DocPaths.RESOURCE_FILES);
} }
for (String script : options.additionalScripts()) { for (String script : options.additionalScripts()) {
performCopy(script, DocPaths.SCRIPT_DIR); copyFile(script, DocPaths.SCRIPT_FILES);
} }
// do early to reduce memory footprint // do early to reduce memory footprint
if (options.classUse()) { if (options.classUse()) {
@ -304,31 +300,25 @@ public class HtmlDoclet extends AbstractDoclet {
// If a stylesheet file is not specified, copy the default stylesheet // If a stylesheet file is not specified, copy the default stylesheet
// and replace newline with platform-specific newline. // and replace newline with platform-specific newline.
DocFile f;
if (options.stylesheetFile().length() == 0) { if (options.stylesheetFile().length() == 0) {
f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET); copyResource(DocPaths.STYLESHEET, DocPaths.RESOURCE_FILES.resolve(DocPaths.STYLESHEET), true);
f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.STYLESHEET), true, true);
} }
f = DocFile.createFileForOutput(configuration, DocPaths.JAVASCRIPT); copyResource(DocPaths.SCRIPT_JS, DocPaths.SCRIPT_FILES.resolve(DocPaths.SCRIPT_JS), true);
f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.JAVASCRIPT), true, true); copyResource(DocPaths.CLIPBOARD_SVG, DocPaths.RESOURCE_FILES.resolve(DocPaths.CLIPBOARD_SVG), true);
f = DocFile.createFileForOutput(configuration, DocPaths.CLIPBOARD_SVG); copyResource(DocPaths.LINK_SVG, DocPaths.RESOURCE_FILES.resolve(DocPaths.LINK_SVG), true);
f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.CLIPBOARD_SVG), true, true);
f = DocFile.createFileForOutput(configuration, DocPaths.LINK_SVG);
f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.LINK_SVG), true, true);
if (options.createIndex()) { if (options.createIndex()) {
f = DocFile.createFileForOutput(configuration, DocPaths.SEARCH_JS); copyResource(DocPaths.SEARCH_JS_TEMPLATE, DocPaths.SCRIPT_FILES.resolve(DocPaths.SEARCH_JS), true);
f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.SEARCH_JS_TEMPLATE), configuration.docResources); copyResource(DocPaths.SEARCH_PAGE_JS, DocPaths.SCRIPT_FILES.resolve(DocPaths.SEARCH_PAGE_JS), true);
copyResource(DocPaths.GLASS_IMG, DocPaths.RESOURCE_FILES.resolve(DocPaths.GLASS_IMG), false);
f = DocFile.createFileForOutput(configuration, DocPaths.SEARCH_PAGE_JS); copyResource(DocPaths.X_IMG, DocPaths.RESOURCE_FILES.resolve(DocPaths.X_IMG), false);
f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.SEARCH_PAGE_JS), configuration.docResources); // No newline replacement for JQuery files
copyResource(DocPaths.JQUERY_DIR.resolve(DocPaths.JQUERY_JS),
f = DocFile.createFileForOutput(configuration, DocPaths.RESOURCES.resolve(DocPaths.GLASS_IMG)); DocPaths.SCRIPT_FILES.resolve(DocPaths.JQUERY_JS), false);
f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.GLASS_IMG), true, false); copyResource(DocPaths.JQUERY_DIR.resolve(DocPaths.JQUERY_UI_JS),
DocPaths.SCRIPT_FILES.resolve(DocPaths.JQUERY_UI_JS), false);
f = DocFile.createFileForOutput(configuration, DocPaths.RESOURCES.resolve(DocPaths.X_IMG)); copyResource(DocPaths.JQUERY_DIR.resolve(DocPaths.JQUERY_UI_CSS),
f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.X_IMG), true, false); DocPaths.RESOURCE_FILES.resolve(DocPaths.JQUERY_UI_CSS), false); }
copyJqueryFiles();
}
copyLegalFiles(options.createIndex()); copyLegalFiles(options.createIndex());
} }
@ -340,20 +330,6 @@ public class HtmlDoclet extends AbstractDoclet {
if (configuration.tagletManager != null) { // may be null, if no files generated, perhaps because of errors if (configuration.tagletManager != null) { // may be null, if no files generated, perhaps because of errors
configuration.tagletManager.printReport(); configuration.tagletManager.printReport();
} }
}
private void copyJqueryFiles() throws DocletException {
List<String> files = Arrays.asList(
DocPaths.JQUERY_JS.getPath(),
DocPaths.JQUERY_UI_JS.getPath(),
DocPaths.JQUERY_UI_CSS.getPath());
DocFile f;
for (String file : files) {
DocPath filePath = DocPaths.SCRIPT_DIR.resolve(file);
f = DocFile.createFileForOutput(configuration, filePath);
f.copyResource(DOCLET_RESOURCES.resolve(filePath), true, false);
}
} }
private void copyLegalFiles(boolean includeJQuery) throws DocletException { private void copyLegalFiles(boolean includeJQuery) throws DocletException {
@ -444,7 +420,24 @@ public class HtmlDoclet extends AbstractDoclet {
return configuration.getOptions().getSupportedOptions(); return configuration.getOptions().getSupportedOptions();
} }
private void performCopy(String filename, DocPath targetPath) throws DocFileIOException { private void copyResource(DocPath sourcePath, DocPath targetPath, boolean replaceNewLine)
throws DocletException {
DocPath resourcePath = DocPaths.RESOURCES.resolve(sourcePath);
// Resolve resources against doclets.formats.html package
URL resourceURL = HtmlConfiguration.class.getResource(resourcePath.getPath());
if (resourceURL == null) {
throw new ResourceIOException(sourcePath, new FileNotFoundException(resourcePath.getPath()));
}
DocFile f = DocFile.createFileForOutput(configuration, targetPath);
if (sourcePath.getPath().toLowerCase(Locale.ROOT).endsWith(".template")) {
f.copyResource(resourcePath, resourceURL, configuration.docResources);
} else {
f.copyResource(resourcePath, resourceURL, replaceNewLine);
}
}
private void copyFile(String filename, DocPath targetPath) throws DocFileIOException {
if (filename.isEmpty()) { if (filename.isEmpty()) {
return; return;
} }

View File

@ -466,7 +466,6 @@ public abstract class HtmlDocletWriter {
Content body) Content body)
throws DocFileIOException { throws DocFileIOException {
List<DocPath> additionalStylesheets = configuration.getAdditionalStylesheets(); List<DocPath> additionalStylesheets = configuration.getAdditionalStylesheets();
additionalStylesheets.addAll(localStylesheets);
Head head = new Head(path, configuration.getDocletVersion(), configuration.getBuildDate()) Head head = new Head(path, configuration.getDocletVersion(), configuration.getBuildDate())
.setTimestamp(!options.noTimestamp()) .setTimestamp(!options.noTimestamp())
.setDescription(description) .setDescription(description)
@ -474,7 +473,7 @@ public abstract class HtmlDocletWriter {
.setTitle(winTitle) .setTitle(winTitle)
.setCharset(options.charset()) .setCharset(options.charset())
.addKeywords(metakeywords) .addKeywords(metakeywords)
.setStylesheets(configuration.getMainStylesheet(), additionalStylesheets) .setStylesheets(configuration.getMainStylesheet(), additionalStylesheets, localStylesheets)
.setAdditionalScripts(configuration.getAdditionalScripts()) .setAdditionalScripts(configuration.getAdditionalScripts())
.setIndex(options.createIndex(), mainBodyScript) .setIndex(options.createIndex(), mainBodyScript)
.addContent(extraHeadContent); .addContent(extraHeadContent);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -74,7 +74,7 @@ public class IndexRedirectWriter extends HtmlDocletWriter {
.setTimestamp(!options.noTimestamp()) .setTimestamp(!options.noTimestamp())
.setDescription("index redirect") .setDescription("index redirect")
.setGenerator(getGenerator(getClass())) .setGenerator(getGenerator(getClass()))
.setStylesheets(configuration.getMainStylesheet(), List.of()) // avoid reference to default stylesheet .setStylesheets(configuration.getMainStylesheet(), List.of(), List.of())
.addDefaultScript(false); .addDefaultScript(false);
String title = (options.windowTitle().length() > 0) String title = (options.windowTitle().length() > 0)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -96,7 +96,8 @@ public class SearchWriter extends HtmlDocletWriter {
.setId(HtmlId.of("page-search-link"))) .setId(HtmlId.of("page-search-link")))
.add(new HtmlTree(TagName.BUTTON) .add(new HtmlTree(TagName.BUTTON)
.add(new HtmlTree(TagName.IMG) .add(new HtmlTree(TagName.IMG)
.put(HtmlAttr.SRC, pathToRoot.resolve(DocPaths.CLIPBOARD_SVG).getPath()) .put(HtmlAttr.SRC, pathToRoot.resolve(DocPaths.RESOURCE_FILES)
.resolve(DocPaths.CLIPBOARD_SVG).getPath())
.put(HtmlAttr.ALT, copyUrlText)) .put(HtmlAttr.ALT, copyUrlText))
.add(HtmlTree.SPAN(Text.of(copyText)) .add(HtmlTree.SPAN(Text.of(copyText))
.put(HtmlAttr.DATA_COPIED, copiedText)) .put(HtmlAttr.DATA_COPIED, copiedText))
@ -114,6 +115,7 @@ public class SearchWriter extends HtmlDocletWriter {
.addUnchecked(Text.EMPTY)) .addUnchecked(Text.EMPTY))
.setId(HtmlId.of("result-section")) .setId(HtmlId.of("result-section"))
.put(HtmlAttr.STYLE, "display: none;") .put(HtmlAttr.STYLE, "display: none;")
.add(HtmlTree.SCRIPT(pathToRoot.resolve(DocPaths.SEARCH_PAGE_JS).getPath()))); .add(HtmlTree.SCRIPT(pathToRoot.resolve(DocPaths.SCRIPT_FILES)
.resolve(DocPaths.SEARCH_PAGE_JS).getPath())));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,6 +30,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.Head;
import java.io.IOException; import java.io.IOException;
import java.io.LineNumberReader; import java.io.LineNumberReader;
import java.io.Reader; import java.io.Reader;
import java.util.List;
import javax.lang.model.element.Element; import javax.lang.model.element.Element;
import javax.lang.model.element.ModuleElement; import javax.lang.model.element.ModuleElement;
@ -232,43 +233,13 @@ public class SourceToHTMLConverter {
.setDescription(HtmlDocletWriter.getDescription("source", te)) .setDescription(HtmlDocletWriter.getDescription("source", te))
.setGenerator(HtmlDocletWriter.getGenerator(getClass())) .setGenerator(HtmlDocletWriter.getGenerator(getClass()))
.addDefaultScript(false) .addDefaultScript(false)
.setStylesheets(configuration.getMainStylesheet(), configuration.getAdditionalStylesheets()); .setStylesheets(configuration.getMainStylesheet(), configuration.getAdditionalStylesheets(), List.of());
var html = HtmlTree.HTML(configuration.getLocale().getLanguage(), head, body); var html = HtmlTree.HTML(configuration.getLocale().getLanguage(), head, body);
HtmlDocument document = new HtmlDocument(html); HtmlDocument document = new HtmlDocument(html);
messages.notice("doclet.Generating_0", path.getPath()); messages.notice("doclet.Generating_0", path.getPath());
document.write(DocFile.createFileForOutput(configuration, path)); document.write(DocFile.createFileForOutput(configuration, path));
} }
/**
* Returns a link to the stylesheet file.
*
* @param head the content to which the stylesheet links will be added
*/
public void addStyleSheetProperties(Content head) {
String filename = options.stylesheetFile();
DocPath stylesheet;
if (filename.length() > 0) {
DocFile file = DocFile.createFileForInput(configuration, filename);
stylesheet = DocPath.create(file.getName());
} else {
stylesheet = DocPaths.STYLESHEET;
}
DocPath p = relativePath.resolve(stylesheet);
var link = HtmlTree.LINK("stylesheet", "text/css", p.getPath(), "Style");
head.add(link);
addStylesheets(head);
}
protected void addStylesheets(Content head) {
options.additionalStylesheets().forEach(css -> {
DocFile file = DocFile.createFileForInput(configuration, css);
DocPath cssPath = DocPath.create(file.getName());
var slink = HtmlTree.LINK("stylesheet", "text/css", relativePath.resolve(cssPath).getPath(),
"Style");
head.add(slink);
});
}
/** /**
* Get the header. * Get the header.
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -55,6 +55,7 @@ public class Head extends Content {
private boolean showTimestamp; private boolean showTimestamp;
private DocPath mainStylesheet; private DocPath mainStylesheet;
private List<DocPath> additionalStylesheets = List.of(); private List<DocPath> additionalStylesheets = List.of();
private List<DocPath> localStylesheets = List.of();
private boolean index; private boolean index;
private Script mainBodyScript; private Script mainBodyScript;
private final List<Script> scripts; private final List<Script> scripts;
@ -157,11 +158,13 @@ public class Head extends Content {
* *
* @param main the main stylesheet, or null to use the default * @param main the main stylesheet, or null to use the default
* @param additional a list of any additional stylesheets to be included * @param additional a list of any additional stylesheets to be included
* @param local a list of module- or package-local stylesheets to be included
* @return this object * @return this object
*/ */
public Head setStylesheets(DocPath main, List<DocPath> additional) { public Head setStylesheets(DocPath main, List<DocPath> additional, List<DocPath> local) {
this.mainStylesheet = main; this.mainStylesheet = main;
this.additionalStylesheets = additional; this.additionalStylesheets = additional;
this.localStylesheets = local;
return this; return this;
} }
@ -319,14 +322,19 @@ public class Head extends Content {
if (mainStylesheet == null) { if (mainStylesheet == null) {
mainStylesheet = DocPaths.STYLESHEET; mainStylesheet = DocPaths.STYLESHEET;
} }
addStylesheet(head, mainStylesheet); addStylesheet(head, DocPaths.RESOURCE_FILES.resolve(mainStylesheet));
for (DocPath path : additionalStylesheets) { for (DocPath path : additionalStylesheets) {
addStylesheet(head, DocPaths.RESOURCE_FILES.resolve(path));
}
for (DocPath path : localStylesheets) {
// Local stylesheets are contained in doc-files, so omit resource-files prefix
addStylesheet(head, path); addStylesheet(head, path);
} }
if (index) { if (index) {
addStylesheet(head, DocPaths.SCRIPT_DIR.resolve(DocPaths.JQUERY_UI_CSS)); addStylesheet(head, DocPaths.RESOURCE_FILES.resolve(DocPaths.JQUERY_UI_CSS));
} }
} }
@ -337,7 +345,7 @@ public class Head extends Content {
private void addScripts(HtmlTree head) { private void addScripts(HtmlTree head) {
if (addDefaultScript) { if (addDefaultScript) {
head.add(HtmlTree.SCRIPT(pathToRoot.resolve(DocPaths.JAVASCRIPT).getPath())); addScriptElement(head, DocPaths.SCRIPT_FILES.resolve(DocPaths.SCRIPT_JS));
} }
if (index) { if (index) {
if (pathToRoot != null && mainBodyScript != null) { if (pathToRoot != null && mainBodyScript != null) {
@ -347,11 +355,11 @@ public class Head extends Content {
.append(";\n") .append(";\n")
.append("loadScripts(document, 'script');"); .append("loadScripts(document, 'script');");
} }
addScriptElement(head, DocPaths.JQUERY_JS); addScriptElement(head, DocPaths.SCRIPT_FILES.resolve(DocPaths.JQUERY_JS));
addScriptElement(head, DocPaths.JQUERY_UI_JS); addScriptElement(head, DocPaths.SCRIPT_FILES.resolve(DocPaths.JQUERY_UI_JS));
} }
for (DocPath path : additionalScripts) { for (DocPath path : additionalScripts) {
addScriptElement(head, path); addScriptElement(head, DocPaths.SCRIPT_FILES.resolve(path));
} }
for (Script script : scripts) { for (Script script : scripts) {
head.add(script.asContent()); head.add(script.asContent());
@ -359,7 +367,7 @@ public class Head extends Content {
} }
private void addScriptElement(HtmlTree head, DocPath filePath) { private void addScriptElement(HtmlTree head, DocPath filePath) {
DocPath scriptFile = pathToRoot.resolve(DocPaths.SCRIPT_DIR).resolve(filePath); DocPath scriptFile = pathToRoot.resolve(filePath);
head.add(HtmlTree.SCRIPT(scriptFile.getPath())); head.add(HtmlTree.SCRIPT(scriptFile.getPath()));
} }
} }

View File

@ -37,7 +37,7 @@ var tableTab = "table-tab";
var activeTableTab = "active-table-tab"; var activeTableTab = "active-table-tab";
function loadScripts(doc, tag) { function loadScripts(doc, tag) {
createElem(doc, tag, 'search.js'); createElem(doc, tag, 'script-files/search.js');
createElem(doc, tag, 'module-search-index.js'); createElem(doc, tag, 'module-search-index.js');
createElem(doc, tag, 'package-search-index.js'); createElem(doc, tag, 'package-search-index.js');

View File

@ -413,7 +413,7 @@ $(function() {
var id = hdr.attr("id") || hdr.parent("section").attr("id") || hdr.children("a").attr("id"); var id = hdr.attr("id") || hdr.parent("section").attr("id") || hdr.children("a").attr("id");
if (id) { if (id) {
hdr.append(" <a href='#" + id + "' class='anchor-link' aria-label='" + messages.linkToSection hdr.append(" <a href='#" + id + "' class='anchor-link' aria-label='" + messages.linkToSection
+ "'><img src='" + pathtoroot + "link.svg' alt='" + messages.linkIcon +"' tabindex='0'" + "'><img src='" + pathtoroot + "resource-files/link.svg' alt='" + messages.linkIcon +"' tabindex='0'"
+ " width='16' height='16'></a>"); + " width='16' height='16'></a>");
} }
}); });

View File

@ -2,7 +2,7 @@
* Javadoc style sheet * Javadoc style sheet
*/ */
@import url('resources/fonts/dejavu.css'); @import url('fonts/dejavu.css');
/* /*
* These CSS custom properties (variables) define the core color and font * These CSS custom properties (variables) define the core color and font
@ -757,7 +757,7 @@ li.ui-static-link a, li.ui-static-link a:visited {
font-weight:bold; font-weight:bold;
} }
#search-input, #page-search-input { #search-input, #page-search-input {
background-image:url('resources/glass.png'); background-image:url('glass.png');
background-size:13px; background-size:13px;
background-repeat:no-repeat; background-repeat:no-repeat;
background-position:2px 3px; background-position:2px 3px;
@ -773,7 +773,7 @@ li.ui-static-link a, li.ui-static-link a:visited {
} }
#reset-button { #reset-button {
background-color: transparent; background-color: transparent;
background-image:url('resources/x.png'); background-image:url('x.png');
background-repeat:no-repeat; background-repeat:no-repeat;
background-size:contain; background-size:contain;
border:0; border:0;

View File

@ -222,7 +222,8 @@ public class SnippetTaglet extends BaseTaglet {
.add(HtmlTree.SPAN(Text.of(copyText)) .add(HtmlTree.SPAN(Text.of(copyText))
.put(HtmlAttr.DATA_COPIED, copiedText)) .put(HtmlAttr.DATA_COPIED, copiedText))
.add(new HtmlTree(TagName.IMG) .add(new HtmlTree(TagName.IMG)
.put(HtmlAttr.SRC, pathToRoot.resolve(DocPaths.CLIPBOARD_SVG).getPath()) .put(HtmlAttr.SRC, pathToRoot.resolve(DocPaths.RESOURCE_FILES)
.resolve(DocPaths.CLIPBOARD_SVG).getPath())
.put(HtmlAttr.ALT, copySnippetText)) .put(HtmlAttr.ALT, copySnippetText))
.addStyle(HtmlStyle.copy) .addStyle(HtmlStyle.copy)
.addStyle(HtmlStyle.snippetCopy) .addStyle(HtmlStyle.snippetCopy)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,6 +32,7 @@ import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.io.Writer; import java.io.Writer;
import java.net.URL;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -176,8 +177,8 @@ public abstract class DocFile {
/** /**
* Copy the contents of a resource file to this file. * Copy the contents of a resource file to this file.
* *
* @param resource the path of the resource, relative to the package of this class * @param resource the path of the resource
* @param overwrite whether or not to overwrite the file if it already exists * @param url the URL of the resource
* @param replaceNewLine if false, the file is copied as a binary file; * @param replaceNewLine if false, the file is copied as a binary file;
* if true, the file is written line by line, using the platform line * if true, the file is written line by line, using the platform line
* separator * separator
@ -185,35 +186,31 @@ public abstract class DocFile {
* @throws DocFileIOException if there is a problem while writing the copy * @throws DocFileIOException if there is a problem while writing the copy
* @throws ResourceIOException if there is a problem while reading the resource * @throws ResourceIOException if there is a problem while reading the resource
*/ */
public void copyResource(DocPath resource, boolean overwrite, boolean replaceNewLine) public void copyResource(DocPath resource, URL url, boolean replaceNewLine)
throws DocFileIOException, ResourceIOException { throws DocFileIOException, ResourceIOException {
if (exists() && !overwrite) copyResource(resource, url, replaceNewLine, null);
return;
copyResource(resource, replaceNewLine, null);
} }
/** /**
* Copy the contents of a resource file to this file. * Copy the contents of a resource file to this file.
* *
* @param resource the path of the resource, relative to the package of this class * @param resource the path of the resource
* @param url the URL of the resource
* @param resources if not {@code null}, substitute occurrences of {@code ##REPLACE:key##} * @param resources if not {@code null}, substitute occurrences of {@code ##REPLACE:key##}
* *
* @throws DocFileIOException if there is a problem while writing the copy * @throws DocFileIOException if there is a problem while writing the copy
* @throws ResourceIOException if there is a problem while reading the resource * @throws ResourceIOException if there is a problem while reading the resource
*/ */
public void copyResource(DocPath resource, Resources resources) throws DocFileIOException, ResourceIOException { public void copyResource(DocPath resource, URL url, Resources resources) throws DocFileIOException, ResourceIOException {
copyResource(resource, true, resources); copyResource(resource, url, true, resources);
} }
private void copyResource(DocPath resource, boolean replaceNewLine, Resources resources) private void copyResource(DocPath resource, URL url, boolean replaceNewLine, Resources resources)
throws DocFileIOException, ResourceIOException { throws DocFileIOException, ResourceIOException {
try { try {
InputStream in = BaseConfiguration.class.getResourceAsStream(resource.getPath()); InputStream in = url.openStream();
if (in == null)
return;
try { try (in) {
if (replaceNewLine) { if (replaceNewLine) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
try (Writer writer = openWriter()) { try (Writer writer = openWriter()) {
@ -237,8 +234,6 @@ public abstract class DocFile {
throw new DocFileIOException(this, DocFileIOException.Mode.WRITE, e); throw new DocFileIOException(this, DocFileIOException.Mode.WRITE, e);
} }
} }
} finally {
in.close();
} }
} catch (IOException e) { } catch (IOException e) {
throw new ResourceIOException(resource, e); throw new ResourceIOException(resource, e);

View File

@ -92,7 +92,7 @@ public class DocPaths {
} }
/** The name of the default javascript file. */ /** The name of the default javascript file. */
public static final DocPath JAVASCRIPT = DocPath.create("script.js"); public static final DocPath SCRIPT_JS = DocPath.create("script.js");
/** The name of the copy-to-clipboard icon file. */ /** The name of the copy-to-clipboard icon file. */
public static final DocPath CLIPBOARD_SVG = DocPath.create("copy.svg"); public static final DocPath CLIPBOARD_SVG = DocPath.create("copy.svg");
@ -100,6 +100,9 @@ public class DocPaths {
/** The name of the link icon file. */ /** The name of the link icon file. */
public static final DocPath LINK_SVG = DocPath.create("link.svg"); public static final DocPath LINK_SVG = DocPath.create("link.svg");
/** The name of the default jQuery directory. */
public static final DocPath JQUERY_DIR = DocPath.create("jquery");
/** The name of the default jQuery javascript file. */ /** The name of the default jQuery javascript file. */
public static final DocPath JQUERY_JS = DocPath.create("jquery-3.6.1.min.js"); public static final DocPath JQUERY_JS = DocPath.create("jquery-3.6.1.min.js");
@ -145,8 +148,11 @@ public class DocPaths {
/** The name of the file for preview elements. */ /** The name of the file for preview elements. */
public static final DocPath PREVIEW_LIST = DocPath.create("preview-list.html"); public static final DocPath PREVIEW_LIST = DocPath.create("preview-list.html");
/** The name of the directory for the resource files. */
public static final DocPath RESOURCE_FILES = DocPath.create("resource-files");
/** The name of the directory for the script files. */ /** The name of the directory for the script files. */
public static final DocPath SCRIPT_DIR = DocPath.create("script-dir"); public static final DocPath SCRIPT_FILES = DocPath.create("script-files");
/** The name of the file for search page. */ /** The name of the file for search page. */
public static final DocPath SEARCH_PAGE = DocPath.create("search.html"); public static final DocPath SEARCH_PAGE = DocPath.create("search.html");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -50,7 +50,7 @@ public class AccessH1 extends JavadocTester {
checkExit(Exit.OK); checkExit(Exit.OK);
// Test the style sheet // Test the style sheet
checkOutput("stylesheet.css", true, checkOutput("resource-files/stylesheet.css", true,
""" """
h1 { h1 {
font-size:1.428em; font-size:1.428em;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -73,7 +73,7 @@ public class CheckLibraryVersions {
var legalDir = rootDir.resolve("src/jdk.javadoc/share/legal"); var legalDir = rootDir.resolve("src/jdk.javadoc/share/legal");
var scriptDir = rootDir.resolve("src/jdk.javadoc/share/classes") var scriptDir = rootDir.resolve("src/jdk.javadoc/share/classes")
.resolve("jdk/javadoc/internal/doclets/formats/html") .resolve("jdk/javadoc/internal/doclets/formats/html")
.resolve("resources/script-dir"); .resolve("resources/jquery");
for (var legalFileName : libraries.keySet()) { for (var legalFileName : libraries.keySet()) {
var legalFile = legalDir.resolve(legalFileName); var legalFile = legalDir.resolve(legalFileName);

View File

@ -27,7 +27,7 @@
* @bug 8267574 * @bug 8267574
* @summary check stylesheet names against HtmlStyle * @summary check stylesheet names against HtmlStyle
* @modules jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.markup * @modules jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.markup
* jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.resources:open * jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.resources:open
*/ */
import java.io.BufferedWriter; import java.io.BufferedWriter;
@ -192,7 +192,7 @@ public class CheckStylesheetClasses {
Set<String> getStylesheetNames() throws IOException { Set<String> getStylesheetNames() throws IOException {
Set<String> names = new TreeSet<>(); Set<String> names = new TreeSet<>();
String stylesheet = "/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css"; String stylesheet = "/jdk/javadoc/internal/doclets/formats/html/resources/stylesheet.css";
URL url = HtmlStyle.class.getResource(stylesheet); URL url = HtmlStyle.class.getResource(stylesheet);
readStylesheet(url, names); readStylesheet(url, names);
return names; return names;

View File

@ -56,7 +56,7 @@ public class TestDocEncoding extends JavadocTester {
"pkg"); "pkg");
checkExit(Exit.OK); checkExit(Exit.OK);
checkOutput("stylesheet.css", true, checkOutput("resource-files/stylesheet.css", true,
""" """
body { body {
background-color:var(--body-background-color);"""); background-color:var(--body-background-color);""");
@ -64,7 +64,7 @@ public class TestDocEncoding extends JavadocTester {
// reset the charset, for a negative test, that the -docencoding // reset the charset, for a negative test, that the -docencoding
// was effective and that the output is not in UTF-8. // was effective and that the output is not in UTF-8.
charset = Charset.forName("UTF-8"); charset = Charset.forName("UTF-8");
checkOutput("stylesheet.css", false, checkOutput("resource-files/stylesheet.css", false,
""" """
body { body {
background-color:var(--page-bg-color);"""); background-color:var(--page-bg-color);""");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -61,7 +61,7 @@ public class TestJavascript extends JavadocTester {
//--> //-->
"""); """);
checkOutput("script.js", false, checkOutput("script-files/script.js", false,
""" """
$(window).resize(function() { $(window).resize(function() {
$('.navPadding').css('padding-top', $('.fixedNav').css("height")); $('.navPadding').css('padding-top', $('.fixedNav').css("height"));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -116,9 +116,9 @@ public class TestOptions extends JavadocTester {
"pkg"); "pkg");
checkExit(Exit.OK); checkExit(Exit.OK);
checkOutput("custom-stylesheet.css", true, "Custom javadoc style sheet"); checkOutput("resource-files/custom-stylesheet.css", true, "Custom javadoc style sheet");
checkOutput("pkg/Foo.html", true, """ checkOutput("pkg/Foo.html", true, """
<link rel="stylesheet" type="text/css" href="../custom-stylesheet.css" title="Style">"""); <link rel="stylesheet" type="text/css" href="../resource-files/custom-stylesheet.css" title="Style">""");
} }
@Test @Test
@ -129,9 +129,9 @@ public class TestOptions extends JavadocTester {
"pkg"); "pkg");
checkExit(Exit.OK); checkExit(Exit.OK);
checkOutput("custom-stylesheet.css", true, "Custom javadoc style sheet"); checkOutput("resource-files/custom-stylesheet.css", true, "Custom javadoc style sheet");
checkOutput("pkg/Foo.html", true, """ checkOutput("pkg/Foo.html", true, """
<link rel="stylesheet" type="text/css" href="../custom-stylesheet.css" title="Style">"""); <link rel="stylesheet" type="text/css" href="../resource-files/custom-stylesheet.css" title="Style">""");
} }
@Test @Test
@ -144,14 +144,14 @@ public class TestOptions extends JavadocTester {
"pkg"); "pkg");
checkExit(Exit.OK); checkExit(Exit.OK);
checkOutput("additional-stylesheet-1.css", true, "Additional javadoc style sheet 1"); checkOutput("resource-files/additional-stylesheet-1.css", true, "Additional javadoc style sheet 1");
checkOutput("additional-stylesheet-2.css", true, "Additional javadoc style sheet 2"); checkOutput("resource-files/additional-stylesheet-2.css", true, "Additional javadoc style sheet 2");
checkOutput("additional-stylesheet-3.css", true, "Additional javadoc style sheet 3"); checkOutput("resource-files/additional-stylesheet-3.css", true, "Additional javadoc style sheet 3");
checkOutput("pkg/Foo.html", true, checkOutput("pkg/Foo.html", true,
""" """
<link rel="stylesheet" type="text/css" href="../additional-stylesheet-1.css" title="Style"> <link rel="stylesheet" type="text/css" href="../resource-files/additional-stylesheet-1.css" title="Style">
<link rel="stylesheet" type="text/css" href="../additional-stylesheet-2.css" title="Style"> <link rel="stylesheet" type="text/css" href="../resource-files/additional-stylesheet-2.css" title="Style">
<link rel="stylesheet" type="text/css" href="../additional-stylesheet-3.css" title="Style">"""); <link rel="stylesheet" type="text/css" href="../resource-files/additional-stylesheet-3.css" title="Style">""");
} }
@Test @Test
@ -189,12 +189,12 @@ public class TestOptions extends JavadocTester {
"pkg"); "pkg");
checkExit(Exit.OK); checkExit(Exit.OK);
checkOutput("script-dir/additional-script-1.js", true, "Additional script file 1"); checkOutput("script-files/additional-script-1.js", true, "Additional script file 1");
checkOutput("script-dir/additional-script-2.js", true, "Additional script file 2"); checkOutput("script-files/additional-script-2.js", true, "Additional script file 2");
checkOutput("pkg/Foo.html", true, checkOutput("pkg/Foo.html", true,
""" """
<script type="text/javascript" src="../script-dir/additional-script-1.js"></script> <script type="text/javascript" src="../script-files/additional-script-1.js"></script>
<script type="text/javascript" src="../script-dir/additional-script-2.js"></script> <script type="text/javascript" src="../script-files/additional-script-2.js"></script>
"""); """);
} }

View File

@ -135,7 +135,7 @@ public class TestSearch extends JavadocTester {
"index-all.html", "index-all.html",
"allpackages-index.html", "allpackages-index.html",
"allclasses-index.html", "allclasses-index.html",
"search-page.js", "script-files/search-page.js",
"search.html"); "search.html");
} }
@ -179,7 +179,7 @@ public class TestSearch extends JavadocTester {
"tag-search-index.js", "tag-search-index.js",
"type-search-index.js", "type-search-index.js",
"index-all.html", "index-all.html",
"search-page.js", "script-files/search-page.js",
"search.html"); "search.html");
} }
@ -418,13 +418,13 @@ public class TestSearch extends JavadocTester {
// Test for search related markup // Test for search related markup
checkOutput(fileName, expectedOutput, checkOutput(fileName, expectedOutput,
""" """
<link rel="stylesheet" type="text/css" href="script-dir/jquery-ui.min.css" title="Style"> <link rel="stylesheet" type="text/css" href="resource-files/jquery-ui.min.css" title="Style">
""", """,
""" """
<script type="text/javascript" src="script-dir/jquery-3.6.1.min.js"></script> <script type="text/javascript" src="script-files/jquery-3.6.1.min.js"></script>
""", """,
""" """
<script type="text/javascript" src="script-dir/jquery-ui.min.js"></script>""", <script type="text/javascript" src="script-files/jquery-ui.min.js"></script>""",
""" """
var pathtoroot = "./"; var pathtoroot = "./";
loadScripts(document, 'script');""", loadScripts(document, 'script');""",
@ -690,29 +690,29 @@ public class TestSearch extends JavadocTester {
void checkJqueryAndImageFiles(boolean expectedOutput) { void checkJqueryAndImageFiles(boolean expectedOutput) {
checkFiles(expectedOutput, checkFiles(expectedOutput,
"search.js", "script-files/search.js",
"script-dir/jquery-3.6.1.min.js", "script-files/jquery-3.6.1.min.js",
"script-dir/jquery-ui.min.js", "script-files/jquery-ui.min.js",
"script-dir/jquery-ui.min.css", "resource-files/jquery-ui.min.css",
"resources/x.png", "resource-files/x.png",
"resources/glass.png"); "resource-files/glass.png");
} }
void checkSearchJS() { void checkSearchJS() {
// ensure all resource keys were resolved // ensure all resource keys were resolved
checkOutput("search.js", false, checkOutput("script-files/search.js", false,
"##REPLACE:"); "##REPLACE:");
checkOutput("search.js", true, checkOutput("script-files/search.js", true,
"function searchIndex(indexArray, category) {", "function searchIndex(indexArray, category) {",
"function getURLPrefix(item, category) {", "function getURLPrefix(item, category) {",
"url += item.l;"); "url += item.l;");
checkOutput("search-page.js", true, checkOutput("script-files/search-page.js", true,
"function renderResults(result) {", "function renderResults(result) {",
"function selectTab(category) {"); "function selectTab(category) {");
checkCssClasses("search.js", "stylesheet.css"); checkCssClasses("script-files/search.js", "resource-files/stylesheet.css");
} }
void checkCssClasses(String jsFile, String cssFile) { void checkCssClasses(String jsFile, String cssFile) {

View File

@ -115,7 +115,7 @@ public class SnippetTester extends JavadocTester {
Optional<String> id) { Optional<String> id) {
// the further away from the root, the further to reach to common resources // the further away from the root, the further to reach to common resources
int nComponents = (int) pathToHtmlFile.chars().filter(c -> c == '/').count(); int nComponents = (int) pathToHtmlFile.chars().filter(c -> c == '/').count();
var svgString = "../".repeat(nComponents) + "copy.svg"; var svgString = "../".repeat(nComponents) + "resource-files/copy.svg";
var idString = id.isEmpty() ? "" : " id=\"%s\"".formatted(id.get()); var idString = id.isEmpty() ? "" : " id=\"%s\"".formatted(id.get());
var langString = lang.isEmpty() ? "" : " class=\"language-%s\"".formatted(lang.get()); var langString = lang.isEmpty() ? "" : " class=\"language-%s\"".formatted(lang.get());
return """ return """

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -65,7 +65,7 @@ public class TestStylesheet extends JavadocTester {
// TODO: most of this test seems a bit silly, since javadoc is simply // TODO: most of this test seems a bit silly, since javadoc is simply
// copying in the stylesheet from the source directory // copying in the stylesheet from the source directory
checkOutput("stylesheet.css", true, checkOutput("resource-files/stylesheet.css", true,
""" """
body { body {
background-color:var(--body-background-color); background-color:var(--body-background-color);
@ -141,7 +141,7 @@ public class TestStylesheet extends JavadocTester {
overflow-x: auto; overflow-x: auto;
scrollbar-width: thin; scrollbar-width: thin;
}""", }""",
"@import url('resources/fonts/dejavu.css');", "@import url('fonts/dejavu.css');",
""" """
.search-tag-result:target { .search-tag-result:target {
background-color:var(--search-tag-highlight-color); background-color:var(--search-tag-highlight-color);
@ -175,7 +175,7 @@ public class TestStylesheet extends JavadocTester {
""" """
#reset-button { #reset-button {
background-color: transparent; background-color: transparent;
background-image:url('resources/x.png'); background-image:url('x.png');
background-repeat:no-repeat; background-repeat:no-repeat;
background-size:contain; background-size:contain;
border:0; border:0;
@ -197,7 +197,7 @@ public class TestStylesheet extends JavadocTester {
// Test whether a link to the stylesheet file is inserted properly // Test whether a link to the stylesheet file is inserted properly
// in the class documentation. // in the class documentation.
""" """
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">""", <link rel="stylesheet" type="text/css" href="../resource-files/stylesheet.css" title="Style">""",
""" """
<div class="block">Test comment for a class which has an <a name="named_anchor">anchor_with_name</a> and <div class="block">Test comment for a class which has an <a name="named_anchor">anchor_with_name</a> and
an <a id="named_anchor1">anchor_with_id</a>.</div>"""); an <a id="named_anchor1">anchor_with_id</a>.</div>""");
@ -211,9 +211,9 @@ public class TestStylesheet extends JavadocTester {
checkOutput("index.html", true, checkOutput("index.html", true,
""" """
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">"""); <link rel="stylesheet" type="text/css" href="resource-files/stylesheet.css" title="Style">""");
checkOutput("stylesheet.css", false, checkOutput("resource-files/stylesheet.css", false,
""" """
* { * {
margin:0; margin:0;
@ -275,7 +275,7 @@ public class TestStylesheet extends JavadocTester {
Set<String> readStylesheet() { Set<String> readStylesheet() {
// scan for class selectors, skipping '{' ... '}' // scan for class selectors, skipping '{' ... '}'
Set<String> styles = new TreeSet<>(); Set<String> styles = new TreeSet<>();
String stylesheet = readFile("stylesheet.css"); String stylesheet = readFile("resource-files/stylesheet.css");
for (int i = 0; i < stylesheet.length(); i++) { for (int i = 0; i < stylesheet.length(); i++) {
char ch = stylesheet.charAt(i); char ch = stylesheet.charAt(i);
switch (ch) { switch (ch) {

View File

@ -1,4 +1,4 @@
/* * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. /* * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -58,9 +58,10 @@ public class TestStylesheetOverwrite extends JavadocTester {
createTestClass(srcDir); createTestClass(srcDir);
Path outDir = base.resolve("out"); Path outDir = base.resolve("out");
Path resourceDir = outDir.resolve("resource-files");
Files.createDirectories(resourceDir);
Files.createDirectory(outDir); Path stylesheet = resourceDir.resolve("stylesheet.css");
Path stylesheet = outDir.resolve("stylesheet.css");
Files.createFile(stylesheet); Files.createFile(stylesheet);
Files.write(stylesheet, List.of("/* custom stylesheet */")); Files.write(stylesheet, List.of("/* custom stylesheet */"));
@ -71,7 +72,7 @@ public class TestStylesheetOverwrite extends JavadocTester {
"pkg"); "pkg");
checkExit(Exit.OK); checkExit(Exit.OK);
checkOutput("stylesheet.css", true, "Javadoc style sheet"); checkOutput("resource-files/stylesheet.css", true, "Javadoc style sheet");
} }
void createTestClass(Path srcDir) throws Exception { void createTestClass(Path srcDir) throws Exception {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -141,11 +141,11 @@ public class TestTerminology extends JavadocTester {
"p"); "p");
checkExit(Exit.OK); checkExit(Exit.OK);
checkOutput("search.js", sv.compareTo(SourceVersion.RELEASE_16) < 0, checkOutput("script-files/search.js", sv.compareTo(SourceVersion.RELEASE_16) < 0,
""" """
types: "Types",""" types: "Types","""
); );
checkOutput("search.js", sv.compareTo(SourceVersion.RELEASE_16) >= 0, checkOutput("script-files/search.js", sv.compareTo(SourceVersion.RELEASE_16) >= 0,
""" """
types: "Classes and Interfaces",""" types: "Classes and Interfaces","""
); );

View File

@ -196,17 +196,11 @@ class APITest {
"allclasses-index.html", "allclasses-index.html",
"allpackages-index.html", "allpackages-index.html",
"constant-values.html", "constant-values.html",
"copy.svg",
"deprecated-list.html", "deprecated-list.html",
"help-doc.html", "help-doc.html",
"index-all.html", "index-all.html",
"index.html", "index.html",
"link.svg",
"script-dir/jquery-3.6.1.min.js",
"script-dir/jquery-ui.min.js",
"script-dir/jquery-ui.min.css",
"search.html", "search.html",
"search-page.js",
"member-search-index.js", "member-search-index.js",
"module-search-index.js", "module-search-index.js",
"overview-tree.html", "overview-tree.html",
@ -215,23 +209,32 @@ class APITest {
"pkg/C.html", "pkg/C.html",
"pkg/package-summary.html", "pkg/package-summary.html",
"pkg/package-tree.html", "pkg/package-tree.html",
"resources/glass.png", "resource-files/copy.svg",
"resources/x.png", "resource-files/glass.png",
"script.js", "resource-files/jquery-ui.min.css",
"search.js", "resource-files/link.svg",
"stylesheet.css", "resource-files/stylesheet.css",
"resource-files/x.png",
"script-files/jquery-3.6.1.min.js",
"script-files/jquery-ui.min.js",
"script-files/script.js",
"script-files/search.js",
"script-files/search-page.js",
"tag-search-index.js", "tag-search-index.js",
"type-search-index.js" "type-search-index.js"
)); ));
protected static Set<String> noIndexFiles = standardExpectFiles.stream() protected static Set<String> noIndexFiles = standardExpectFiles.stream()
.filter(s -> !s.startsWith("script-dir") .filter(s ->
&& !s.startsWith("resources") !s.endsWith("-search-index.js")
&& !s.endsWith("-search-index.js")
&& !s.equals("index-all.html") && !s.equals("index-all.html")
&& !s.equals("search.js") && !s.equals("resource-files/glass.png")
&& !s.equals("resource-files/jquery-ui.min.css")
&& !s.equals("resource-files/x.png")
&& !s.startsWith("script-files/jquery-")
&& !s.equals("script-files/search.js")
&& !s.equals("script-files/search-page.js")
&& !s.equals("search.html") && !s.equals("search.html")
&& !s.equals("search-page.js")
&& !s.equals("allclasses-index.html") && !s.equals("allclasses-index.html")
&& !s.equals("allpackages-index.html") && !s.equals("allpackages-index.html")
&& !s.equals("system-properties.html")) && !s.equals("system-properties.html"))