8181622: new {@index} tag generates multiple index entries
Reviewed-by: jjg, ksrini
This commit is contained in:
parent
0fc53f8797
commit
f26667d2a2
@ -455,7 +455,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
|
||||
* @throws DocFileIOException if there is a problem creating the search index file
|
||||
*/
|
||||
protected void createSearchIndexFile(DocPath searchIndexFile, DocPath searchIndexZip,
|
||||
DocPath searchIndexJS, List<SearchIndexItem> searchIndex, String varName) throws DocFileIOException {
|
||||
DocPath searchIndexJS, Collection<SearchIndexItem> searchIndex, String varName) throws DocFileIOException {
|
||||
if (!searchIndex.isEmpty()) {
|
||||
StringBuilder searchVar = new StringBuilder("[");
|
||||
boolean first = true;
|
||||
|
@ -224,7 +224,7 @@ public class HtmlConfiguration extends BaseConfiguration {
|
||||
|
||||
protected List<SearchIndexItem> packageSearchIndex = new ArrayList<>();
|
||||
|
||||
protected List<SearchIndexItem> tagSearchIndex = new ArrayList<>();
|
||||
protected SortedSet<SearchIndexItem> tagSearchIndex = new TreeSet<>(makeSearchTagComparator());
|
||||
|
||||
protected List<SearchIndexItem> typeSearchIndex = new ArrayList<>();
|
||||
|
||||
@ -348,6 +348,16 @@ public class HtmlConfiguration extends BaseConfiguration {
|
||||
return htmlTag.allowTag(this.htmlVersion);
|
||||
}
|
||||
|
||||
public Comparator<SearchIndexItem> makeSearchTagComparator() {
|
||||
return (SearchIndexItem sii1, SearchIndexItem sii2) -> {
|
||||
int result = (sii1.getLabel()).compareTo(sii2.getLabel());
|
||||
if (result == 0) {
|
||||
result = (sii1.getHolder()).compareTo(sii2.getHolder());
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Decide the page which will appear first in the right-hand frame. It will
|
||||
* be "overview-summary.html" if "-overview" option is used or no
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 8154119 8154262 8156077 8157987 8154261 8154817 8135291 8155995 8162363
|
||||
* 8168766 8168688 8162674 8160196 8175799 8174974 8176778 8177562 8175218 8175823 8166306
|
||||
* 8178043
|
||||
* 8178043 8181622
|
||||
* @summary Test modules support in javadoc.
|
||||
* @author bpatel
|
||||
* @library ../lib
|
||||
@ -394,7 +394,7 @@ public class TestModules extends JavadocTester {
|
||||
+ "<a name=\"module.description\">\n"
|
||||
+ "<!-- -->\n"
|
||||
+ "</a>\n"
|
||||
+ "<div class=\"block\">This is a test description for the moduleA module. Search "
|
||||
+ "<div class=\"block\">This is a test description for the moduleA module with a Search "
|
||||
+ "phrase <a id=\"searchphrase\" class=\"searchTagResult\">search phrase</a>.</div>");
|
||||
checkOutput("moduleB-summary.html", found,
|
||||
"<!-- ============ MODULE DESCRIPTION =========== -->\n"
|
||||
@ -454,7 +454,7 @@ public class TestModules extends JavadocTester {
|
||||
+ "<a id=\"module.description\">\n"
|
||||
+ "<!-- -->\n"
|
||||
+ "</a>\n"
|
||||
+ "<div class=\"block\">This is a test description for the moduleA module. Search "
|
||||
+ "<div class=\"block\">This is a test description for the moduleA module with a Search "
|
||||
+ "phrase <a id=\"searchphrase\" class=\"searchTagResult\">search phrase</a>.</div>");
|
||||
checkOutput("moduleB-summary.html", found,
|
||||
"<section role=\"region\">\n"
|
||||
@ -755,7 +755,8 @@ public class TestModules extends JavadocTester {
|
||||
+ "<td class=\"colFirst\">transitive</td>\n"
|
||||
+ "<th class=\"colSecond\" scope=\"row\"><a href=\"moduleA-summary.html\">moduleA</a></th>\n"
|
||||
+ "<td class=\"colLast\">\n"
|
||||
+ "<div class=\"block\">This is a test description for the moduleA module.</div>\n"
|
||||
+ "<div class=\"block\">This is a test description for the moduleA module with a Search "
|
||||
+ "phrase <a id=\"searchphrase\" class=\"searchTagResult\">search phrase</a>.</div>\n"
|
||||
+ "</td>\n"
|
||||
+ "</tr>\n"
|
||||
+ "<tr class=\"rowColor\">\n"
|
||||
@ -839,7 +840,8 @@ public class TestModules extends JavadocTester {
|
||||
"<dl>\n"
|
||||
+ "<dt><a href=\"moduleA-summary.html\">moduleA</a> - module moduleA</dt>\n"
|
||||
+ "<dd>\n"
|
||||
+ "<div class=\"block\">This is a test description for the moduleA module.</div>\n"
|
||||
+ "<div class=\"block\">This is a test description for the moduleA module with a Search "
|
||||
+ "phrase <a id=\"searchphrase\" class=\"searchTagResult\">search phrase</a>.</div>\n"
|
||||
+ "</dd>\n"
|
||||
+ "<dt><a href=\"moduleB-summary.html\">moduleB</a> - module moduleB</dt>\n"
|
||||
+ "<dd>\n"
|
||||
@ -854,13 +856,21 @@ public class TestModules extends JavadocTester {
|
||||
+ "search_word</a></span> - Search tag in moduleB</dt>\n"
|
||||
+ "<dd> </dd>\n"
|
||||
+ "</dl>");
|
||||
checkOutput("index-all.html", false,
|
||||
"<dt><span class=\"searchTagLink\"><a href=\"moduleA-summary.html#searchphrase\">"
|
||||
+ "search phrase</a></span> - Search tag in moduleA</dt>\n"
|
||||
+ "<dd>with description</dd>\n"
|
||||
+ "<dt><span class=\"searchTagLink\"><a href=\"moduleA-summary.html#searchphrase\">"
|
||||
+ "search phrase</a></span> - Search tag in moduleA</dt>\n"
|
||||
+ "<dd>with description</dd>");
|
||||
}
|
||||
|
||||
void checkModuleModeCommon() {
|
||||
checkOutput("overview-summary.html", true,
|
||||
"<th class=\"colFirst\" scope=\"row\"><a href=\"moduleA-summary.html\">moduleA</a></th>\n"
|
||||
+ "<td class=\"colLast\">\n"
|
||||
+ "<div class=\"block\">This is a test description for the moduleA module.</div>\n"
|
||||
+ "<div class=\"block\">This is a test description for the moduleA module with a Search "
|
||||
+ "phrase <a id=\"searchphrase\" class=\"searchTagResult\">search phrase</a>.</div>\n"
|
||||
+ "</td>",
|
||||
"<th class=\"colFirst\" scope=\"row\"><a href=\"moduleB-summary.html\">moduleB</a></th>\n"
|
||||
+ "<td class=\"colLast\">\n"
|
||||
@ -868,7 +878,7 @@ public class TestModules extends JavadocTester {
|
||||
+ "</td>",
|
||||
"<th class=\"colFirst\" scope=\"row\"><a href=\"moduletags-summary.html\">moduletags</a></th>\n"
|
||||
+ "<td class=\"colLast\">\n"
|
||||
+ "<div class=\"block\">This is a test description for the moduleA module.<br>\n"
|
||||
+ "<div class=\"block\">This is a test description for the moduletags module.<br>\n"
|
||||
+ " Type Link: <a href=\"testpkgmdltags/TestClassInModuleTags.html\" title=\"class in testpkgmdltags\"><code>TestClassInModuleTags</code></a>.<br>\n"
|
||||
+ " Member Link: <a href=\"testpkgmdltags/TestClassInModuleTags.html#testMethod-java.lang.String-\"><code>testMethod(String)</code></a>.<br>\n"
|
||||
+ " Package Link: <a href=\"testpkgmdltags/package-summary.html\"><code>testpkgmdltags</code></a>.<br></div>\n"
|
||||
@ -896,7 +906,8 @@ public class TestModules extends JavadocTester {
|
||||
"<td class=\"colFirst\">transitive static</td>\n"
|
||||
+ "<th class=\"colSecond\" scope=\"row\"><a href=\"moduleA-summary.html\">moduleA</a></th>\n"
|
||||
+ "<td class=\"colLast\">\n"
|
||||
+ "<div class=\"block\">This is a test description for the moduleA module.</div>\n"
|
||||
+ "<div class=\"block\">This is a test description for the moduleA module with a Search "
|
||||
+ "phrase <a id=\"searchphrase\" class=\"searchTagResult\">search phrase</a>.</div>\n"
|
||||
+ "</td>",
|
||||
"<table class=\"requiresSummary\" summary=\"Requires table, listing modules, and an explanation\">\n"
|
||||
+ "<caption><span>Requires</span><span class=\"tabEnd\"> </span></caption>\n"
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 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
|
||||
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a test description for the moduleA module. Search phrase {@index "search phrase" with description}.
|
||||
* This is a test description for the moduleA module with a Search phrase {@index "search phrase" with description}.
|
||||
*
|
||||
* @deprecated This module is deprecated.
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 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
|
||||
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a test description for the moduleA module.<br>
|
||||
* This is a test description for the moduletags module.<br>
|
||||
* Type Link: {@link testpkgmdltags.TestClassInModuleTags}.<br>
|
||||
* Member Link: {@link testpkgmdltags.TestClassInModuleTags#testMethod(String)}.<br>
|
||||
* Package Link: {@link testpkgmdltags}.<br>
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8141492 8071982 8141636 8147890 8166175 8168965 8176794 8175218 8147881
|
||||
* @bug 8141492 8071982 8141636 8147890 8166175 8168965 8176794 8175218 8147881 8181622
|
||||
* @summary Test the search feature of javadoc.
|
||||
* @author bpatel
|
||||
* @library ../lib
|
||||
@ -65,6 +65,7 @@ public class TestSearch extends JavadocTester {
|
||||
checkInvalidUsageIndexTag();
|
||||
checkSearchOutput(true);
|
||||
checkSingleIndex(true);
|
||||
checkSingleIndexSearchTagDuplication();
|
||||
checkJqueryAndImageFiles(true);
|
||||
checkSearchJS();
|
||||
checkFiles(true,
|
||||
@ -86,6 +87,7 @@ public class TestSearch extends JavadocTester {
|
||||
checkDocLintErrors();
|
||||
checkSearchOutput(true);
|
||||
checkSingleIndex(true);
|
||||
checkSingleIndexSearchTagDuplication();
|
||||
checkJqueryAndImageFiles(true);
|
||||
checkSearchJS();
|
||||
checkFiles(true,
|
||||
@ -127,6 +129,7 @@ public class TestSearch extends JavadocTester {
|
||||
checkExit(Exit.OK);
|
||||
checkSearchOutput(true);
|
||||
checkSingleIndex(true);
|
||||
checkSingleIndexSearchTagDuplication();
|
||||
checkJqueryAndImageFiles(true);
|
||||
checkSearchJS();
|
||||
checkFiles(true,
|
||||
@ -210,6 +213,7 @@ public class TestSearch extends JavadocTester {
|
||||
checkInvalidUsageIndexTag();
|
||||
checkSearchOutput(true);
|
||||
checkSplitIndex();
|
||||
checkSplitIndexSearchTagDuplication();
|
||||
checkJqueryAndImageFiles(true);
|
||||
checkSearchJS();
|
||||
checkFiles(true,
|
||||
@ -498,4 +502,34 @@ public class TestSearch extends JavadocTester {
|
||||
+ " }\n"
|
||||
+ " });");
|
||||
}
|
||||
|
||||
void checkSingleIndexSearchTagDuplication() {
|
||||
// Test for search tags duplication in index file.
|
||||
checkOutput("index-all.html", true,
|
||||
"<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestError.html#SearchTagDeprecatedMethod\">"
|
||||
+ "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError</dt>\n"
|
||||
+ "<dd>with description</dd>");
|
||||
checkOutput("index-all.html", false,
|
||||
"<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestError.html#SearchTagDeprecatedMethod\">"
|
||||
+ "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError</dt>\n"
|
||||
+ "<dd>with description</dd>\n"
|
||||
+ "<dt><span class=\"searchTagLink\"><a href=\"pkg2/TestError.html#SearchTagDeprecatedMethod\">"
|
||||
+ "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError</dt>\n"
|
||||
+ "<dd>with description</dd>");
|
||||
}
|
||||
|
||||
void checkSplitIndexSearchTagDuplication() {
|
||||
// Test for search tags duplication in index file.
|
||||
checkOutput("index-files/index-13.html", true,
|
||||
"<dt><span class=\"searchTagLink\"><a href=\"../pkg2/TestError.html#SearchTagDeprecatedMethod\">"
|
||||
+ "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError</dt>\n"
|
||||
+ "<dd>with description</dd>");
|
||||
checkOutput("index-files/index-13.html", false,
|
||||
"<dt><span class=\"searchTagLink\"><a href=\"../pkg2/TestError.html#SearchTagDeprecatedMethod\">"
|
||||
+ "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError</dt>\n"
|
||||
+ "<dd>with description</dd>\n"
|
||||
+ "<dt><span class=\"searchTagLink\"><a href=\"../pkg2/TestError.html#SearchTagDeprecatedMethod\">"
|
||||
+ "SearchTagDeprecatedMethod</a></span> - Search tag in pkg2.TestError</dt>\n"
|
||||
+ "<dd>with description</dd>");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user