author | jjg |
Thu, 10 Jan 2013 19:38:57 -0800 | |
changeset 15354 | 52a04c670c05 |
parent 14545 | 2e7bab0639b8 |
child 17563 | e8ddeb9bd17c |
permissions | -rw-r--r-- |
10 | 1 |
/* |
15354 | 2 |
* Copyright (c) 1998, 2013, 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; |
32 |
||
10 | 33 |
import com.sun.javadoc.*; |
14258 | 34 |
import com.sun.tools.doclets.internal.toolkit.*; |
35 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
|
15354 | 36 |
import com.sun.tools.doclint.DocLint; |
14544 | 37 |
import com.sun.tools.javac.file.JavacFileManager; |
38 |
import com.sun.tools.javac.util.Context; |
|
15354 | 39 |
import com.sun.tools.javadoc.RootDocImpl; |
10 | 40 |
|
41 |
/** |
|
42 |
* Configure the output based on the command line options. |
|
43 |
* <p> |
|
44 |
* Also determine the length of the command line option. For example, |
|
45 |
* for a option "-header" there will be a string argument associated, then the |
|
46 |
* the length of option "-header" is two. But for option "-nohelp" no argument |
|
47 |
* is needed so it's length is 1. |
|
48 |
* </p> |
|
49 |
* <p> |
|
50 |
* Also do the error checking on the options used. For example it is illegal to |
|
51 |
* use "-helpfile" option when already "-nohelp" option is used. |
|
52 |
* </p> |
|
53 |
* |
|
14368
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14357
diff
changeset
|
54 |
* <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
|
55 |
* 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
|
56 |
* 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
|
57 |
* deletion without notice.</b> |
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14357
diff
changeset
|
58 |
* |
10 | 59 |
* @author Robert Field. |
60 |
* @author Atul Dambalkar. |
|
61 |
* @author Jamie Ho |
|
9608 | 62 |
* @author Bhavesh Patel (Modified) |
10 | 63 |
*/ |
64 |
public class ConfigurationImpl extends Configuration { |
|
65 |
||
66 |
/** |
|
67 |
* The build date. Note: For now, we will use |
|
68 |
* a version number instead of a date. |
|
69 |
*/ |
|
70 |
public static final String BUILD_DATE = System.getProperty("java.version"); |
|
71 |
||
72 |
/** |
|
73 |
* Argument for command line option "-header". |
|
74 |
*/ |
|
75 |
public String header = ""; |
|
76 |
||
77 |
/** |
|
78 |
* Argument for command line option "-packagesheader". |
|
79 |
*/ |
|
80 |
public String packagesheader = ""; |
|
81 |
||
82 |
/** |
|
83 |
* Argument for command line option "-footer". |
|
84 |
*/ |
|
85 |
public String footer = ""; |
|
86 |
||
87 |
/** |
|
88 |
* Argument for command line option "-doctitle". |
|
89 |
*/ |
|
90 |
public String doctitle = ""; |
|
91 |
||
92 |
/** |
|
93 |
* Argument for command line option "-windowtitle". |
|
94 |
*/ |
|
95 |
public String windowtitle = ""; |
|
96 |
||
97 |
/** |
|
98 |
* Argument for command line option "-top". |
|
99 |
*/ |
|
100 |
public String top = ""; |
|
101 |
||
102 |
/** |
|
103 |
* Argument for command line option "-bottom". |
|
104 |
*/ |
|
105 |
public String bottom = ""; |
|
106 |
||
107 |
/** |
|
108 |
* Argument for command line option "-helpfile". |
|
109 |
*/ |
|
110 |
public String helpfile = ""; |
|
111 |
||
112 |
/** |
|
113 |
* Argument for command line option "-stylesheetfile". |
|
114 |
*/ |
|
115 |
public String stylesheetfile = ""; |
|
116 |
||
117 |
/** |
|
9608 | 118 |
* Argument for command line option "-Xdocrootparent". |
119 |
*/ |
|
120 |
public String docrootparent = ""; |
|
121 |
||
122 |
/** |
|
10 | 123 |
* True if command line option "-nohelp" is used. Default value is false. |
124 |
*/ |
|
125 |
public boolean nohelp = false; |
|
126 |
||
127 |
/** |
|
128 |
* True if command line option "-splitindex" is used. Default value is |
|
129 |
* false. |
|
130 |
*/ |
|
131 |
public boolean splitindex = false; |
|
132 |
||
133 |
/** |
|
134 |
* False if command line option "-noindex" is used. Default value is true. |
|
135 |
*/ |
|
136 |
public boolean createindex = true; |
|
137 |
||
138 |
/** |
|
139 |
* True if command line option "-use" is used. Default value is false. |
|
140 |
*/ |
|
141 |
public boolean classuse = false; |
|
142 |
||
143 |
/** |
|
144 |
* False if command line option "-notree" is used. Default value is true. |
|
145 |
*/ |
|
146 |
public boolean createtree = true; |
|
147 |
||
148 |
/** |
|
149 |
* True if command line option "-nodeprecated" is used. Default value is |
|
150 |
* false. |
|
151 |
*/ |
|
152 |
public boolean nodeprecatedlist = false; |
|
153 |
||
154 |
/** |
|
155 |
* True if command line option "-nonavbar" is used. Default value is false. |
|
156 |
*/ |
|
157 |
public boolean nonavbar = false; |
|
158 |
||
159 |
/** |
|
160 |
* True if command line option "-nooverview" is used. Default value is |
|
161 |
* false |
|
162 |
*/ |
|
163 |
private boolean nooverview = false; |
|
164 |
||
165 |
/** |
|
166 |
* True if command line option "-overview" is used. Default value is false. |
|
167 |
*/ |
|
168 |
public boolean overview = false; |
|
169 |
||
170 |
/** |
|
171 |
* This is true if option "-overview" is used or option "-overview" is not |
|
172 |
* used and number of packages is more than one. |
|
173 |
*/ |
|
174 |
public boolean createoverview = false; |
|
175 |
||
176 |
/** |
|
15354 | 177 |
* Collected set of doclint options |
178 |
*/ |
|
179 |
public Set<String> doclintOpts = new LinkedHashSet<String>(); |
|
180 |
||
181 |
/** |
|
10 | 182 |
* Unique Resource Handler for this package. |
183 |
*/ |
|
184 |
public final MessageRetriever standardmessage; |
|
185 |
||
186 |
/** |
|
187 |
* First file to appear in the right-hand frame in the generated |
|
188 |
* documentation. |
|
189 |
*/ |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14259
diff
changeset
|
190 |
public DocPath topFile = DocPath.empty; |
10 | 191 |
|
192 |
/** |
|
193 |
* The classdoc for the class file getting generated. |
|
194 |
*/ |
|
14542 | 195 |
public ClassDoc currentcd = null; // Set this classdoc in the ClassWriter. |
10 | 196 |
|
197 |
/** |
|
14259 | 198 |
* Constructor. Initializes resource for the |
199 |
* {@link com.sun.tools.doclets.internal.toolkit.util.MessageRetriever MessageRetriever}. |
|
10 | 200 |
*/ |
14542 | 201 |
public ConfigurationImpl() { |
10 | 202 |
standardmessage = new MessageRetriever(this, |
203 |
"com.sun.tools.doclets.formats.html.resources.standard"); |
|
204 |
} |
|
205 |
||
1475 | 206 |
/** |
10 | 207 |
* Return the build date for the doclet. |
208 |
*/ |
|
14544 | 209 |
@Override |
10 | 210 |
public String getDocletSpecificBuildDate() { |
211 |
return BUILD_DATE; |
|
212 |
} |
|
213 |
||
214 |
/** |
|
215 |
* Depending upon the command line options provided by the user, set |
|
216 |
* configure the output generation environment. |
|
217 |
* |
|
218 |
* @param options The array of option names and values. |
|
219 |
*/ |
|
14544 | 220 |
@Override |
10 | 221 |
public void setSpecificDocletOptions(String[][] options) { |
222 |
for (int oi = 0; oi < options.length; ++oi) { |
|
223 |
String[] os = options[oi]; |
|
224 |
String opt = os[0].toLowerCase(); |
|
225 |
if (opt.equals("-footer")) { |
|
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
226 |
footer = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
227 |
} else if (opt.equals("-header")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
228 |
header = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
229 |
} else if (opt.equals("-packagesheader")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
230 |
packagesheader = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
231 |
} else if (opt.equals("-doctitle")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
232 |
doctitle = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
233 |
} else if (opt.equals("-windowtitle")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
234 |
windowtitle = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
235 |
} else if (opt.equals("-top")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
236 |
top = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
237 |
} else if (opt.equals("-bottom")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
238 |
bottom = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
239 |
} else if (opt.equals("-helpfile")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
240 |
helpfile = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
241 |
} else if (opt.equals("-stylesheetfile")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
242 |
stylesheetfile = os[1]; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
243 |
} else if (opt.equals("-charset")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
244 |
charset = os[1]; |
9608 | 245 |
} else if (opt.equals("-xdocrootparent")) { |
246 |
docrootparent = os[1]; |
|
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
247 |
} else if (opt.equals("-nohelp")) { |
10 | 248 |
nohelp = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
249 |
} else if (opt.equals("-splitindex")) { |
10 | 250 |
splitindex = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
251 |
} else if (opt.equals("-noindex")) { |
10 | 252 |
createindex = false; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
253 |
} else if (opt.equals("-use")) { |
10 | 254 |
classuse = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
255 |
} else if (opt.equals("-notree")) { |
10 | 256 |
createtree = false; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
257 |
} else if (opt.equals("-nodeprecatedlist")) { |
10 | 258 |
nodeprecatedlist = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
259 |
} else if (opt.equals("-nonavbar")) { |
10 | 260 |
nonavbar = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
261 |
} else if (opt.equals("-nooverview")) { |
10 | 262 |
nooverview = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9608
diff
changeset
|
263 |
} else if (opt.equals("-overview")) { |
10 | 264 |
overview = true; |
15354 | 265 |
} else if (opt.equals("-xdoclint")) { |
266 |
doclintOpts.add(null); |
|
267 |
} else if (opt.startsWith("-xdoclint:")) { |
|
268 |
doclintOpts.add(opt.substring(opt.indexOf(":") + 1)); |
|
10 | 269 |
} |
270 |
} |
|
271 |
if (root.specifiedClasses().length > 0) { |
|
868 | 272 |
Map<String,PackageDoc> map = new HashMap<String,PackageDoc>(); |
10 | 273 |
PackageDoc pd; |
274 |
ClassDoc[] classes = root.classes(); |
|
275 |
for (int i = 0; i < classes.length; i++) { |
|
276 |
pd = classes[i].containingPackage(); |
|
277 |
if(! map.containsKey(pd.name())) { |
|
278 |
map.put(pd.name(), pd); |
|
279 |
} |
|
280 |
} |
|
281 |
} |
|
282 |
setCreateOverview(); |
|
283 |
setTopFile(root); |
|
15354 | 284 |
|
285 |
if (root instanceof RootDocImpl) { |
|
286 |
((RootDocImpl) root).initDocLint(doclintOpts); |
|
287 |
} |
|
10 | 288 |
} |
289 |
||
290 |
/** |
|
291 |
* Returns the "length" of a given option. If an option takes no |
|
292 |
* arguments, its length is one. If it takes one argument, it's |
|
293 |
* length is two, and so on. This method is called by JavaDoc to |
|
294 |
* parse the options it does not recognize. It then calls |
|
295 |
* {@link #validOptions(String[][], DocErrorReporter)} to |
|
296 |
* validate them. |
|
297 |
* <b>Note:</b><br> |
|
298 |
* The options arrive as case-sensitive strings. For options that |
|
299 |
* are not case-sensitive, use toLowerCase() on the option string |
|
300 |
* before comparing it. |
|
301 |
* </blockquote> |
|
302 |
* |
|
303 |
* @return number of arguments + 1 for a option. Zero return means |
|
304 |
* option not known. Negative value means error occurred. |
|
305 |
*/ |
|
306 |
public int optionLength(String option) { |
|
307 |
int result = -1; |
|
308 |
if ((result = super.optionLength(option)) > 0) { |
|
309 |
return result; |
|
310 |
} |
|
311 |
// otherwise look for the options we have added |
|
312 |
option = option.toLowerCase(); |
|
313 |
if (option.equals("-nodeprecatedlist") || |
|
314 |
option.equals("-noindex") || |
|
315 |
option.equals("-notree") || |
|
316 |
option.equals("-nohelp") || |
|
317 |
option.equals("-splitindex") || |
|
318 |
option.equals("-serialwarn") || |
|
319 |
option.equals("-use") || |
|
320 |
option.equals("-nonavbar") || |
|
15354 | 321 |
option.equals("-nooverview") || |
322 |
option.equals("-xdoclint") || |
|
323 |
option.startsWith("-xdoclint:")) { |
|
10 | 324 |
return 1; |
325 |
} else if (option.equals("-help")) { |
|
326 |
System.out.println(getText("doclet.usage")); |
|
327 |
return 1; |
|
328 |
} else if (option.equals("-footer") || |
|
329 |
option.equals("-header") || |
|
330 |
option.equals("-packagesheader") || |
|
331 |
option.equals("-doctitle") || |
|
332 |
option.equals("-windowtitle") || |
|
333 |
option.equals("-top") || |
|
334 |
option.equals("-bottom") || |
|
335 |
option.equals("-helpfile") || |
|
336 |
option.equals("-stylesheetfile") || |
|
337 |
option.equals("-charset") || |
|
9608 | 338 |
option.equals("-overview") || |
339 |
option.equals("-xdocrootparent")) { |
|
10 | 340 |
return 2; |
341 |
} else { |
|
342 |
return 0; |
|
343 |
} |
|
344 |
} |
|
345 |
||
346 |
/** |
|
347 |
* {@inheritDoc} |
|
348 |
*/ |
|
14544 | 349 |
@Override |
10 | 350 |
public boolean validOptions(String options[][], |
351 |
DocErrorReporter reporter) { |
|
352 |
boolean helpfile = false; |
|
353 |
boolean nohelp = false; |
|
354 |
boolean overview = false; |
|
355 |
boolean nooverview = false; |
|
356 |
boolean splitindex = false; |
|
357 |
boolean noindex = false; |
|
358 |
// check shared options |
|
359 |
if (!generalValidOptions(options, reporter)) { |
|
360 |
return false; |
|
361 |
} |
|
362 |
// otherwise look at our options |
|
363 |
for (int oi = 0; oi < options.length; ++oi) { |
|
364 |
String[] os = options[oi]; |
|
365 |
String opt = os[0].toLowerCase(); |
|
366 |
if (opt.equals("-helpfile")) { |
|
367 |
if (nohelp == true) { |
|
368 |
reporter.printError(getText("doclet.Option_conflict", |
|
369 |
"-helpfile", "-nohelp")); |
|
370 |
return false; |
|
371 |
} |
|
372 |
if (helpfile == true) { |
|
373 |
reporter.printError(getText("doclet.Option_reuse", |
|
374 |
"-helpfile")); |
|
375 |
return false; |
|
376 |
} |
|
14368
6f4c62de6985
8001664: refactor javadoc to use abstraction to handle files
jjg
parents:
14357
diff
changeset
|
377 |
DocFile help = DocFile.createFileForInput(this, os[1]); |
10 | 378 |
if (!help.exists()) { |
379 |
reporter.printError(getText("doclet.File_not_found", os[1])); |
|
380 |
return false; |
|
381 |
} |
|
382 |
helpfile = true; |
|
383 |
} else if (opt.equals("-nohelp")) { |
|
384 |
if (helpfile == true) { |
|
385 |
reporter.printError(getText("doclet.Option_conflict", |
|
386 |
"-nohelp", "-helpfile")); |
|
387 |
return false; |
|
388 |
} |
|
389 |
nohelp = true; |
|
9608 | 390 |
} else if (opt.equals("-xdocrootparent")) { |
391 |
try { |
|
392 |
new URL(os[1]); |
|
393 |
} catch (MalformedURLException e) { |
|
394 |
reporter.printError(getText("doclet.MalformedURL", os[1])); |
|
395 |
return false; |
|
396 |
} |
|
10 | 397 |
} else if (opt.equals("-overview")) { |
398 |
if (nooverview == true) { |
|
399 |
reporter.printError(getText("doclet.Option_conflict", |
|
400 |
"-overview", "-nooverview")); |
|
401 |
return false; |
|
402 |
} |
|
403 |
if (overview == true) { |
|
404 |
reporter.printError(getText("doclet.Option_reuse", |
|
405 |
"-overview")); |
|
406 |
return false; |
|
407 |
} |
|
408 |
overview = true; |
|
409 |
} else if (opt.equals("-nooverview")) { |
|
410 |
if (overview == true) { |
|
411 |
reporter.printError(getText("doclet.Option_conflict", |
|
412 |
"-nooverview", "-overview")); |
|
413 |
return false; |
|
414 |
} |
|
415 |
nooverview = true; |
|
416 |
} else if (opt.equals("-splitindex")) { |
|
417 |
if (noindex == true) { |
|
418 |
reporter.printError(getText("doclet.Option_conflict", |
|
419 |
"-splitindex", "-noindex")); |
|
420 |
return false; |
|
421 |
} |
|
422 |
splitindex = true; |
|
423 |
} else if (opt.equals("-noindex")) { |
|
424 |
if (splitindex == true) { |
|
425 |
reporter.printError(getText("doclet.Option_conflict", |
|
426 |
"-noindex", "-splitindex")); |
|
427 |
return false; |
|
428 |
} |
|
429 |
noindex = true; |
|
15354 | 430 |
} else if (opt.startsWith("-xdoclint:")) { |
431 |
if (opt.contains("/")) { |
|
432 |
reporter.printError(getText("doclet.Option_doclint_no_qualifiers")); |
|
433 |
return false; |
|
434 |
} |
|
435 |
if (!DocLint.isValidOption( |
|
436 |
opt.replace("-xdoclint:", DocLint.XMSGS_CUSTOM_PREFIX))) { |
|
437 |
reporter.printError(getText("doclet.Option_doclint_invalid_arg")); |
|
438 |
return false; |
|
439 |
} |
|
10 | 440 |
} |
441 |
} |
|
442 |
return true; |
|
443 |
} |
|
444 |
||
445 |
/** |
|
446 |
* {@inheritDoc} |
|
447 |
*/ |
|
14544 | 448 |
@Override |
10 | 449 |
public MessageRetriever getDocletSpecificMsg() { |
450 |
return standardmessage; |
|
451 |
} |
|
452 |
||
453 |
/** |
|
454 |
* Decide the page which will appear first in the right-hand frame. It will |
|
455 |
* be "overview-summary.html" if "-overview" option is used or no |
|
456 |
* "-overview" but the number of packages is more than one. It will be |
|
457 |
* "package-summary.html" of the respective package if there is only one |
|
458 |
* package to document. It will be a class page(first in the sorted order), |
|
459 |
* if only classes are provided on the command line. |
|
460 |
* |
|
461 |
* @param root Root of the program structure. |
|
462 |
*/ |
|
463 |
protected void setTopFile(RootDoc root) { |
|
464 |
if (!checkForDeprecation(root)) { |
|
465 |
return; |
|
466 |
} |
|
467 |
if (createoverview) { |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14259
diff
changeset
|
468 |
topFile = DocPaths.OVERVIEW_SUMMARY; |
10 | 469 |
} else { |
470 |
if (packages.length == 1 && packages[0].name().equals("")) { |
|
471 |
if (root.classes().length > 0) { |
|
472 |
ClassDoc[] classarr = root.classes(); |
|
473 |
Arrays.sort(classarr); |
|
474 |
ClassDoc cd = getValidClass(classarr); |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14259
diff
changeset
|
475 |
topFile = DocPath.forClass(cd); |
10 | 476 |
} |
477 |
} else { |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14259
diff
changeset
|
478 |
topFile = DocPath.forPackage(packages[0]).resolve(DocPaths.PACKAGE_SUMMARY); |
10 | 479 |
} |
480 |
} |
|
481 |
} |
|
482 |
||
483 |
protected ClassDoc getValidClass(ClassDoc[] classarr) { |
|
484 |
if (!nodeprecated) { |
|
485 |
return classarr[0]; |
|
486 |
} |
|
487 |
for (int i = 0; i < classarr.length; i++) { |
|
488 |
if (classarr[i].tags("deprecated").length == 0) { |
|
489 |
return classarr[i]; |
|
490 |
} |
|
491 |
} |
|
492 |
return null; |
|
493 |
} |
|
494 |
||
495 |
protected boolean checkForDeprecation(RootDoc root) { |
|
496 |
ClassDoc[] classarr = root.classes(); |
|
497 |
for (int i = 0; i < classarr.length; i++) { |
|
498 |
if (isGeneratedDoc(classarr[i])) { |
|
499 |
return true; |
|
500 |
} |
|
501 |
} |
|
502 |
return false; |
|
503 |
} |
|
504 |
||
505 |
/** |
|
506 |
* Generate "overview.html" page if option "-overview" is used or number of |
|
507 |
* packages is more than one. Sets {@link #createoverview} field to true. |
|
508 |
*/ |
|
509 |
protected void setCreateOverview() { |
|
510 |
if ((overview || packages.length > 1) && !nooverview) { |
|
511 |
createoverview = true; |
|
512 |
} |
|
513 |
} |
|
514 |
||
515 |
/** |
|
516 |
* {@inheritDoc} |
|
517 |
*/ |
|
14544 | 518 |
@Override |
10 | 519 |
public WriterFactory getWriterFactory() { |
1475 | 520 |
return new WriterFactoryImpl(this); |
10 | 521 |
} |
522 |
||
523 |
/** |
|
524 |
* {@inheritDoc} |
|
525 |
*/ |
|
14544 | 526 |
@Override |
868 | 527 |
public Comparator<ProgramElementDoc> getMemberComparator() { |
10 | 528 |
return null; |
529 |
} |
|
1863
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1475
diff
changeset
|
530 |
|
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1475
diff
changeset
|
531 |
/** |
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1475
diff
changeset
|
532 |
* {@inheritDoc} |
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1475
diff
changeset
|
533 |
*/ |
14544 | 534 |
@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
|
535 |
public Locale getLocale() { |
15354 | 536 |
if (root instanceof RootDocImpl) |
537 |
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
|
538 |
else |
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1475
diff
changeset
|
539 |
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
|
540 |
} |
14544 | 541 |
|
542 |
/** |
|
543 |
* {@inheritDoc} |
|
544 |
*/ |
|
545 |
@Override |
|
546 |
public JavaFileManager getFileManager() { |
|
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14544
diff
changeset
|
547 |
if (fileManager == null) { |
15354 | 548 |
if (root instanceof RootDocImpl) |
549 |
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
|
550 |
else |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14544
diff
changeset
|
551 |
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
|
552 |
} |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14544
diff
changeset
|
553 |
return fileManager; |
14544 | 554 |
} |
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14544
diff
changeset
|
555 |
|
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14544
diff
changeset
|
556 |
private JavaFileManager fileManager; |
15354 | 557 |
|
558 |
@Override |
|
559 |
public boolean showMessage(SourcePosition pos, String key) { |
|
560 |
if (root instanceof RootDocImpl) { |
|
561 |
return pos == null || ((RootDocImpl) root).showTagMessages(); |
|
562 |
} |
|
563 |
return true; |
|
564 |
} |
|
10 | 565 |
} |