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