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