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