author | jjg |
Thu, 21 Feb 2019 14:03:57 -0800 | |
changeset 53879 | e7cb0348fa1c |
parent 52695 | 99eb43bc3595 |
child 53883 | f41793b5b83f |
permissions | -rw-r--r-- |
10 | 1 |
/* |
53879 | 2 |
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.formats.html; |
10 | 27 |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
28 |
import java.io.*; |
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1789
diff
changeset
|
29 |
import java.util.*; |
33920 | 30 |
import java.util.zip.*; |
10 | 31 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
32 |
import javax.lang.model.element.Element; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
33 |
import javax.lang.model.element.ExecutableElement; |
40511 | 34 |
import javax.lang.model.element.ModuleElement; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
35 |
import javax.lang.model.element.PackageElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
36 |
import javax.lang.model.element.TypeElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
37 |
import javax.lang.model.util.SimpleElementVisitor9; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
38 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
39 |
import com.sun.source.doctree.DocTree; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
40 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
41 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
42 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; |
49551
0d4786e42471
8196200: Implement a navigation builder in javadoc
bpatel
parents:
49427
diff
changeset
|
43 |
import jdk.javadoc.internal.doclets.formats.html.markup.Navigation; |
0d4786e42471
8196200: Implement a navigation builder in javadoc
bpatel
parents:
49427
diff
changeset
|
44 |
import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
45 |
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
46 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
47 |
import jdk.javadoc.internal.doclets.toolkit.util.DocFile; |
40587 | 48 |
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
49 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
50 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
51 |
import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder; |
10 | 52 |
|
53 |
/** |
|
54 |
* Generate Index for all the Member Names with Indexing in |
|
55 |
* Unicode Order. This class is a base class for {@link SingleIndexWriter} and |
|
56 |
* {@link SplitIndexWriter}. It uses the functionality from |
|
57 |
* {@link HtmlDocletWriter} to generate the Index Contents. |
|
58 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
59 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
60 |
* If you write code that depends on this, you do so at your own risk. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
61 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
62 |
* deletion without notice.</b> |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
63 |
* |
10 | 64 |
* @see IndexBuilder |
65 |
* @author Atul M Dambalkar |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
66 |
* @author Bhavesh Patel (Modified) |
10 | 67 |
*/ |
68 |
public class AbstractIndexWriter extends HtmlDocletWriter { |
|
69 |
||
70 |
/** |
|
71 |
* The index of all the members with unicode character. |
|
72 |
*/ |
|
73 |
protected IndexBuilder indexbuilder; |
|
74 |
||
49551
0d4786e42471
8196200: Implement a navigation builder in javadoc
bpatel
parents:
49427
diff
changeset
|
75 |
protected Navigation navBar; |
0d4786e42471
8196200: Implement a navigation builder in javadoc
bpatel
parents:
49427
diff
changeset
|
76 |
|
10 | 77 |
/** |
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
78 |
* This constructor will be used by {@link SplitIndexWriter}. Initializes |
10 | 79 |
* path to this file and relative path from this file. |
80 |
* |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
81 |
* @param configuration The current configuration |
10 | 82 |
* @param path Path to the file which is getting generated. |
83 |
* @param indexbuilder Unicode based Index from {@link IndexBuilder} |
|
84 |
*/ |
|
45417 | 85 |
protected AbstractIndexWriter(HtmlConfiguration configuration, |
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
86 |
DocPath path, |
40303 | 87 |
IndexBuilder indexbuilder) { |
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
88 |
super(configuration, path); |
10 | 89 |
this.indexbuilder = indexbuilder; |
49551
0d4786e42471
8196200: Implement a navigation builder in javadoc
bpatel
parents:
49427
diff
changeset
|
90 |
this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.INDEX, path); |
10 | 91 |
} |
92 |
||
93 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
94 |
* Add the member information for the unicode character along with the |
10 | 95 |
* list of the members. |
96 |
* |
|
33920 | 97 |
* @param uc Unicode for which member list information to be generated |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
98 |
* @param memberlist List of members for the unicode character |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
99 |
* @param contentTree the content tree to which the information will be added |
10 | 100 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
101 |
protected void addContents(Character uc, Collection<? extends Element> memberlist, |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
102 |
Content contentTree) { |
33920 | 103 |
addHeading(uc, contentTree); |
104 |
// Display the list only if there are elements to be displayed. |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
105 |
if (!memberlist.isEmpty()) { |
33920 | 106 |
Content dl = new HtmlTree(HtmlTag.DL); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
107 |
for (Element element : memberlist) { |
33920 | 108 |
addDescription(dl, element); |
109 |
} |
|
110 |
contentTree.addContent(dl); |
|
111 |
} |
|
112 |
} |
|
113 |
||
114 |
protected void addSearchContents(Character uc, List<SearchIndexItem> searchList, |
|
115 |
Content contentTree) { |
|
116 |
addHeading(uc, contentTree); |
|
117 |
// Display the list only if there are elements to be displayed. |
|
118 |
if (!searchList.isEmpty()) { |
|
119 |
Content dl = new HtmlTree(HtmlTag.DL); |
|
120 |
for (SearchIndexItem sii : searchList) { |
|
121 |
addDescription(sii, dl); |
|
122 |
} |
|
123 |
contentTree.addContent(dl); |
|
124 |
} |
|
125 |
} |
|
126 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
127 |
protected void addContents(Character uc, List<? extends Element> memberlist, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
128 |
List<SearchIndexItem> searchList, Content contentTree) { |
33920 | 129 |
addHeading(uc, contentTree); |
130 |
int memberListSize = memberlist.size(); |
|
131 |
int searchListSize = searchList.size(); |
|
132 |
int i = 0; |
|
133 |
int j = 0; |
|
134 |
Content dl = new HtmlTree(HtmlTag.DL); |
|
135 |
while (i < memberListSize && j < searchListSize) { |
|
45771
e447c20c3ff9
8182736: javadoc generates bad names and broken module graph links
jjg
parents:
43370
diff
changeset
|
136 |
Element elem = memberlist.get(i); |
e447c20c3ff9
8182736: javadoc generates bad names and broken module graph links
jjg
parents:
43370
diff
changeset
|
137 |
String name = (utils.isModule(elem)) |
e447c20c3ff9
8182736: javadoc generates bad names and broken module graph links
jjg
parents:
43370
diff
changeset
|
138 |
? utils.getFullyQualifiedName(elem) : utils.getSimpleName(elem); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
139 |
if (name.compareTo(searchList.get(j).getLabel()) < 0) { |
33920 | 140 |
addDescription(dl, memberlist.get(i)); |
141 |
i++; |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
142 |
} else if (name.compareTo(searchList.get(j).getLabel()) > 0) { |
33920 | 143 |
addDescription(searchList.get(j), dl); |
144 |
j++; |
|
145 |
} else { |
|
146 |
addDescription(dl, memberlist.get(i)); |
|
147 |
addDescription(searchList.get(j), dl); |
|
148 |
j++; |
|
149 |
i++; |
|
150 |
} |
|
151 |
} |
|
152 |
if (i >= memberListSize) { |
|
153 |
while (j < searchListSize) { |
|
154 |
addDescription(searchList.get(j), dl); |
|
155 |
j++; |
|
156 |
} |
|
157 |
} |
|
158 |
if (j >= searchListSize) { |
|
159 |
while (i < memberListSize) { |
|
160 |
addDescription(dl, memberlist.get(i)); |
|
161 |
i++; |
|
162 |
} |
|
163 |
} |
|
164 |
contentTree.addContent(dl); |
|
165 |
} |
|
166 |
||
167 |
protected void addHeading(Character uc, Content contentTree) { |
|
21008
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
168 |
String unicode = uc.toString(); |
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
169 |
contentTree.addContent(getMarkerAnchorForIndex(unicode)); |
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
170 |
Content headContent = new StringContent(unicode); |
53879 | 171 |
Content heading = HtmlTree.HEADING(Headings.CONTENT_HEADING, false, |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
172 |
HtmlStyle.title, headContent); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
173 |
contentTree.addContent(heading); |
33920 | 174 |
} |
175 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
176 |
protected void addDescription(Content dl, Element element) { |
33920 | 177 |
SearchIndexItem si = new SearchIndexItem(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
178 |
new SimpleElementVisitor9<Void, Void>() { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
179 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40587
diff
changeset
|
180 |
@Override |
40511 | 181 |
public Void visitModule(ModuleElement e, Void p) { |
182 |
if (configuration.showModules) { |
|
183 |
addDescription(e, dl, si); |
|
184 |
configuration.moduleSearchIndex.add(si); |
|
185 |
} |
|
186 |
return null; |
|
187 |
} |
|
188 |
||
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40587
diff
changeset
|
189 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
190 |
public Void visitPackage(PackageElement e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
191 |
addDescription(e, dl, si); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
192 |
configuration.packageSearchIndex.add(si); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
193 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
194 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
195 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40587
diff
changeset
|
196 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
197 |
public Void visitType(TypeElement e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
198 |
addDescription(e, dl, si); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
199 |
configuration.typeSearchIndex.add(si); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
200 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
201 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
202 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40587
diff
changeset
|
203 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
204 |
protected Void defaultAction(Element e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
205 |
addDescription(e, dl, si); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
206 |
configuration.memberSearchIndex.add(si); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
207 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
208 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
209 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
210 |
}.visit(element); |
10 | 211 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
212 |
|
10 | 213 |
/** |
40511 | 214 |
* Add one line summary comment for the module. |
215 |
* |
|
216 |
* @param mdle the module to be documented |
|
217 |
* @param dlTree the content tree to which the description will be added |
|
47850 | 218 |
* @param si the search index item |
40511 | 219 |
*/ |
220 |
protected void addDescription(ModuleElement mdle, Content dlTree, SearchIndexItem si) { |
|
45771
e447c20c3ff9
8182736: javadoc generates bad names and broken module graph links
jjg
parents:
43370
diff
changeset
|
221 |
String moduleName = utils.getFullyQualifiedName(mdle); |
40511 | 222 |
Content link = getModuleLink(mdle, new StringContent(moduleName)); |
223 |
si.setLabel(moduleName); |
|
52695
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
52644
diff
changeset
|
224 |
si.setCategory(SearchIndexItem.Category.MODULES); |
40511 | 225 |
Content dt = HtmlTree.DT(link); |
226 |
dt.addContent(" - "); |
|
227 |
dt.addContent(contents.module_); |
|
228 |
dt.addContent(" " + moduleName); |
|
229 |
dlTree.addContent(dt); |
|
230 |
Content dd = new HtmlTree(HtmlTag.DD); |
|
231 |
addSummaryComment(mdle, dd); |
|
232 |
dlTree.addContent(dd); |
|
233 |
} |
|
234 |
||
235 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
236 |
* Add one line summary comment for the package. |
10 | 237 |
* |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
238 |
* @param pkg the package to be documented |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
239 |
* @param dlTree the content tree to which the description will be added |
40587 | 240 |
* @param si the search index item to be updated |
10 | 241 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
242 |
protected void addDescription(PackageElement pkg, Content dlTree, SearchIndexItem si) { |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22159
diff
changeset
|
243 |
Content link = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg))); |
40511 | 244 |
if (configuration.showModules) { |
45771
e447c20c3ff9
8182736: javadoc generates bad names and broken module graph links
jjg
parents:
43370
diff
changeset
|
245 |
si.setContainingModule(utils.getFullyQualifiedName(utils.containingModule(pkg))); |
40511 | 246 |
} |
33920 | 247 |
si.setLabel(utils.getPackageName(pkg)); |
52695
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
52644
diff
changeset
|
248 |
si.setCategory(SearchIndexItem.Category.PACKAGES); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
249 |
Content dt = HtmlTree.DT(link); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
250 |
dt.addContent(" - "); |
40303 | 251 |
dt.addContent(contents.package_); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
252 |
dt.addContent(" " + utils.getPackageName(pkg)); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
253 |
dlTree.addContent(dt); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
254 |
Content dd = new HtmlTree(HtmlTag.DD); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
255 |
addSummaryComment(pkg, dd); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
256 |
dlTree.addContent(dd); |
10 | 257 |
} |
258 |
||
259 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
260 |
* Add one line summary comment for the class. |
10 | 261 |
* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
262 |
* @param typeElement the class being documented |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
263 |
* @param dlTree the content tree to which the description will be added |
40587 | 264 |
* @param si the search index item to be updated |
10 | 265 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
266 |
protected void addDescription(TypeElement typeElement, Content dlTree, SearchIndexItem si) { |
17559
87c28ee29329
8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents:
17558
diff
changeset
|
267 |
Content link = getLink(new LinkInfoImpl(configuration, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
268 |
LinkInfoImpl.Kind.INDEX, typeElement).strong(true)); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
269 |
si.setContainingPackage(utils.getPackageName(utils.containingPackage(typeElement))); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
270 |
si.setLabel(utils.getSimpleName(typeElement)); |
52695
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
52644
diff
changeset
|
271 |
si.setCategory(SearchIndexItem.Category.TYPES); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
272 |
Content dt = HtmlTree.DT(link); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
273 |
dt.addContent(" - "); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
274 |
addClassInfo(typeElement, dt); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
275 |
dlTree.addContent(dt); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
276 |
Content dd = new HtmlTree(HtmlTag.DD); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
277 |
addComment(typeElement, dd); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
278 |
dlTree.addContent(dd); |
10 | 279 |
} |
280 |
||
281 |
/** |
|
17558
eee4ccf66cfd
8010440: Replace int constants in LinkInfoImpl with enum
jjg
parents:
14542
diff
changeset
|
282 |
* Add the classkind (class, interface, exception), error of the class |
10 | 283 |
* passed. |
284 |
* |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
285 |
* @param te the class being documented |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
286 |
* @param contentTree the content tree to which the class info will be added |
10 | 287 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
288 |
protected void addClassInfo(TypeElement te, Content contentTree) { |
40303 | 289 |
contentTree.addContent(contents.getContent("doclet.in", |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
290 |
utils.getTypeElementName(te, false), |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
291 |
getPackageLink(utils.containingPackage(te), |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
292 |
utils.getPackageName(utils.containingPackage(te))) |
17563
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
17561
diff
changeset
|
293 |
)); |
10 | 294 |
} |
295 |
||
296 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
297 |
* Add description for Class, Field, Method or Constructor. |
10 | 298 |
* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
299 |
* @param member the member of the Class Kind |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
300 |
* @param dlTree the content tree to which the description will be added |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
301 |
* @param si search index item |
10 | 302 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
303 |
protected void addDescription(Element member, Content dlTree, SearchIndexItem si) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
304 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
305 |
si.setContainingPackage(utils.getPackageName(utils.containingPackage(member))); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
306 |
si.setContainingClass(utils.getSimpleName(utils.getEnclosingTypeElement(member))); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
307 |
String name = utils.getSimpleName(member); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
308 |
if (utils.isExecutableElement(member)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
309 |
ExecutableElement ee = (ExecutableElement)member; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
310 |
name = name + utils.flatSignature(ee); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
311 |
si.setLabel(name); |
49427
d2fd2581325b
8199278: Javadoc search results does not link to anchors on a page
bpatel
parents:
47850
diff
changeset
|
312 |
String url = HtmlTree.encodeURL(links.getName(getAnchor(ee))); |
d2fd2581325b
8199278: Javadoc search results does not link to anchors on a page
bpatel
parents:
47850
diff
changeset
|
313 |
if (!name.equals(url)) { |
d2fd2581325b
8199278: Javadoc search results does not link to anchors on a page
bpatel
parents:
47850
diff
changeset
|
314 |
si.setUrl(url); |
33920 | 315 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
316 |
} else { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
317 |
si.setLabel(name); |
33920 | 318 |
} |
52695
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
52644
diff
changeset
|
319 |
si.setCategory(SearchIndexItem.Category.MEMBERS); |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21008
diff
changeset
|
320 |
Content span = HtmlTree.SPAN(HtmlStyle.memberNameLink, |
17558
eee4ccf66cfd
8010440: Replace int constants in LinkInfoImpl with enum
jjg
parents:
14542
diff
changeset
|
321 |
getDocLink(LinkInfoImpl.Kind.INDEX, member, name)); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
322 |
Content dt = HtmlTree.DT(span); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
323 |
dt.addContent(" - "); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
324 |
addMemberDesc(member, dt); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
325 |
dlTree.addContent(dt); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
326 |
Content dd = new HtmlTree(HtmlTag.DD); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
327 |
addComment(member, dd); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
328 |
dlTree.addContent(dd); |
10 | 329 |
} |
330 |
||
33920 | 331 |
protected void addDescription(SearchIndexItem sii, Content dlTree) { |
40587 | 332 |
String siiPath = pathToRoot.isEmpty() ? "" : pathToRoot.getPath() + "/"; |
333 |
siiPath += sii.getUrl(); |
|
334 |
HtmlTree labelLink = HtmlTree.A(siiPath, new StringContent(sii.getLabel())); |
|
33920 | 335 |
Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.searchTagLink, labelLink)); |
336 |
dt.addContent(" - "); |
|
40303 | 337 |
dt.addContent(contents.getContent("doclet.Search_tag_in", sii.getHolder())); |
33920 | 338 |
dlTree.addContent(dt); |
339 |
Content dd = new HtmlTree(HtmlTag.DD); |
|
340 |
if (sii.getDescription().isEmpty()) { |
|
40303 | 341 |
dd.addContent(Contents.SPACE); |
33920 | 342 |
} else { |
343 |
dd.addContent(sii.getDescription()); |
|
344 |
} |
|
345 |
dlTree.addContent(dd); |
|
346 |
} |
|
347 |
||
10 | 348 |
/** |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
349 |
* Add comment for each element in the index. If the element is deprecated |
10 | 350 |
* and it has a @deprecated tag, use that comment. Else if the containing |
351 |
* class for this element is deprecated, then add the word "Deprecated." at |
|
352 |
* the start and then print the normal comment. |
|
353 |
* |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
354 |
* @param element Index element |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
355 |
* @param contentTree the content tree to which the comment will be added |
10 | 356 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
357 |
protected void addComment(Element element, Content contentTree) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
358 |
List<? extends DocTree> tags; |
42816
3638773ff1b0
8162674: change javadoc output text and style emitted by for-removal deprecations
bpatel
parents:
40606
diff
changeset
|
359 |
Content span = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, getDeprecatedPhrase(element)); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
360 |
HtmlTree div = new HtmlTree(HtmlTag.DIV); |
47846 | 361 |
div.setStyle(HtmlStyle.deprecationBlock); |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22159
diff
changeset
|
362 |
if (utils.isDeprecated(element)) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
363 |
div.addContent(span); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
364 |
tags = utils.getBlockTags(element, DocTree.Kind.DEPRECATED); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
365 |
if (!tags.isEmpty()) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
366 |
addInlineDeprecatedComment(element, tags.get(0), div); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
367 |
contentTree.addContent(div); |
10 | 368 |
} else { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
369 |
TypeElement encl = utils.getEnclosingTypeElement(element); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
370 |
while (encl != null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
371 |
if (utils.isDeprecated(encl)) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
372 |
div.addContent(span); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
373 |
contentTree.addContent(div); |
10 | 374 |
break; |
375 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
376 |
encl = utils.getEnclosingTypeElement(encl); |
10 | 377 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
378 |
addSummaryComment(element, contentTree); |
10 | 379 |
} |
380 |
} |
|
381 |
||
382 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
383 |
* Add description about the Static Variable/Method/Constructor for a |
10 | 384 |
* member. |
385 |
* |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
386 |
* @param member MemberDoc for the member within the Class Kind |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
387 |
* @param contentTree the content tree to which the member description will be added |
10 | 388 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
389 |
protected void addMemberDesc(Element member, Content contentTree) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
390 |
TypeElement containing = utils.getEnclosingTypeElement(member); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
391 |
String classdesc = utils.getTypeElementName(containing, true) + " "; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
392 |
if (utils.isField(member)) { |
40303 | 393 |
Content resource = contents.getContent(utils.isStatic(member) |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
394 |
? "doclet.Static_variable_in" |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
395 |
: "doclet.Variable_in", classdesc); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
396 |
contentTree.addContent(resource); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
397 |
} else if (utils.isConstructor(member)) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
398 |
contentTree.addContent( |
40303 | 399 |
contents.getContent("doclet.Constructor_for", classdesc)); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
400 |
} else if (utils.isMethod(member)) { |
40303 | 401 |
Content resource = contents.getContent(utils.isStatic(member) |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
402 |
? "doclet.Static_method_in" |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
403 |
: "doclet.Method_in", classdesc); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
404 |
contentTree.addContent(resource); |
10 | 405 |
} |
17558
eee4ccf66cfd
8010440: Replace int constants in LinkInfoImpl with enum
jjg
parents:
14542
diff
changeset
|
406 |
addPreQualifiedClassLink(LinkInfoImpl.Kind.INDEX, containing, |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
407 |
false, contentTree); |
10 | 408 |
} |
21008
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
409 |
|
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
410 |
/** |
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
411 |
* Get the marker anchor which will be added to the index documentation tree. |
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
412 |
* |
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
413 |
* @param anchorNameForIndex the anchor name attribute for index page |
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
414 |
* @return a content tree for the marker anchor |
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
415 |
*/ |
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
416 |
public Content getMarkerAnchorForIndex(String anchorNameForIndex) { |
47850 | 417 |
return links.createAnchor(getNameForIndex(anchorNameForIndex), null); |
21008
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
418 |
} |
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
419 |
|
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
420 |
/** |
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
421 |
* Generate a valid HTML name for member index page. |
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
422 |
* |
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
423 |
* @param unicode the string that needs to be converted to valid HTML name. |
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
424 |
* @return a valid HTML name string. |
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
425 |
*/ |
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
426 |
public String getNameForIndex(String unicode) { |
47850 | 427 |
return "I:" + links.getName(unicode); |
21008
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
17563
diff
changeset
|
428 |
} |
33920 | 429 |
|
40587 | 430 |
/** |
431 |
* @throws DocFileIOException if there is a problem creating any of the search index files |
|
432 |
*/ |
|
433 |
protected void createSearchIndexFiles() throws DocFileIOException { |
|
40511 | 434 |
if (configuration.showModules) { |
435 |
createSearchIndexFile(DocPaths.MODULE_SEARCH_INDEX_JSON, DocPaths.MODULE_SEARCH_INDEX_ZIP, |
|
43370
5969237f927c
8166175: javadoc search doesn't work on local doc bundles
bpatel
parents:
42816
diff
changeset
|
436 |
DocPaths.MODULE_SEARCH_INDEX_JS, configuration.moduleSearchIndex, "moduleSearchIndex"); |
40511 | 437 |
} |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
438 |
if (!configuration.packages.isEmpty()) { |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
439 |
SearchIndexItem si = new SearchIndexItem(); |
52695
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
52644
diff
changeset
|
440 |
si.setCategory(SearchIndexItem.Category.PACKAGES); |
52644
43efb4ca6d6c
8214139: Remove wrapper methods from {Base,Html}Configuration
jjg
parents:
50167
diff
changeset
|
441 |
si.setLabel(resources.getText("doclet.All_Packages")); |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
442 |
si.setUrl(DocPaths.ALLPACKAGES_INDEX.getPath()); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
443 |
configuration.packageSearchIndex.add(si); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
444 |
} |
33920 | 445 |
createSearchIndexFile(DocPaths.PACKAGE_SEARCH_INDEX_JSON, DocPaths.PACKAGE_SEARCH_INDEX_ZIP, |
43370
5969237f927c
8166175: javadoc search doesn't work on local doc bundles
bpatel
parents:
42816
diff
changeset
|
446 |
DocPaths.PACKAGE_SEARCH_INDEX_JS, configuration.packageSearchIndex, "packageSearchIndex"); |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
447 |
SearchIndexItem si = new SearchIndexItem(); |
52695
99eb43bc3595
8213716: javadoc search not working with Japanese and Chinese locales
hannesw
parents:
52644
diff
changeset
|
448 |
si.setCategory(SearchIndexItem.Category.TYPES); |
52644
43efb4ca6d6c
8214139: Remove wrapper methods from {Base,Html}Configuration
jjg
parents:
50167
diff
changeset
|
449 |
si.setLabel(resources.getText("doclet.All_Classes")); |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
450 |
si.setUrl(DocPaths.ALLCLASSES_INDEX.getPath()); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
451 |
configuration.typeSearchIndex.add(si); |
33920 | 452 |
createSearchIndexFile(DocPaths.TYPE_SEARCH_INDEX_JSON, DocPaths.TYPE_SEARCH_INDEX_ZIP, |
43370
5969237f927c
8166175: javadoc search doesn't work on local doc bundles
bpatel
parents:
42816
diff
changeset
|
453 |
DocPaths.TYPE_SEARCH_INDEX_JS, configuration.typeSearchIndex, "typeSearchIndex"); |
33920 | 454 |
createSearchIndexFile(DocPaths.MEMBER_SEARCH_INDEX_JSON, DocPaths.MEMBER_SEARCH_INDEX_ZIP, |
43370
5969237f927c
8166175: javadoc search doesn't work on local doc bundles
bpatel
parents:
42816
diff
changeset
|
455 |
DocPaths.MEMBER_SEARCH_INDEX_JS, configuration.memberSearchIndex, "memberSearchIndex"); |
33920 | 456 |
createSearchIndexFile(DocPaths.TAG_SEARCH_INDEX_JSON, DocPaths.TAG_SEARCH_INDEX_ZIP, |
43370
5969237f927c
8166175: javadoc search doesn't work on local doc bundles
bpatel
parents:
42816
diff
changeset
|
457 |
DocPaths.TAG_SEARCH_INDEX_JS, configuration.tagSearchIndex, "tagSearchIndex"); |
33920 | 458 |
} |
459 |
||
40587 | 460 |
/** |
47850 | 461 |
* Creates a search index file. |
462 |
* |
|
463 |
* @param searchIndexFile the file to be generated |
|
464 |
* @param searchIndexZip the zip file to be generated |
|
465 |
* @param searchIndexJS the file for the JavaScript to be generated |
|
466 |
* @param searchIndex the search index items |
|
467 |
* @param varName the variable name to write in the JavaScript file |
|
40587 | 468 |
* @throws DocFileIOException if there is a problem creating the search index file |
469 |
*/ |
|
33920 | 470 |
protected void createSearchIndexFile(DocPath searchIndexFile, DocPath searchIndexZip, |
45913
90f6a96c1603
8181622: new {@index} tag generates multiple index entries
bpatel
parents:
45864
diff
changeset
|
471 |
DocPath searchIndexJS, Collection<SearchIndexItem> searchIndex, String varName) throws DocFileIOException { |
33920 | 472 |
if (!searchIndex.isEmpty()) { |
40587 | 473 |
StringBuilder searchVar = new StringBuilder("["); |
474 |
boolean first = true; |
|
475 |
for (SearchIndexItem item : searchIndex) { |
|
476 |
if (first) { |
|
477 |
searchVar.append(item.toString()); |
|
478 |
first = false; |
|
479 |
} else { |
|
480 |
searchVar.append(",").append(item.toString()); |
|
33920 | 481 |
} |
40587 | 482 |
} |
483 |
searchVar.append("]"); |
|
43370
5969237f927c
8166175: javadoc search doesn't work on local doc bundles
bpatel
parents:
42816
diff
changeset
|
484 |
DocFile jsFile = DocFile.createFileForOutput(configuration, searchIndexJS); |
5969237f927c
8166175: javadoc search doesn't work on local doc bundles
bpatel
parents:
42816
diff
changeset
|
485 |
try (Writer wr = jsFile.openWriter()) { |
5969237f927c
8166175: javadoc search doesn't work on local doc bundles
bpatel
parents:
42816
diff
changeset
|
486 |
wr.write(varName); |
5969237f927c
8166175: javadoc search doesn't work on local doc bundles
bpatel
parents:
42816
diff
changeset
|
487 |
wr.write(" = "); |
5969237f927c
8166175: javadoc search doesn't work on local doc bundles
bpatel
parents:
42816
diff
changeset
|
488 |
wr.write(searchVar.toString()); |
5969237f927c
8166175: javadoc search doesn't work on local doc bundles
bpatel
parents:
42816
diff
changeset
|
489 |
} catch (IOException ie) { |
5969237f927c
8166175: javadoc search doesn't work on local doc bundles
bpatel
parents:
42816
diff
changeset
|
490 |
throw new DocFileIOException(jsFile, DocFileIOException.Mode.WRITE, ie); |
5969237f927c
8166175: javadoc search doesn't work on local doc bundles
bpatel
parents:
42816
diff
changeset
|
491 |
} |
40587 | 492 |
|
493 |
DocFile zipFile = DocFile.createFileForOutput(configuration, searchIndexZip); |
|
494 |
try (OutputStream fos = zipFile.openOutputStream(); |
|
495 |
ZipOutputStream zos = new ZipOutputStream(fos)) { |
|
496 |
try { |
|
497 |
ZipEntry ze = new ZipEntry(searchIndexFile.getPath()); |
|
498 |
zos.putNextEntry(ze); |
|
499 |
zos.write(searchVar.toString().getBytes()); |
|
500 |
} finally { |
|
501 |
zos.closeEntry(); |
|
33920 | 502 |
} |
503 |
} catch (IOException ie) { |
|
40587 | 504 |
throw new DocFileIOException(zipFile, DocFileIOException.Mode.WRITE, ie); |
33920 | 505 |
} |
506 |
} |
|
507 |
} |
|
10 | 508 |
} |