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