author | jjg |
Mon, 09 May 2016 16:52:15 -0700 | |
changeset 37938 | 42baa89d2156 |
parent 36526 | 3b41f1c69604 |
child 38617 | d93a7f64e231 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
36526 | 2 |
* Copyright (c) 1998, 2016, 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 |
||
26 |
package com.sun.tools.doclets.formats.html; |
|
27 |
||
14258 | 28 |
import java.net.*; |
29 |
import java.util.*; |
|
10 | 30 |
|
14544 | 31 |
import javax.tools.JavaFileManager; |
36526 | 32 |
import javax.tools.JavaFileManager.Location; |
33 |
import javax.tools.StandardLocation; |
|
14544 | 34 |
|
10 | 35 |
import com.sun.javadoc.*; |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
36 |
import com.sun.tools.doclets.formats.html.markup.*; |
14258 | 37 |
import com.sun.tools.doclets.internal.toolkit.*; |
38 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
|
15354 | 39 |
import com.sun.tools.doclint.DocLint; |
14544 | 40 |
import com.sun.tools.javac.file.JavacFileManager; |
41 |
import com.sun.tools.javac.util.Context; |
|
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
21888
diff
changeset
|
42 |
import com.sun.tools.javac.util.StringUtils; |
37938
42baa89d2156
8075703: jdk.javadoc module exports com.sun.tools.javadoc package which contains a lot of internal API.
jjg
parents:
36526
diff
changeset
|
43 |
import com.sun.tools.javadoc.main.RootDocImpl; |
10 | 44 |
|
45 |
/** |
|
46 |
* Configure the output based on the command line options. |
|
47 |
* <p> |
|
48 |
* Also determine the length of the command line option. For example, |
|
49 |
* for a option "-header" there will be a string argument associated, then the |
|
50 |
* the length of option "-header" is two. But for option "-nohelp" no argument |
|
51 |
* is needed so it's length is 1. |
|
52 |
* </p> |
|
53 |
* <p> |
|
54 |
* Also do the error checking on the options used. For example it is illegal to |
|
55 |
* use "-helpfile" option when already "-nohelp" option is used. |
|
56 |
* </p> |
|
57 |
* |
|
14368
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14357
diff
changeset
|
58 |
* <p><b>This is NOT part of any supported API. |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14357
diff
changeset
|
59 |
* If you write code that depends on this, you do so at your own risk. |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14357
diff
changeset
|
60 |
* This code and its internal interfaces are subject to change or |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14357
diff
changeset
|
61 |
* deletion without notice.</b> |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14357
diff
changeset
|
62 |
* |
10 | 63 |
* @author Robert Field. |
64 |
* @author Atul Dambalkar. |
|
65 |
* @author Jamie Ho |
|
9608 | 66 |
* @author Bhavesh Patel (Modified) |
10 | 67 |
*/ |
68 |
public class ConfigurationImpl extends Configuration { |
|
69 |
||
70 |
/** |
|
71 |
* The build date. Note: For now, we will use |
|
72 |
* a version number instead of a date. |
|
73 |
*/ |
|
74 |
public static final String BUILD_DATE = System.getProperty("java.version"); |
|
75 |
||
76 |
/** |
|
77 |
* Argument for command line option "-header". |
|
78 |
*/ |
|
79 |
public String header = ""; |
|
80 |
||
81 |
/** |
|
82 |
* Argument for command line option "-packagesheader". |
|
83 |
*/ |
|
84 |
public String packagesheader = ""; |
|
85 |
||
86 |
/** |
|
87 |
* Argument for command line option "-footer". |
|
88 |
*/ |
|
89 |
public String footer = ""; |
|
90 |
||
91 |
/** |
|
92 |
* Argument for command line option "-doctitle". |
|
93 |
*/ |
|
94 |
public String doctitle = ""; |
|
95 |
||
96 |
/** |
|
97 |
* Argument for command line option "-windowtitle". |
|
98 |
*/ |
|
99 |
public String windowtitle = ""; |
|
100 |
||
101 |
/** |
|
102 |
* Argument for command line option "-top". |
|
103 |
*/ |
|
104 |
public String top = ""; |
|
105 |
||
106 |
/** |
|
107 |
* Argument for command line option "-bottom". |
|
108 |
*/ |
|
109 |
public String bottom = ""; |
|
110 |
||
111 |
/** |
|
112 |
* Argument for command line option "-helpfile". |
|
113 |
*/ |
|
114 |
public String helpfile = ""; |
|
115 |
||
116 |
/** |
|
117 |
* Argument for command line option "-stylesheetfile". |
|
118 |
*/ |
|
119 |
public String stylesheetfile = ""; |
|
120 |
||
121 |
/** |
|
9608 | 122 |
* Argument for command line option "-Xdocrootparent". |
123 |
*/ |
|
124 |
public String docrootparent = ""; |
|
125 |
||
126 |
/** |
|
10 | 127 |
* True if command line option "-nohelp" is used. Default value is false. |
128 |
*/ |
|
129 |
public boolean nohelp = false; |
|
130 |
||
131 |
/** |
|
132 |
* True if command line option "-splitindex" is used. Default value is |
|
133 |
* false. |
|
134 |
*/ |
|
135 |
public boolean splitindex = false; |
|
136 |
||
137 |
/** |
|
138 |
* False if command line option "-noindex" is used. Default value is true. |
|
139 |
*/ |
|
140 |
public boolean createindex = true; |
|
141 |
||
142 |
/** |
|
143 |
* True if command line option "-use" is used. Default value is false. |
|
144 |
*/ |
|
145 |
public boolean classuse = false; |
|
146 |
||
147 |
/** |
|
148 |
* False if command line option "-notree" is used. Default value is true. |
|
149 |
*/ |
|
150 |
public boolean createtree = true; |
|
151 |
||
152 |
/** |
|
153 |
* True if command line option "-nodeprecated" is used. Default value is |
|
154 |
* false. |
|
155 |
*/ |
|
156 |
public boolean nodeprecatedlist = false; |
|
157 |
||
158 |
/** |
|
159 |
* True if command line option "-nonavbar" is used. Default value is false. |
|
160 |
*/ |
|
161 |
public boolean nonavbar = false; |
|
162 |
||
163 |
/** |
|
164 |
* True if command line option "-nooverview" is used. Default value is |
|
165 |
* false |
|
166 |
*/ |
|
167 |
private boolean nooverview = false; |
|
168 |
||
169 |
/** |
|
170 |
* True if command line option "-overview" is used. Default value is false. |
|
171 |
*/ |
|
172 |
public boolean overview = false; |
|
173 |
||
174 |
/** |
|
175 |
* This is true if option "-overview" is used or option "-overview" is not |
|
176 |
* used and number of packages is more than one. |
|
177 |
*/ |
|
178 |
public boolean createoverview = false; |
|
179 |
||
180 |
/** |
|
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
181 |
* This is the HTML version of the generated pages. HTML 4.01 is the default output version. |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
182 |
*/ |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
183 |
public HtmlVersion htmlVersion = HtmlVersion.HTML4; |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
184 |
|
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
185 |
/** |
15354 | 186 |
* Collected set of doclint options |
187 |
*/ |
|
22163 | 188 |
public Set<String> doclintOpts = new LinkedHashSet<>(); |
15354 | 189 |
|
190 |
/** |
|
10 | 191 |
* Unique Resource Handler for this package. |
192 |
*/ |
|
193 |
public final MessageRetriever standardmessage; |
|
194 |
||
195 |
/** |
|
196 |
* First file to appear in the right-hand frame in the generated |
|
197 |
* documentation. |
|
198 |
*/ |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14259
diff
changeset
|
199 |
public DocPath topFile = DocPath.empty; |
10 | 200 |
|
201 |
/** |
|
202 |
* The classdoc for the class file getting generated. |
|
203 |
*/ |
|
14542 | 204 |
public ClassDoc currentcd = null; // Set this classdoc in the ClassWriter. |
10 | 205 |
|
33920 | 206 |
protected List<SearchIndexItem> memberSearchIndex = new ArrayList<>(); |
207 |
||
208 |
protected List<SearchIndexItem> packageSearchIndex = new ArrayList<>(); |
|
209 |
||
210 |
protected List<SearchIndexItem> tagSearchIndex = new ArrayList<>(); |
|
211 |
||
212 |
protected List<SearchIndexItem> typeSearchIndex = new ArrayList<>(); |
|
213 |
||
214 |
protected Map<Character,List<SearchIndexItem>> tagSearchIndexMap = new HashMap<>(); |
|
215 |
||
216 |
protected Set<Character> tagSearchIndexKeys; |
|
217 |
||
10 | 218 |
/** |
14259 | 219 |
* Constructor. Initializes resource for the |
220 |
* {@link com.sun.tools.doclets.internal.toolkit.util.MessageRetriever MessageRetriever}. |
|
10 | 221 |
*/ |
14542 | 222 |
public ConfigurationImpl() { |
10 | 223 |
standardmessage = new MessageRetriever(this, |
224 |
"com.sun.tools.doclets.formats.html.resources.standard"); |
|
225 |
} |
|
226 |
||
21888
568c5da9f16b
6726154: javadoc generated with incorrect version in comment
kizune
parents:
21500
diff
changeset
|
227 |
private final String versionRBName = "com.sun.tools.javadoc.resources.version"; |
568c5da9f16b
6726154: javadoc generated with incorrect version in comment
kizune
parents:
21500
diff
changeset
|
228 |
private ResourceBundle versionRB; |
568c5da9f16b
6726154: javadoc generated with incorrect version in comment
kizune
parents:
21500
diff
changeset
|
229 |
|
1475 | 230 |
/** |
10 | 231 |
* Return the build date for the doclet. |
232 |
*/ |
|
14544 | 233 |
@Override |
10 | 234 |
public String getDocletSpecificBuildDate() { |
21888
568c5da9f16b
6726154: javadoc generated with incorrect version in comment
kizune
parents:
21500
diff
changeset
|
235 |
if (versionRB == null) { |
568c5da9f16b
6726154: javadoc generated with incorrect version in comment
kizune
parents:
21500
diff
changeset
|
236 |
try { |
568c5da9f16b
6726154: javadoc generated with incorrect version in comment
kizune
parents:
21500
diff
changeset
|
237 |
versionRB = ResourceBundle.getBundle(versionRBName); |
568c5da9f16b
6726154: javadoc generated with incorrect version in comment
kizune
parents:
21500
diff
changeset
|
238 |
} catch (MissingResourceException e) { |
568c5da9f16b
6726154: javadoc generated with incorrect version in comment
kizune
parents:
21500
diff
changeset
|
239 |
return BUILD_DATE; |
568c5da9f16b
6726154: javadoc generated with incorrect version in comment
kizune
parents:
21500
diff
changeset
|
240 |
} |
568c5da9f16b
6726154: javadoc generated with incorrect version in comment
kizune
parents:
21500
diff
changeset
|
241 |
} |
568c5da9f16b
6726154: javadoc generated with incorrect version in comment
kizune
parents:
21500
diff
changeset
|
242 |
|
568c5da9f16b
6726154: javadoc generated with incorrect version in comment
kizune
parents:
21500
diff
changeset
|
243 |
try { |
568c5da9f16b
6726154: javadoc generated with incorrect version in comment
kizune
parents:
21500
diff
changeset
|
244 |
return versionRB.getString("release"); |
568c5da9f16b
6726154: javadoc generated with incorrect version in comment
kizune
parents:
21500
diff
changeset
|
245 |
} catch (MissingResourceException e) { |
568c5da9f16b
6726154: javadoc generated with incorrect version in comment
kizune
parents:
21500
diff
changeset
|
246 |
return BUILD_DATE; |
568c5da9f16b
6726154: javadoc generated with incorrect version in comment
kizune
parents:
21500
diff
changeset
|
247 |
} |
10 | 248 |
} |
249 |
||
250 |
/** |
|
251 |
* Depending upon the command line options provided by the user, set |
|
252 |
* configure the output generation environment. |
|
253 |
* |
|
254 |
* @param options The array of option names and values. |
|
255 |
*/ |
|
14544 | 256 |
@Override |
10 | 257 |
public void setSpecificDocletOptions(String[][] options) { |
258 |
for (int oi = 0; oi < options.length; ++oi) { |
|
259 |
String[] os = options[oi]; |
|
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
21888
diff
changeset
|
260 |
String opt = StringUtils.toLowerCase(os[0]); |
10 | 261 |
if (opt.equals("-footer")) { |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
262 |
footer = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
263 |
} else if (opt.equals("-header")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
264 |
header = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
265 |
} else if (opt.equals("-packagesheader")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
266 |
packagesheader = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
267 |
} else if (opt.equals("-doctitle")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
268 |
doctitle = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
269 |
} else if (opt.equals("-windowtitle")) { |
23968 | 270 |
windowtitle = os[1].replaceAll("\\<.*?>", ""); |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
271 |
} else if (opt.equals("-top")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
272 |
top = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
273 |
} else if (opt.equals("-bottom")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
274 |
bottom = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
275 |
} else if (opt.equals("-helpfile")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
276 |
helpfile = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
277 |
} else if (opt.equals("-stylesheetfile")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
278 |
stylesheetfile = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
279 |
} else if (opt.equals("-charset")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
280 |
charset = os[1]; |
9608 | 281 |
} else if (opt.equals("-xdocrootparent")) { |
282 |
docrootparent = os[1]; |
|
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
283 |
} else if (opt.equals("-nohelp")) { |
10 | 284 |
nohelp = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
285 |
} else if (opt.equals("-splitindex")) { |
10 | 286 |
splitindex = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
287 |
} else if (opt.equals("-noindex")) { |
10 | 288 |
createindex = false; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
289 |
} else if (opt.equals("-use")) { |
10 | 290 |
classuse = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
291 |
} else if (opt.equals("-notree")) { |
10 | 292 |
createtree = false; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
293 |
} else if (opt.equals("-nodeprecatedlist")) { |
10 | 294 |
nodeprecatedlist = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
295 |
} else if (opt.equals("-nonavbar")) { |
10 | 296 |
nonavbar = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
297 |
} else if (opt.equals("-nooverview")) { |
10 | 298 |
nooverview = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
299 |
} else if (opt.equals("-overview")) { |
10 | 300 |
overview = true; |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
301 |
} else if (opt.equals("-html4")) { |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
302 |
htmlVersion = HtmlVersion.HTML4; |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
303 |
} else if (opt.equals("-html5")) { |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
304 |
htmlVersion = HtmlVersion.HTML5; |
15354 | 305 |
} else if (opt.equals("-xdoclint")) { |
31752 | 306 |
doclintOpts.add(DocLint.XMSGS_OPTION); |
15354 | 307 |
} else if (opt.startsWith("-xdoclint:")) { |
31752 | 308 |
doclintOpts.add(DocLint.XMSGS_CUSTOM_PREFIX + opt.substring(opt.indexOf(":") + 1)); |
309 |
} else if (opt.startsWith("-xdoclint/package:")) { |
|
310 |
doclintOpts.add(DocLint.XCHECK_PACKAGE + opt.substring(opt.indexOf(":") + 1)); |
|
10 | 311 |
} |
312 |
} |
|
313 |
if (root.specifiedClasses().length > 0) { |
|
22163 | 314 |
Map<String,PackageDoc> map = new HashMap<>(); |
10 | 315 |
PackageDoc pd; |
316 |
ClassDoc[] classes = root.classes(); |
|
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
317 |
for (ClassDoc aClass : classes) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
318 |
pd = aClass.containingPackage(); |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
319 |
if (!map.containsKey(pd.name())) { |
10 | 320 |
map.put(pd.name(), pd); |
321 |
} |
|
322 |
} |
|
323 |
} |
|
324 |
setCreateOverview(); |
|
325 |
setTopFile(root); |
|
15354 | 326 |
|
327 |
if (root instanceof RootDocImpl) { |
|
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
328 |
((RootDocImpl) root).initDocLint(doclintOpts, tagletManager.getCustomTagNames(), |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
329 |
StringUtils.toLowerCase(htmlVersion.name())); |
15354 | 330 |
} |
10 | 331 |
} |
332 |
||
333 |
/** |
|
334 |
* Returns the "length" of a given option. If an option takes no |
|
335 |
* arguments, its length is one. If it takes one argument, it's |
|
336 |
* length is two, and so on. This method is called by JavaDoc to |
|
337 |
* parse the options it does not recognize. It then calls |
|
338 |
* {@link #validOptions(String[][], DocErrorReporter)} to |
|
339 |
* validate them. |
|
340 |
* <b>Note:</b><br> |
|
341 |
* The options arrive as case-sensitive strings. For options that |
|
342 |
* are not case-sensitive, use toLowerCase() on the option string |
|
343 |
* before comparing it. |
|
344 |
* |
|
345 |
* @return number of arguments + 1 for a option. Zero return means |
|
346 |
* option not known. Negative value means error occurred. |
|
347 |
*/ |
|
348 |
public int optionLength(String option) { |
|
349 |
int result = -1; |
|
350 |
if ((result = super.optionLength(option)) > 0) { |
|
351 |
return result; |
|
352 |
} |
|
353 |
// otherwise look for the options we have added |
|
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
21888
diff
changeset
|
354 |
option = StringUtils.toLowerCase(option); |
10 | 355 |
if (option.equals("-nodeprecatedlist") || |
356 |
option.equals("-noindex") || |
|
357 |
option.equals("-notree") || |
|
358 |
option.equals("-nohelp") || |
|
359 |
option.equals("-splitindex") || |
|
360 |
option.equals("-serialwarn") || |
|
361 |
option.equals("-use") || |
|
362 |
option.equals("-nonavbar") || |
|
15354 | 363 |
option.equals("-nooverview") || |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
364 |
option.equals("-html4") || |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
365 |
option.equals("-html5") || |
15354 | 366 |
option.equals("-xdoclint") || |
31752 | 367 |
option.startsWith("-xdoclint:") || |
368 |
option.startsWith("-xdoclint/package:")) { |
|
10 | 369 |
return 1; |
370 |
} else if (option.equals("-help")) { |
|
18005 | 371 |
// Uugh: first, this should not be hidden inside optionLength, |
372 |
// and second, we should not be writing directly to stdout. |
|
373 |
// But we have no access to a DocErrorReporter, which would |
|
374 |
// allow use of reporter.printNotice |
|
10 | 375 |
System.out.println(getText("doclet.usage")); |
376 |
return 1; |
|
18005 | 377 |
} else if (option.equals("-x")) { |
378 |
// Uugh: first, this should not be hidden inside optionLength, |
|
379 |
// and second, we should not be writing directly to stdout. |
|
380 |
// But we have no access to a DocErrorReporter, which would |
|
381 |
// allow use of reporter.printNotice |
|
382 |
System.out.println(getText("doclet.X.usage")); |
|
383 |
return 1; |
|
10 | 384 |
} else if (option.equals("-footer") || |
385 |
option.equals("-header") || |
|
386 |
option.equals("-packagesheader") || |
|
387 |
option.equals("-doctitle") || |
|
388 |
option.equals("-windowtitle") || |
|
389 |
option.equals("-top") || |
|
390 |
option.equals("-bottom") || |
|
391 |
option.equals("-helpfile") || |
|
392 |
option.equals("-stylesheetfile") || |
|
393 |
option.equals("-charset") || |
|
9608 | 394 |
option.equals("-overview") || |
395 |
option.equals("-xdocrootparent")) { |
|
10 | 396 |
return 2; |
397 |
} else { |
|
398 |
return 0; |
|
399 |
} |
|
400 |
} |
|
401 |
||
402 |
/** |
|
403 |
* {@inheritDoc} |
|
404 |
*/ |
|
14544 | 405 |
@Override |
10 | 406 |
public boolean validOptions(String options[][], |
407 |
DocErrorReporter reporter) { |
|
408 |
boolean helpfile = false; |
|
409 |
boolean nohelp = false; |
|
410 |
boolean overview = false; |
|
411 |
boolean nooverview = false; |
|
412 |
boolean splitindex = false; |
|
413 |
boolean noindex = false; |
|
414 |
// check shared options |
|
415 |
if (!generalValidOptions(options, reporter)) { |
|
416 |
return false; |
|
417 |
} |
|
418 |
// otherwise look at our options |
|
419 |
for (int oi = 0; oi < options.length; ++oi) { |
|
420 |
String[] os = options[oi]; |
|
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
21888
diff
changeset
|
421 |
String opt = StringUtils.toLowerCase(os[0]); |
10 | 422 |
if (opt.equals("-helpfile")) { |
423 |
if (nohelp == true) { |
|
424 |
reporter.printError(getText("doclet.Option_conflict", |
|
425 |
"-helpfile", "-nohelp")); |
|
426 |
return false; |
|
427 |
} |
|
428 |
if (helpfile == true) { |
|
429 |
reporter.printError(getText("doclet.Option_reuse", |
|
430 |
"-helpfile")); |
|
431 |
return false; |
|
432 |
} |
|
14368
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14357
diff
changeset
|
433 |
DocFile help = DocFile.createFileForInput(this, os[1]); |
10 | 434 |
if (!help.exists()) { |
435 |
reporter.printError(getText("doclet.File_not_found", os[1])); |
|
436 |
return false; |
|
437 |
} |
|
438 |
helpfile = true; |
|
439 |
} else if (opt.equals("-nohelp")) { |
|
440 |
if (helpfile == true) { |
|
441 |
reporter.printError(getText("doclet.Option_conflict", |
|
442 |
"-nohelp", "-helpfile")); |
|
443 |
return false; |
|
444 |
} |
|
445 |
nohelp = true; |
|
9608 | 446 |
} else if (opt.equals("-xdocrootparent")) { |
447 |
try { |
|
448 |
new URL(os[1]); |
|
449 |
} catch (MalformedURLException e) { |
|
450 |
reporter.printError(getText("doclet.MalformedURL", os[1])); |
|
451 |
return false; |
|
452 |
} |
|
10 | 453 |
} else if (opt.equals("-overview")) { |
454 |
if (nooverview == true) { |
|
455 |
reporter.printError(getText("doclet.Option_conflict", |
|
456 |
"-overview", "-nooverview")); |
|
457 |
return false; |
|
458 |
} |
|
459 |
if (overview == true) { |
|
460 |
reporter.printError(getText("doclet.Option_reuse", |
|
461 |
"-overview")); |
|
462 |
return false; |
|
463 |
} |
|
464 |
overview = true; |
|
465 |
} else if (opt.equals("-nooverview")) { |
|
466 |
if (overview == true) { |
|
467 |
reporter.printError(getText("doclet.Option_conflict", |
|
468 |
"-nooverview", "-overview")); |
|
469 |
return false; |
|
470 |
} |
|
471 |
nooverview = true; |
|
472 |
} else if (opt.equals("-splitindex")) { |
|
473 |
if (noindex == true) { |
|
474 |
reporter.printError(getText("doclet.Option_conflict", |
|
475 |
"-splitindex", "-noindex")); |
|
476 |
return false; |
|
477 |
} |
|
478 |
splitindex = true; |
|
479 |
} else if (opt.equals("-noindex")) { |
|
480 |
if (splitindex == true) { |
|
481 |
reporter.printError(getText("doclet.Option_conflict", |
|
482 |
"-noindex", "-splitindex")); |
|
483 |
return false; |
|
484 |
} |
|
485 |
noindex = true; |
|
15354 | 486 |
} else if (opt.startsWith("-xdoclint:")) { |
487 |
if (opt.contains("/")) { |
|
488 |
reporter.printError(getText("doclet.Option_doclint_no_qualifiers")); |
|
489 |
return false; |
|
490 |
} |
|
491 |
if (!DocLint.isValidOption( |
|
492 |
opt.replace("-xdoclint:", DocLint.XMSGS_CUSTOM_PREFIX))) { |
|
493 |
reporter.printError(getText("doclet.Option_doclint_invalid_arg")); |
|
494 |
return false; |
|
495 |
} |
|
31752 | 496 |
} else if (opt.startsWith("-xdoclint/package:")) { |
497 |
if (!DocLint.isValidOption( |
|
498 |
opt.replace("-xdoclint/package:", DocLint.XCHECK_PACKAGE))) { |
|
499 |
reporter.printError(getText("doclet.Option_doclint_package_invalid_arg")); |
|
500 |
return false; |
|
501 |
} |
|
10 | 502 |
} |
503 |
} |
|
504 |
return true; |
|
505 |
} |
|
506 |
||
507 |
/** |
|
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
508 |
* Return true if the generated output is HTML5. |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
509 |
*/ |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
510 |
public boolean isOutputHtml5() { |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
511 |
return htmlVersion == HtmlVersion.HTML5; |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
512 |
} |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
513 |
|
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
514 |
/** |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
515 |
* Return true if the tag is allowed for this specific version of HTML. |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
516 |
*/ |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
517 |
public boolean allowTag(HtmlTag htmlTag) { |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
518 |
return htmlTag.allowTag(this.htmlVersion); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
519 |
} |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
520 |
|
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
521 |
/** |
10 | 522 |
* {@inheritDoc} |
523 |
*/ |
|
14544 | 524 |
@Override |
10 | 525 |
public MessageRetriever getDocletSpecificMsg() { |
526 |
return standardmessage; |
|
527 |
} |
|
528 |
||
529 |
/** |
|
530 |
* Decide the page which will appear first in the right-hand frame. It will |
|
531 |
* be "overview-summary.html" if "-overview" option is used or no |
|
532 |
* "-overview" but the number of packages is more than one. It will be |
|
533 |
* "package-summary.html" of the respective package if there is only one |
|
534 |
* package to document. It will be a class page(first in the sorted order), |
|
535 |
* if only classes are provided on the command line. |
|
536 |
* |
|
537 |
* @param root Root of the program structure. |
|
538 |
*/ |
|
539 |
protected void setTopFile(RootDoc root) { |
|
540 |
if (!checkForDeprecation(root)) { |
|
541 |
return; |
|
542 |
} |
|
543 |
if (createoverview) { |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14259
diff
changeset
|
544 |
topFile = DocPaths.OVERVIEW_SUMMARY; |
10 | 545 |
} else { |
24221
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
23968
diff
changeset
|
546 |
if (packages.size() == 1 && packages.first().name().equals("")) { |
10 | 547 |
if (root.classes().length > 0) { |
548 |
ClassDoc[] classarr = root.classes(); |
|
549 |
Arrays.sort(classarr); |
|
550 |
ClassDoc cd = getValidClass(classarr); |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14259
diff
changeset
|
551 |
topFile = DocPath.forClass(cd); |
10 | 552 |
} |
24221
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
23968
diff
changeset
|
553 |
} else if (!packages.isEmpty()) { |
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
23968
diff
changeset
|
554 |
topFile = DocPath.forPackage(packages.first()).resolve(DocPaths.PACKAGE_SUMMARY); |
10 | 555 |
} |
556 |
} |
|
557 |
} |
|
558 |
||
559 |
protected ClassDoc getValidClass(ClassDoc[] classarr) { |
|
560 |
if (!nodeprecated) { |
|
561 |
return classarr[0]; |
|
562 |
} |
|
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
563 |
for (ClassDoc cd : classarr) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
564 |
if (cd.tags("deprecated").length == 0) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
565 |
return cd; |
10 | 566 |
} |
567 |
} |
|
568 |
return null; |
|
569 |
} |
|
570 |
||
571 |
protected boolean checkForDeprecation(RootDoc root) { |
|
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
572 |
for (ClassDoc cd : root.classes()) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
573 |
if (isGeneratedDoc(cd)) { |
10 | 574 |
return true; |
575 |
} |
|
576 |
} |
|
577 |
return false; |
|
578 |
} |
|
579 |
||
580 |
/** |
|
581 |
* Generate "overview.html" page if option "-overview" is used or number of |
|
582 |
* packages is more than one. Sets {@link #createoverview} field to true. |
|
583 |
*/ |
|
584 |
protected void setCreateOverview() { |
|
24221
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
23968
diff
changeset
|
585 |
if ((overview || packages.size() > 1) && !nooverview) { |
10 | 586 |
createoverview = true; |
587 |
} |
|
588 |
} |
|
589 |
||
590 |
/** |
|
591 |
* {@inheritDoc} |
|
592 |
*/ |
|
14544 | 593 |
@Override |
10 | 594 |
public WriterFactory getWriterFactory() { |
1475 | 595 |
return new WriterFactoryImpl(this); |
10 | 596 |
} |
597 |
||
598 |
/** |
|
599 |
* {@inheritDoc} |
|
600 |
*/ |
|
14544 | 601 |
@Override |
868 | 602 |
public Comparator<ProgramElementDoc> getMemberComparator() { |
10 | 603 |
return null; |
604 |
} |
|
1863
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1475
diff
changeset
|
605 |
|
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1475
diff
changeset
|
606 |
/** |
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1475
diff
changeset
|
607 |
* {@inheritDoc} |
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1475
diff
changeset
|
608 |
*/ |
14544 | 609 |
@Override |
1863
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1475
diff
changeset
|
610 |
public Locale getLocale() { |
15354 | 611 |
if (root instanceof RootDocImpl) |
612 |
return ((RootDocImpl)root).getLocale(); |
|
1863
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1475
diff
changeset
|
613 |
else |
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1475
diff
changeset
|
614 |
return Locale.getDefault(); |
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1475
diff
changeset
|
615 |
} |
14544 | 616 |
|
617 |
/** |
|
618 |
* {@inheritDoc} |
|
619 |
*/ |
|
620 |
@Override |
|
621 |
public JavaFileManager getFileManager() { |
|
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14544
diff
changeset
|
622 |
if (fileManager == null) { |
15354 | 623 |
if (root instanceof RootDocImpl) |
624 |
fileManager = ((RootDocImpl) root).getFileManager(); |
|
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14544
diff
changeset
|
625 |
else |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14544
diff
changeset
|
626 |
fileManager = new JavacFileManager(new Context(), false, null); |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14544
diff
changeset
|
627 |
} |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14544
diff
changeset
|
628 |
return fileManager; |
14544 | 629 |
} |
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14544
diff
changeset
|
630 |
|
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14544
diff
changeset
|
631 |
private JavaFileManager fileManager; |
15354 | 632 |
|
633 |
@Override |
|
634 |
public boolean showMessage(SourcePosition pos, String key) { |
|
635 |
if (root instanceof RootDocImpl) { |
|
636 |
return pos == null || ((RootDocImpl) root).showTagMessages(); |
|
637 |
} |
|
638 |
return true; |
|
639 |
} |
|
17563
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
15354
diff
changeset
|
640 |
|
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
15354
diff
changeset
|
641 |
@Override |
17570
78512b2899db
8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents:
17563
diff
changeset
|
642 |
public Content newContent() { |
17563
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
15354
diff
changeset
|
643 |
return new ContentBuilder(); |
e8ddeb9bd17c
8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents:
15354
diff
changeset
|
644 |
} |
33920 | 645 |
|
36526 | 646 |
@Override |
647 |
public Location getLocationForPackage(PackageDoc pd) { |
|
648 |
JavaFileManager fm = getFileManager(); |
|
649 |
return StandardLocation.SOURCE_PATH; |
|
650 |
} |
|
651 |
||
33920 | 652 |
protected void buildSearchTagIndex() { |
653 |
for (SearchIndexItem sii : tagSearchIndex) { |
|
654 |
String tagLabel = sii.getLabel(); |
|
655 |
char ch = (tagLabel.length() == 0) |
|
656 |
? '*' |
|
657 |
: Character.toUpperCase(tagLabel.charAt(0)); |
|
658 |
Character unicode = ch; |
|
659 |
List<SearchIndexItem> list = tagSearchIndexMap.get(unicode); |
|
660 |
if (list == null) { |
|
661 |
list = new ArrayList<>(); |
|
662 |
tagSearchIndexMap.put(unicode, list); |
|
663 |
} |
|
664 |
list.add(sii); |
|
665 |
} |
|
666 |
tagSearchIndexKeys = tagSearchIndexMap.keySet(); |
|
667 |
} |
|
10 | 668 |
} |