mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-06 03:35:10 +00:00
8166175: javadoc search doesn't work on local doc bundles
Reviewed-by: jjg, ksrini
This commit is contained in:
parent
210dd83834
commit
30c9249c9d
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2017, 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
|
||||
@ -437,23 +437,23 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
|
||||
protected void createSearchIndexFiles() throws DocFileIOException {
|
||||
if (configuration.showModules) {
|
||||
createSearchIndexFile(DocPaths.MODULE_SEARCH_INDEX_JSON, DocPaths.MODULE_SEARCH_INDEX_ZIP,
|
||||
configuration.moduleSearchIndex);
|
||||
DocPaths.MODULE_SEARCH_INDEX_JS, configuration.moduleSearchIndex, "moduleSearchIndex");
|
||||
}
|
||||
createSearchIndexFile(DocPaths.PACKAGE_SEARCH_INDEX_JSON, DocPaths.PACKAGE_SEARCH_INDEX_ZIP,
|
||||
configuration.packageSearchIndex);
|
||||
DocPaths.PACKAGE_SEARCH_INDEX_JS, configuration.packageSearchIndex, "packageSearchIndex");
|
||||
createSearchIndexFile(DocPaths.TYPE_SEARCH_INDEX_JSON, DocPaths.TYPE_SEARCH_INDEX_ZIP,
|
||||
configuration.typeSearchIndex);
|
||||
DocPaths.TYPE_SEARCH_INDEX_JS, configuration.typeSearchIndex, "typeSearchIndex");
|
||||
createSearchIndexFile(DocPaths.MEMBER_SEARCH_INDEX_JSON, DocPaths.MEMBER_SEARCH_INDEX_ZIP,
|
||||
configuration.memberSearchIndex);
|
||||
DocPaths.MEMBER_SEARCH_INDEX_JS, configuration.memberSearchIndex, "memberSearchIndex");
|
||||
createSearchIndexFile(DocPaths.TAG_SEARCH_INDEX_JSON, DocPaths.TAG_SEARCH_INDEX_ZIP,
|
||||
configuration.tagSearchIndex);
|
||||
DocPaths.TAG_SEARCH_INDEX_JS, configuration.tagSearchIndex, "tagSearchIndex");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws DocFileIOException if there is a problem creating the search index file
|
||||
*/
|
||||
protected void createSearchIndexFile(DocPath searchIndexFile, DocPath searchIndexZip,
|
||||
List<SearchIndexItem> searchIndex) throws DocFileIOException {
|
||||
DocPath searchIndexJS, List<SearchIndexItem> searchIndex, String varName) throws DocFileIOException {
|
||||
if (!searchIndex.isEmpty()) {
|
||||
StringBuilder searchVar = new StringBuilder("[");
|
||||
boolean first = true;
|
||||
@ -466,6 +466,14 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
|
||||
}
|
||||
}
|
||||
searchVar.append("]");
|
||||
DocFile jsFile = DocFile.createFileForOutput(configuration, searchIndexJS);
|
||||
try (Writer wr = jsFile.openWriter()) {
|
||||
wr.write(varName);
|
||||
wr.write(" = ");
|
||||
wr.write(searchVar.toString());
|
||||
} catch (IOException ie) {
|
||||
throw new DocFileIOException(jsFile, DocFileIOException.Mode.WRITE, ie);
|
||||
}
|
||||
|
||||
DocFile zipFile = DocFile.createFileForOutput(configuration, searchIndexZip);
|
||||
try (OutputStream fos = zipFile.openOutputStream();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2017, 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
|
||||
@ -77,6 +77,21 @@ function loadScripts(doc, tag) {
|
||||
tagSearchIndex = JSON.parse(zip.file("tag-search-index.json").asText());
|
||||
});
|
||||
});
|
||||
if (!moduleSearchIndex) {
|
||||
createElem(doc, tag, 'module-search-index.js');
|
||||
}
|
||||
if (!packageSearchIndex) {
|
||||
createElem(doc, tag, 'package-search-index.js');
|
||||
}
|
||||
if (!typeSearchIndex) {
|
||||
createElem(doc, tag, 'type-search-index.js');
|
||||
}
|
||||
if (!memberSearchIndex) {
|
||||
createElem(doc, tag, 'member-search-index.js');
|
||||
}
|
||||
if (!tagSearchIndex) {
|
||||
createElem(doc, tag, 'tag-search-index.js');
|
||||
}
|
||||
}
|
||||
|
||||
function createElem(doc, tag, path) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2017, 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
|
||||
@ -121,12 +121,18 @@ public class DocPaths {
|
||||
/** The name of the member search index zip file. */
|
||||
public static final DocPath MEMBER_SEARCH_INDEX_ZIP = DocPath.create("member-search-index.zip");
|
||||
|
||||
/** The name of the member search index js file. */
|
||||
public static final DocPath MEMBER_SEARCH_INDEX_JS = DocPath.create("member-search-index.js");
|
||||
|
||||
/** The name of the module search index file. */
|
||||
public static final DocPath MODULE_SEARCH_INDEX_JSON = DocPath.create("module-search-index.json");
|
||||
|
||||
/** The name of the module search index zipfile. */
|
||||
/** The name of the module search index zip file. */
|
||||
public static final DocPath MODULE_SEARCH_INDEX_ZIP = DocPath.create("module-search-index.zip");
|
||||
|
||||
/** The name of the module search index js file. */
|
||||
public static final DocPath MODULE_SEARCH_INDEX_JS = DocPath.create("module-search-index.js");
|
||||
|
||||
/** The name of the file for the overview frame. */
|
||||
public static final DocPath OVERVIEW_FRAME = DocPath.create("overview-frame.html");
|
||||
|
||||
@ -149,9 +155,12 @@ public class DocPaths {
|
||||
/** The name of the package search index file. */
|
||||
public static final DocPath PACKAGE_SEARCH_INDEX_JSON = DocPath.create("package-search-index.json");
|
||||
|
||||
/** The name of the package search index zipfile. */
|
||||
/** The name of the package search index zip file. */
|
||||
public static final DocPath PACKAGE_SEARCH_INDEX_ZIP = DocPath.create("package-search-index.zip");
|
||||
|
||||
/** The name of the package search index js file. */
|
||||
public static final DocPath PACKAGE_SEARCH_INDEX_JS = DocPath.create("package-search-index.js");
|
||||
|
||||
/** The name of the file for the package summary. */
|
||||
public static final DocPath PACKAGE_SUMMARY = DocPath.create("package-summary.html");
|
||||
|
||||
@ -202,12 +211,18 @@ public class DocPaths {
|
||||
/** The name of the tag search index zip file. */
|
||||
public static final DocPath TAG_SEARCH_INDEX_ZIP = DocPath.create("tag-search-index.zip");
|
||||
|
||||
/** The name of the tag search index js file. */
|
||||
public static final DocPath TAG_SEARCH_INDEX_JS = DocPath.create("tag-search-index.js");
|
||||
|
||||
/** The name of the type search index file. */
|
||||
public static final DocPath TYPE_SEARCH_INDEX_JSON = DocPath.create("type-search-index.json");
|
||||
|
||||
/** The name of the type search index zip file. */
|
||||
public static final DocPath TYPE_SEARCH_INDEX_ZIP = DocPath.create("type-search-index.zip");
|
||||
|
||||
/** The name of the type search index js file. */
|
||||
public static final DocPath TYPE_SEARCH_INDEX_JS = DocPath.create("type-search-index.js");
|
||||
|
||||
/** The name of the image file for undo button on the search box. */
|
||||
public static final DocPath X_IMG = DocPath.create("x.png");
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2017, 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
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8141492 8071982 8141636 8147890
|
||||
* @bug 8141492 8071982 8141636 8147890 8166175
|
||||
* @summary Test the search feature of javadoc.
|
||||
* @author bpatel
|
||||
* @library ../lib
|
||||
@ -47,10 +47,14 @@ public class TestSearch extends JavadocTester {
|
||||
checkSearchJS();
|
||||
checkFiles(false,
|
||||
"package-search-index.zip",
|
||||
"tag-search-index.zip");
|
||||
"tag-search-index.zip",
|
||||
"package-search-index.js",
|
||||
"tag-search-index.js");
|
||||
checkFiles(true,
|
||||
"member-search-index.zip",
|
||||
"type-search-index.zip");
|
||||
"type-search-index.zip",
|
||||
"member-search-index.js",
|
||||
"type-search-index.js");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -67,7 +71,11 @@ public class TestSearch extends JavadocTester {
|
||||
"member-search-index.zip",
|
||||
"package-search-index.zip",
|
||||
"tag-search-index.zip",
|
||||
"type-search-index.zip");
|
||||
"type-search-index.zip",
|
||||
"member-search-index.js",
|
||||
"package-search-index.js",
|
||||
"tag-search-index.js",
|
||||
"type-search-index.js");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -84,7 +92,11 @@ public class TestSearch extends JavadocTester {
|
||||
"member-search-index.zip",
|
||||
"package-search-index.zip",
|
||||
"tag-search-index.zip",
|
||||
"type-search-index.zip");
|
||||
"type-search-index.zip",
|
||||
"member-search-index.js",
|
||||
"package-search-index.js",
|
||||
"tag-search-index.js",
|
||||
"type-search-index.js");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -100,6 +112,10 @@ public class TestSearch extends JavadocTester {
|
||||
"package-search-index.zip",
|
||||
"tag-search-index.zip",
|
||||
"type-search-index.zip",
|
||||
"member-search-index.js",
|
||||
"package-search-index.js",
|
||||
"tag-search-index.js",
|
||||
"type-search-index.js",
|
||||
"index-all.html");
|
||||
}
|
||||
|
||||
@ -117,7 +133,11 @@ public class TestSearch extends JavadocTester {
|
||||
"member-search-index.zip",
|
||||
"package-search-index.zip",
|
||||
"tag-search-index.zip",
|
||||
"type-search-index.zip");
|
||||
"type-search-index.zip",
|
||||
"member-search-index.js",
|
||||
"package-search-index.js",
|
||||
"tag-search-index.js",
|
||||
"type-search-index.js");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -133,6 +153,10 @@ public class TestSearch extends JavadocTester {
|
||||
"package-search-index.zip",
|
||||
"tag-search-index.zip",
|
||||
"type-search-index.zip",
|
||||
"member-search-index.js",
|
||||
"package-search-index.js",
|
||||
"tag-search-index.js",
|
||||
"type-search-index.js",
|
||||
"index-all.html");
|
||||
}
|
||||
|
||||
@ -150,7 +174,11 @@ public class TestSearch extends JavadocTester {
|
||||
"member-search-index.zip",
|
||||
"package-search-index.zip",
|
||||
"tag-search-index.zip",
|
||||
"type-search-index.zip");
|
||||
"type-search-index.zip",
|
||||
"member-search-index.js",
|
||||
"package-search-index.js",
|
||||
"tag-search-index.js",
|
||||
"type-search-index.js");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -167,7 +195,11 @@ public class TestSearch extends JavadocTester {
|
||||
"member-search-index.zip",
|
||||
"package-search-index.zip",
|
||||
"tag-search-index.zip",
|
||||
"type-search-index.zip");
|
||||
"type-search-index.zip",
|
||||
"member-search-index.js",
|
||||
"package-search-index.js",
|
||||
"tag-search-index.js",
|
||||
"type-search-index.js");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -184,7 +216,11 @@ public class TestSearch extends JavadocTester {
|
||||
"member-search-index.zip",
|
||||
"package-search-index.zip",
|
||||
"tag-search-index.zip",
|
||||
"type-search-index.zip");
|
||||
"type-search-index.zip",
|
||||
"member-search-index.js",
|
||||
"package-search-index.js",
|
||||
"tag-search-index.js",
|
||||
"type-search-index.js");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -197,11 +233,15 @@ public class TestSearch extends JavadocTester {
|
||||
checkJqueryAndImageFiles(true);
|
||||
checkSearchJS();
|
||||
checkFiles(false,
|
||||
"tag-search-index.zip");
|
||||
"tag-search-index.zip",
|
||||
"tag-search-index.js");
|
||||
checkFiles(true,
|
||||
"member-search-index.zip",
|
||||
"package-search-index.zip",
|
||||
"type-search-index.zip");
|
||||
"type-search-index.zip",
|
||||
"member-search-index.js",
|
||||
"package-search-index.js",
|
||||
"type-search-index.js");
|
||||
}
|
||||
|
||||
void checkDocLintErrors() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user