Skip to content
Permalink
Browse files

8237909: Remove zipped index files feature

Reviewed-by: hannesw, jjg
  • Loading branch information
pavelrappo committed Feb 11, 2020
1 parent fff1a59 commit 56a76315553baff0bf5e1fdeccbdec5e3b1f3265
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@@ -26,12 +26,9 @@
package jdk.javadoc.internal.doclets.formats.html;

import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.util.Collection;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
@@ -426,8 +423,9 @@ public String getNameForIndex(String unicode) {
*/
protected void createSearchIndexFiles() throws DocFileIOException {
if (configuration.showModules) {
createSearchIndexFile(DocPaths.MODULE_SEARCH_INDEX_JSON, DocPaths.MODULE_SEARCH_INDEX_ZIP,
DocPaths.MODULE_SEARCH_INDEX_JS, configuration.moduleSearchIndex, "moduleSearchIndex");
createSearchIndexFile(DocPaths.MODULE_SEARCH_INDEX_JS,
configuration.moduleSearchIndex,
"moduleSearchIndex");
}
if (!configuration.packages.isEmpty()) {
SearchIndexItem si = new SearchIndexItem();
@@ -436,33 +434,38 @@ protected void createSearchIndexFiles() throws DocFileIOException {
si.setUrl(DocPaths.ALLPACKAGES_INDEX.getPath());
configuration.packageSearchIndex.add(si);
}
createSearchIndexFile(DocPaths.PACKAGE_SEARCH_INDEX_JSON, DocPaths.PACKAGE_SEARCH_INDEX_ZIP,
DocPaths.PACKAGE_SEARCH_INDEX_JS, configuration.packageSearchIndex, "packageSearchIndex");
createSearchIndexFile(DocPaths.PACKAGE_SEARCH_INDEX_JS,
configuration.packageSearchIndex,
"packageSearchIndex");
SearchIndexItem si = new SearchIndexItem();
si.setCategory(SearchIndexItem.Category.TYPES);
si.setLabel(resources.getText("doclet.All_Classes"));
si.setUrl(DocPaths.ALLCLASSES_INDEX.getPath());
configuration.typeSearchIndex.add(si);
createSearchIndexFile(DocPaths.TYPE_SEARCH_INDEX_JSON, DocPaths.TYPE_SEARCH_INDEX_ZIP,
DocPaths.TYPE_SEARCH_INDEX_JS, configuration.typeSearchIndex, "typeSearchIndex");
createSearchIndexFile(DocPaths.MEMBER_SEARCH_INDEX_JSON, DocPaths.MEMBER_SEARCH_INDEX_ZIP,
DocPaths.MEMBER_SEARCH_INDEX_JS, configuration.memberSearchIndex, "memberSearchIndex");
createSearchIndexFile(DocPaths.TAG_SEARCH_INDEX_JSON, DocPaths.TAG_SEARCH_INDEX_ZIP,
DocPaths.TAG_SEARCH_INDEX_JS, configuration.tagSearchIndex, "tagSearchIndex");
createSearchIndexFile(DocPaths.TYPE_SEARCH_INDEX_JS,
configuration.typeSearchIndex,
"typeSearchIndex");
createSearchIndexFile(DocPaths.MEMBER_SEARCH_INDEX_JS,
configuration.memberSearchIndex,
"memberSearchIndex");
createSearchIndexFile(DocPaths.TAG_SEARCH_INDEX_JS,
configuration.tagSearchIndex,
"tagSearchIndex");
}

/**
* Creates a search index file.
*
* @param searchIndexFile the file to be generated
* @param searchIndexZip the zip file to be generated
* @param searchIndexJS the file for the JavaScript to be generated
* @param searchIndex the search index items
* @param varName the variable name to write in the JavaScript file
* @throws DocFileIOException if there is a problem creating the search index file
*/
protected void createSearchIndexFile(DocPath searchIndexFile, DocPath searchIndexZip,
DocPath searchIndexJS, Collection<SearchIndexItem> searchIndex, String varName) throws DocFileIOException {
protected void createSearchIndexFile(DocPath searchIndexJS,
Collection<SearchIndexItem> searchIndex,
String varName)
throws DocFileIOException
{
if (!searchIndex.isEmpty()) {
StringBuilder searchVar = new StringBuilder("[");
boolean first = true;
@@ -483,20 +486,6 @@ protected void createSearchIndexFile(DocPath searchIndexFile, DocPath searchInde
} catch (IOException ie) {
throw new DocFileIOException(jsFile, DocFileIOException.Mode.WRITE, ie);
}

DocFile zipFile = DocFile.createFileForOutput(configuration, searchIndexZip);
try (OutputStream fos = zipFile.openOutputStream();
ZipOutputStream zos = new ZipOutputStream(fos)) {
try {
ZipEntry ze = new ZipEntry(searchIndexFile.getPath());
zos.putNextEntry(ze);
zos.write(searchVar.toString().getBytes());
} finally {
zos.closeEntry();
}
} catch (IOException ie) {
throw new DocFileIOException(zipFile, DocFileIOException.Mode.WRITE, ie);
}
}
}
}
@@ -223,12 +223,6 @@ private void copyJqueryFiles() throws DocletException {
"jquery-ui.min.css",
"jquery-ui.structure.min.css",
"jquery-ui.structure.css",
"jszip/dist/jszip.js",
"jszip/dist/jszip.min.js",
"jszip-utils/dist/jszip-utils.js",
"jszip-utils/dist/jszip-utils.min.js",
"jszip-utils/dist/jszip-utils-ie.js",
"jszip-utils/dist/jszip-utils-ie.min.js",
"images/ui-bg_glass_65_dadada_1x400.png",
"images/ui-icons_454545_256x240.png",
"images/ui-bg_glass_95_fef1ec_1x400.png",
@@ -313,11 +313,6 @@ private void addScripts(HtmlTree tree) {
.append(";\n")
.append("loadScripts(document, 'script');");
}
addJQueryFile(tree, DocPaths.JSZIP_MIN);
addJQueryFile(tree, DocPaths.JSZIPUTILS_MIN);
tree.add(new RawHtml("<!--[if IE]>"));
addJQueryFile(tree, DocPaths.JSZIPUTILS_IE_MIN);
tree.add(new RawHtml("<![endif]-->"));
addJQueryFile(tree, DocPaths.JQUERY_JS_3_4);
addJQueryFile(tree, DocPaths.JQUERY_JS);
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 56a7631

Please sign in to comment.