1 |
/* gnu.classpath.tools.gjdoc.Main |
/* gnu.classpath.tools.gjdoc.Main |
2 |
Copyright (C) 2001 Free Software Foundation, Inc. |
Copyright (C) 2001 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
6 |
GNU Classpath is free software; you can redistribute it and/or modify |
GNU Classpath is free software; you can redistribute it and/or modify |
7 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
8 |
the Free Software Foundation; either version 2, or (at your option) |
the Free Software Foundation; either version 2, or (at your option) |
9 |
any later version. |
any later version. |
10 |
|
|
11 |
GNU Classpath is distributed in the hope that it will be useful, but |
GNU Classpath is distributed in the hope that it will be useful, but |
12 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
General Public License for more details. |
General Public License for more details. |
15 |
|
|
16 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
17 |
along with GNU Classpath; see the file COPYING. If not, write to the |
along with GNU Classpath; see the file COPYING. If not, write to the |
18 |
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
19 |
02111-1307 USA. */ |
02111-1307 USA. */ |
20 |
|
|
21 |
package gnu.classpath.tools.gjdoc; |
package gnu.classpath.tools.gjdoc; |
22 |
|
|
25 |
import java.util.*; |
import java.util.*; |
26 |
import java.lang.reflect.*; |
import java.lang.reflect.*; |
27 |
|
|
28 |
public final class Main { |
/** |
29 |
|
* Class that will launch the gjdoc tool. |
30 |
|
*/ |
31 |
|
public final class Main |
32 |
|
{ |
33 |
|
|
34 |
|
/** |
35 |
|
* Do we load classes that are referenced as base class? |
36 |
|
*/ |
37 |
|
static final boolean DESCEND_SUPERCLASS = true; |
38 |
|
|
39 |
|
/** |
40 |
|
* Do we load classes that are referenced as interface? |
41 |
|
*/ |
42 |
|
static final boolean DESCEND_INTERFACES = false; |
43 |
|
|
44 |
|
/** |
45 |
|
* Do we load classes that are imported in a source file? |
46 |
|
*/ |
47 |
|
static final boolean DESCEND_IMPORTED = true; |
48 |
|
|
49 |
|
/** |
50 |
|
* Document only public members. |
51 |
|
*/ |
52 |
|
static final int COVERAGE_PUBLIC = 0; |
53 |
|
|
54 |
|
/** |
55 |
|
* Document only public and protected members. |
56 |
|
*/ |
57 |
|
static final int COVERAGE_PROTECTED = 1; |
58 |
|
|
59 |
|
/** |
60 |
|
* Document public, protected and package private members. |
61 |
|
*/ |
62 |
|
static final int COVERAGE_PACKAGE = 2; |
63 |
|
|
64 |
|
/** |
65 |
|
* Document all members. |
66 |
|
*/ |
67 |
|
static final int COVERAGE_PRIVATE = 3; |
68 |
|
|
69 |
|
/** |
70 |
|
* Grid for looking up whether a particular access level is included in the |
71 |
|
* documentation. |
72 |
|
*/ |
73 |
|
static final boolean[][] coverageTemplates = new boolean[][] |
74 |
|
{ new boolean[] |
75 |
|
{ true, false, false, false }, // public |
76 |
|
new boolean[] |
77 |
|
{ true, true, false, false }, // protected |
78 |
|
new boolean[] |
79 |
|
{ true, true, true, false }, // package |
80 |
|
new boolean[] |
81 |
|
{ true, true, true, true }, // private |
82 |
|
}; |
83 |
|
|
84 |
|
/** |
85 |
|
* Holds the Singleton instance of this class. |
86 |
|
*/ |
87 |
|
private static Main instance = new Main(); |
88 |
|
|
89 |
|
/** |
90 |
|
* Avoid re-instantiation of this class. |
91 |
|
*/ |
92 |
|
private Main() |
93 |
|
{ |
94 |
|
} |
95 |
|
|
96 |
|
private static RootDocImpl rootDoc; |
97 |
|
|
98 |
|
private ErrorReporter reporter; |
99 |
|
|
100 |
|
/** |
101 |
|
* <code>false</code> during Phase I: preparation of the documentation data. |
102 |
|
* <code>true</code> during Phase II: documentation output by doclet. |
103 |
|
*/ |
104 |
|
boolean docletRunning = false; |
105 |
|
|
106 |
|
//---- Command line options |
107 |
|
|
108 |
|
/** |
109 |
|
* Option "-doclet": name of the Doclet class to use. |
110 |
|
*/ |
111 |
|
private String option_doclet = "gnu.classpath.tools.doclets.xmldoclet.Driver"; |
112 |
|
|
113 |
|
/** |
114 |
|
* Option "-overview": path to the special overview file. |
115 |
|
*/ |
116 |
|
private String option_overview; |
117 |
|
|
118 |
|
/** |
119 |
|
* Option "-coverage": which members to include in generated documentation. |
120 |
|
*/ |
121 |
|
private int option_coverage = COVERAGE_PROTECTED; |
122 |
|
|
123 |
|
/** |
124 |
|
* Option "-help": display command line usage. |
125 |
|
*/ |
126 |
|
private boolean option_help; |
127 |
|
|
128 |
|
/** |
129 |
|
* Option "-docletpath": path to doclet classes. |
130 |
|
*/ |
131 |
|
private String option_docletpath; |
132 |
|
|
133 |
|
/** |
134 |
|
* Option "-classpath": path to additional classes. |
135 |
|
*/ |
136 |
|
private String option_classpath; |
137 |
|
|
138 |
|
/** |
139 |
|
* Option "-sourcepath": path to the Java source files to be documented. |
140 |
|
* FIXME: this should be a list of paths |
141 |
|
*/ |
142 |
|
private List option_sourcepath = new ArrayList(); |
143 |
|
|
144 |
|
/** |
145 |
|
* Option "-bootclasspath": path to Java bootstrap classes. |
146 |
|
*/ |
147 |
|
private String option_bootclasspath; |
148 |
|
|
149 |
|
/** |
150 |
|
* Option "-extdirs": path to Java extension files. |
151 |
|
*/ |
152 |
|
private String option_extdirs; |
153 |
|
|
154 |
|
/** |
155 |
|
* Option "-verbose": Be verbose when generating documentation. |
156 |
|
*/ |
157 |
|
private boolean option_verbose; |
158 |
|
|
159 |
|
/** |
160 |
|
* Option "-nowarn": Do not print warnings. |
161 |
|
*/ |
162 |
|
private boolean option_nowarn; |
163 |
|
|
164 |
|
/** |
165 |
|
* Option "-locale:" Specify the locale charset of Java source files. |
166 |
|
*/ |
167 |
|
private String option_locale; |
168 |
|
|
169 |
|
/** |
170 |
|
* Option "-encoding": Specify character encoding of Java source files. |
171 |
|
*/ |
172 |
|
private String option_encoding; |
173 |
|
|
174 |
|
/** |
175 |
|
* Option "-J": Specify flags to be passed to Java runtime. |
176 |
|
*/ |
177 |
|
private List option_java_flags = new LinkedList(); //ArrayList(); |
178 |
|
|
179 |
|
/** |
180 |
|
* Option "-source:" should be 1.4 to handle assertions, 1.1 is no more |
181 |
|
* supported. |
182 |
|
*/ |
183 |
|
private String option_source; |
184 |
|
|
185 |
|
// TODO: add the rest of the options as instance variables |
186 |
|
|
187 |
|
/** |
188 |
|
* Parse all source files/packages and subsequentially start the Doclet given |
189 |
|
* on the command line. |
190 |
|
* |
191 |
|
* @param customOptions |
192 |
|
* List of unrecognized command line tokens |
193 |
|
*/ |
194 |
|
private void startDoclet(List customOptions) |
195 |
|
{ |
196 |
|
|
197 |
|
try |
198 |
|
{ |
199 |
|
|
200 |
|
//--- Fetch the Class object for the Doclet. |
201 |
|
|
202 |
|
Debug.log(1, "loading doclet class..."); |
203 |
|
|
204 |
|
Class docletClass = Class.forName(option_doclet); |
205 |
|
//Object docletInstance = docletClass.newInstance(); |
206 |
|
|
207 |
|
Debug.log(1, "doclet class loaded..."); |
208 |
|
|
209 |
|
Method startTempMethod = null; |
210 |
|
Method startMethod = null; |
211 |
|
Method optionLenMethod = null; |
212 |
|
Method validOptionsMethod = null; |
213 |
|
|
214 |
|
//--- Try to find the optionLength method in the Doclet class. |
215 |
|
|
216 |
|
try |
217 |
|
{ |
218 |
|
optionLenMethod = docletClass.getMethod("optionLength", new Class[] |
219 |
|
{ String.class }); |
220 |
|
} |
221 |
|
catch (NoSuchMethodException e) |
222 |
|
{ |
223 |
|
// Ignore if not found; it's OK it the Doclet class doesn't define |
224 |
|
// this method. |
225 |
|
} |
226 |
|
|
227 |
|
//--- Try to find the validOptions method in the Doclet class. |
228 |
|
|
229 |
|
try |
230 |
|
{ |
231 |
|
validOptionsMethod = docletClass.getMethod("validOptions", new Class[] |
232 |
|
{ String[][].class, DocErrorReporter.class }); |
233 |
|
} |
234 |
|
catch (NoSuchMethodException e) |
235 |
|
{ |
236 |
|
// Ignore if not found; it's OK it the Doclet class doesn't define |
237 |
|
// this method. |
238 |
|
} |
239 |
|
|
240 |
|
//--- Find the start method in the Doclet class; complain if not found |
241 |
|
|
242 |
|
try |
243 |
|
{ |
244 |
|
startTempMethod = docletClass.getMethod("start", new Class[] |
245 |
|
{ TemporaryStore.class }); |
246 |
|
} |
247 |
|
catch (Exception e) |
248 |
|
{ |
249 |
|
// ignore |
250 |
|
} |
251 |
|
startMethod = docletClass.getMethod("start", new Class[] |
252 |
|
{ RootDoc.class }); |
253 |
|
|
254 |
|
//--- Feed the custom command line tokens to the Doclet |
255 |
|
|
256 |
|
// stores all recognized options |
257 |
|
List options = new LinkedList(); |
258 |
|
|
259 |
|
// stores packages and classes defined on the command line |
260 |
|
List packageAndClasses = new LinkedList(); |
261 |
|
|
262 |
|
for (Iterator it = customOptions.iterator(); it.hasNext();) |
263 |
|
{ |
264 |
|
String option = (String) it.next(); |
265 |
|
|
266 |
|
Debug.log(9, "parsing option '" + option + "'"); |
267 |
|
|
268 |
|
if (option.startsWith("-")) |
269 |
|
{ |
270 |
|
|
271 |
|
//--- Parse option |
272 |
|
|
273 |
|
int optlen = 0; |
274 |
|
|
275 |
|
//--- Try to get option length from Doclet class |
276 |
|
|
277 |
|
if (optionLenMethod != null) |
278 |
|
{ |
279 |
|
|
280 |
|
optionLenMethod.invoke(null, new Object[] |
281 |
|
{ option }); |
282 |
|
|
283 |
|
Debug.log(3, "invoking optionLen method"); |
284 |
|
|
285 |
|
optlen = ((Integer) optionLenMethod.invoke(null, new Object[] |
286 |
|
{ option })).intValue(); |
287 |
|
|
288 |
|
Debug.log(3, "done"); |
289 |
|
} |
290 |
|
|
291 |
|
if (optlen <= 0) |
292 |
|
{ |
293 |
|
|
294 |
|
//--- Complain if not found |
295 |
|
|
296 |
|
reporter.printError("Unknown option " + option); |
297 |
|
shutdown(); |
298 |
|
} |
299 |
|
else |
300 |
|
{ |
301 |
|
|
302 |
|
//--- Read option values |
303 |
|
|
304 |
|
String[] optionAndValues = new String[optlen]; |
305 |
|
optionAndValues[0] = option; |
306 |
|
for (int i = 1; i < optlen; ++i) |
307 |
|
{ |
308 |
|
if (!it.hasNext()) |
309 |
|
{ |
310 |
|
reporter.printError("Missing value for option " + option); |
311 |
|
shutdown(); |
312 |
|
} |
313 |
|
else |
314 |
|
{ |
315 |
|
optionAndValues[i] = (String) it.next(); |
316 |
|
} |
317 |
|
} |
318 |
|
|
319 |
|
//--- Store option for processing later |
320 |
|
|
321 |
|
options.add(optionAndValues); |
322 |
|
} |
323 |
|
} |
324 |
|
else |
325 |
|
{ |
326 |
|
|
327 |
|
//--- Add to list of packages/classes if not option or option |
328 |
|
// value |
329 |
|
|
330 |
|
packageAndClasses.add(option); |
331 |
|
} |
332 |
|
} |
333 |
|
|
334 |
|
Debug.log(9, "options parsed..."); |
335 |
|
|
336 |
|
//--- Complain if no packages or classes specified |
337 |
|
|
338 |
|
if (packageAndClasses.isEmpty()) |
339 |
|
{ |
340 |
|
reporter.printError("No packages or classes specified."); |
341 |
|
usage(); |
342 |
|
shutdown(); |
343 |
|
} |
344 |
|
|
345 |
|
//--- For each class or package specified on the command line, |
346 |
|
// check that it exists and find out whether it is a class |
347 |
|
// or a package |
348 |
|
|
349 |
|
for (Iterator it = packageAndClasses.iterator(); it.hasNext();) |
350 |
|
{ |
351 |
|
|
352 |
|
String classOrPackage = (String) it.next(); |
353 |
|
|
354 |
|
//--- Check for illegal name |
355 |
|
|
356 |
|
if (classOrPackage.startsWith(".") |
357 |
|
|| classOrPackage.endsWith(".") |
358 |
|
|| classOrPackage.indexOf("..") > 0 |
359 |
|
|| !checkCharSet(classOrPackage, |
360 |
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_.")) |
361 |
|
{ |
362 |
|
throw new ParseException("Illegal class or package name '" |
363 |
|
+ classOrPackage + "'"); |
364 |
|
} |
365 |
|
|
366 |
|
//--- Assemble absolute path to package |
367 |
|
|
368 |
|
String classOrPackageRelPath = classOrPackage.replace('.', |
369 |
|
File.separatorChar); |
370 |
|
|
371 |
|
//--- Create one file object each for a possible package directory |
372 |
|
// and a possible class file, and find out if they exist. |
373 |
|
|
374 |
|
File packageDir = rootDoc.findSourceFile(classOrPackageRelPath); |
375 |
|
File sourceFile = rootDoc.findSourceFile(classOrPackageRelPath |
376 |
|
+ ".java"); |
377 |
|
|
378 |
|
boolean packageDirExists = packageDir != null |
379 |
|
&& packageDir.exists() |
380 |
|
&& packageDir.getCanonicalFile().getAbsolutePath().endsWith( |
381 |
|
classOrPackageRelPath); |
382 |
|
|
383 |
|
boolean sourceFileExists = sourceFile != null |
384 |
|
&& sourceFile.exists() |
385 |
|
&& sourceFile.getCanonicalFile().getAbsolutePath().endsWith( |
386 |
|
classOrPackageRelPath + ".java"); |
387 |
|
|
388 |
|
//--- Complain if neither exists: not found |
389 |
|
|
390 |
|
if (!packageDirExists && !sourceFileExists) |
391 |
|
{ |
392 |
|
reporter.printError("Class or package " + classOrPackage |
393 |
|
+ " not found."); |
394 |
|
shutdown(); |
395 |
|
} |
396 |
|
|
397 |
|
//--- Complain if both exist: ambigious |
398 |
|
|
399 |
|
else |
400 |
|
if (packageDirExists && sourceFileExists) |
401 |
|
{ |
402 |
|
reporter.printError("Ambigious class/package name " |
403 |
|
+ classOrPackage + "."); |
404 |
|
shutdown(); |
405 |
|
} |
406 |
|
|
407 |
|
//--- Otherwise, if the package directory exists, it is a package |
408 |
|
|
409 |
|
else |
410 |
|
if (packageDirExists) |
411 |
|
{ |
412 |
|
if (!packageDir.isDirectory()) |
413 |
|
{ |
414 |
|
reporter.printError("File \"" + packageDir |
415 |
|
+ "\" doesn't have .java extension."); |
416 |
|
shutdown(); |
417 |
|
} |
418 |
|
else |
419 |
|
{ |
420 |
|
rootDoc.addSpecifiedPackageName(classOrPackage); |
421 |
|
} |
422 |
|
} |
423 |
|
|
424 |
|
//--- Otherwise, it must be a Java source file file |
425 |
|
|
426 |
|
else |
427 |
|
/* if (sourceFileExists) */{ |
428 |
|
if (sourceFile.isDirectory()) |
429 |
|
{ |
430 |
|
reporter.printError("File \"" + sourceFile |
431 |
|
+ "\" is a directory!"); |
432 |
|
shutdown(); |
433 |
|
} |
434 |
|
else |
435 |
|
{ |
436 |
|
rootDoc.addSpecifiedClassName(classOrPackage); |
437 |
|
} |
438 |
|
} |
439 |
|
} |
440 |
|
|
441 |
|
//--- Validate custom options passed on command line |
442 |
|
// by asking the Doclet if they are OK. |
443 |
|
|
444 |
|
String[][] customOptionArr = (String[][]) options |
445 |
|
.toArray(new String[0][0]); |
446 |
|
if (validOptionsMethod != null |
447 |
|
&& !((Boolean) validOptionsMethod.invoke(null, new Object[] |
448 |
|
{ customOptionArr, this })).booleanValue()) |
449 |
|
{ |
450 |
|
// Not ok: shutdown system. |
451 |
|
shutdown(); |
452 |
|
} |
453 |
|
|
454 |
|
rootDoc.setOptions(customOptionArr); |
455 |
|
|
456 |
|
rootDoc.build(); |
457 |
|
|
458 |
|
//--- Our work is done, tidy up memory |
459 |
|
|
460 |
|
System.gc(); |
461 |
|
System.gc(); |
462 |
|
|
463 |
|
//--- Set flag indicating Phase II of documentation generation |
464 |
|
|
465 |
|
docletRunning = true; |
466 |
|
|
467 |
|
//--- Invoke the start method on the Doclet: produce output |
468 |
|
|
469 |
|
reporter.printNotice("Running doclet..."); |
470 |
|
|
471 |
|
TemporaryStore tstore = new TemporaryStore(Main.rootDoc); |
472 |
|
|
473 |
|
if (null != startTempMethod) |
474 |
|
{ |
475 |
|
startTempMethod.invoke(null, new Object[] |
476 |
|
{ tstore }); |
477 |
|
} |
478 |
|
else |
479 |
|
{ |
480 |
|
startMethod.invoke(null, new Object[] |
481 |
|
{ tstore.getAndClear() }); |
482 |
|
} |
483 |
|
|
484 |
|
//--- Let the user know how many warnings/errors occured |
485 |
|
|
486 |
|
if (reporter.getWarningCount() > 0) |
487 |
|
{ |
488 |
|
System.err.println(reporter.getWarningCount() + " warnings"); |
489 |
|
} |
490 |
|
|
491 |
|
if (reporter.getErrorCount() > 0) |
492 |
|
{ |
493 |
|
System.err.println(reporter.getErrorCount() + " errors"); |
494 |
|
} |
495 |
|
|
496 |
|
System.gc(); |
497 |
|
|
498 |
|
//--- Done. |
499 |
|
} |
500 |
|
catch (Exception e) |
501 |
|
{ |
502 |
|
e.printStackTrace(); |
503 |
|
} |
504 |
|
} |
505 |
|
|
506 |
|
/** |
507 |
|
* |
508 |
|
*/ |
509 |
|
private static boolean validOptions(String options[][], |
510 |
|
DocErrorReporter reporter) |
511 |
|
{ |
512 |
|
|
513 |
|
boolean foundDocletOption = false; |
514 |
|
for (int i = 0; i < options.length; i++) |
515 |
|
{ |
516 |
|
String[] opt = options[i]; |
517 |
|
if (opt[0].equals("-doclet")) |
518 |
|
{ |
519 |
|
if (foundDocletOption) |
520 |
|
{ |
521 |
|
reporter.printError("Only one -doclet option allowed."); |
522 |
|
return false; |
523 |
|
} |
524 |
|
else |
525 |
|
{ |
526 |
|
foundDocletOption = true; |
527 |
|
} |
528 |
|
} |
529 |
|
} |
530 |
|
|
531 |
|
return true; |
532 |
|
} |
533 |
|
|
534 |
|
/** |
535 |
|
* Main entry point. This is the method called when gjdoc is invoked from the |
536 |
|
* command line. |
537 |
|
* |
538 |
|
* @param args |
539 |
|
* command line arguments |
540 |
|
*/ |
541 |
|
public static void main(String[] args) |
542 |
|
{ |
543 |
|
|
544 |
|
try |
545 |
|
{ |
546 |
|
|
547 |
|
//--- For testing purposes only |
548 |
|
|
549 |
|
//System.err.println("getting locale..."); |
550 |
|
//java.util.Locale loc = java.util.Locale.getDefault(); |
551 |
|
//System.err.println("locale="+loc.getLanguage()+" |
552 |
|
// ("+loc.getDefault()+"), "+loc.getLanguage()+", "+loc.getVariant()+", |
553 |
|
// "+loc.getCountry()); |
554 |
|
|
555 |
|
//--- Remember current time for profiling purposes |
556 |
|
|
557 |
|
Timer.setStartTime(); |
558 |
|
|
559 |
|
//--- Handle control to the Singleton instance of this class |
560 |
|
|
561 |
|
instance.start(args); |
562 |
|
} |
563 |
|
catch (Exception e) |
564 |
|
{ |
565 |
|
|
566 |
|
//--- Report any error |
567 |
|
|
568 |
|
e.printStackTrace(); |
569 |
|
} |
570 |
|
} |
571 |
|
|
572 |
|
/** |
573 |
|
* Parses command line arguments and subsequentially handles control to the |
574 |
|
* startDoclet() method |
575 |
|
* |
576 |
|
* @param args |
577 |
|
* Command line arguments, as passed to the main() method |
578 |
|
* @exception ParseException |
579 |
|
* FIXME |
580 |
|
* @exception IOException |
581 |
|
* if an IO problem occur |
582 |
|
*/ |
583 |
|
public void start(String[] args) throws ParseException, IOException |
584 |
|
{ |
585 |
|
|
586 |
|
//--- Collect unparsed arguments in array and resolve references |
587 |
|
// to external argument files. |
588 |
|
|
589 |
|
List arguments = new ArrayList(args.length); |
590 |
|
|
591 |
|
for (int i = 0; i < args.length; ++i) |
592 |
|
{ |
593 |
|
if (!args[i].startsWith("@")) |
594 |
|
{ |
595 |
|
arguments.add(args[i]); |
596 |
|
} |
597 |
|
else |
598 |
|
{ |
599 |
|
FileReader reader = new FileReader(args[i].substring(1)); |
600 |
|
StreamTokenizer st = new StreamTokenizer(reader); |
601 |
|
st.resetSyntax(); |
602 |
|
st.wordChars('\u0000', '\uffff'); |
603 |
|
st.quoteChar('\"'); |
604 |
|
st.whitespaceChars(' ', ' '); |
605 |
|
st.whitespaceChars('\t', '\t'); |
606 |
|
st.whitespaceChars('\r', '\r'); |
607 |
|
st.whitespaceChars('\n', '\n'); |
608 |
|
while (st.nextToken() != StreamTokenizer.TT_EOF) |
609 |
|
{ |
610 |
|
arguments.add(st.sval); |
611 |
|
} |
612 |
|
} |
613 |
|
} |
614 |
|
|
615 |
|
//--- Initialize Map for option parsing |
616 |
|
|
617 |
|
initOptions(); |
618 |
|
|
619 |
|
//--- This will hold all options recognized by gjdoc itself |
620 |
|
// and their associated arguments. |
621 |
|
// Contains objects of type String[], where each entry |
622 |
|
// specifies an option along with its aguments. |
623 |
|
|
624 |
|
List options = new LinkedList(); |
625 |
|
|
626 |
|
//--- This will hold all command line tokens not recognized |
627 |
|
// to be part of a standard option. |
628 |
|
// These options are intended to be processed by the doclet |
629 |
|
// Contains objects of type String, where each entry is |
630 |
|
// one unrecognized token. |
631 |
|
|
632 |
|
List customOptions = new LinkedList(); |
633 |
|
|
634 |
|
rootDoc = new RootDocImpl(); |
635 |
|
reporter = rootDoc.getReporter(); |
636 |
|
|
637 |
|
//--- Iterate over all options given on the command line |
638 |
|
|
639 |
|
for (Iterator it = arguments.iterator(); it.hasNext();) |
640 |
|
{ |
641 |
|
|
642 |
|
String arg = (String) it.next(); |
643 |
|
|
644 |
|
//--- Check if gjdoc recognizes this option as a standard option |
645 |
|
// and remember the options' argument count |
646 |
|
|
647 |
|
int optlen = optionLength(arg); |
648 |
|
|
649 |
|
//--- Argument count == 0 indicates that the option is not recognized. |
650 |
|
// Add it to the list of custom option tokens |
651 |
|
|
652 |
|
if (optlen == 0) |
653 |
|
{ |
654 |
|
customOptions.add(arg); |
655 |
|
} |
656 |
|
|
657 |
|
//--- Otherwise the option is recognized as a standard option. |
658 |
|
// if all required arguments are supplied. Create a new String |
659 |
|
// array for the option and its arguments, and store it |
660 |
|
// in the options array. |
661 |
|
|
|
/** |
|
|
* Do we load classes that are referenced as base |
|
|
* class? |
|
|
*/ |
|
|
static final boolean DESCEND_SUPERCLASS = true; |
|
|
|
|
|
/** |
|
|
* Do we load classes that are referenced as |
|
|
* interface? |
|
|
*/ |
|
|
static final boolean DESCEND_INTERFACES = false; |
|
|
|
|
|
/** |
|
|
* Do we load classes that are imported in a |
|
|
* source file? |
|
|
*/ |
|
|
static final boolean DESCEND_IMPORTED = true; |
|
|
|
|
|
/** |
|
|
* Document only public members. |
|
|
*/ |
|
|
static final int COVERAGE_PUBLIC = 0; |
|
|
|
|
|
/** |
|
|
* Document only public and protected members. |
|
|
*/ |
|
|
static final int COVERAGE_PROTECTED = 1; |
|
|
|
|
|
/** |
|
|
* Document public, protected and package private members. |
|
|
*/ |
|
|
static final int COVERAGE_PACKAGE = 2; |
|
|
|
|
|
/** |
|
|
* Document all members. |
|
|
*/ |
|
|
static final int COVERAGE_PRIVATE = 3; |
|
|
|
|
|
/** |
|
|
* Grid for looking up whether a particular access level |
|
|
* is included in the documentation. |
|
|
*/ |
|
|
static final boolean[][] coverageTemplates = new boolean[][] { |
|
|
new boolean[] { true, false, false, false }, // public |
|
|
new boolean[] { true, true, false, false }, // protected |
|
|
new boolean[] { true, true, true, false }, // package |
|
|
new boolean[] { true, true, true, true }, // private |
|
|
}; |
|
|
|
|
|
/** |
|
|
* Holds the Singleton instance of this class. |
|
|
*/ |
|
|
private static Main instance = new Main(); |
|
|
|
|
|
/** |
|
|
* Avoid re-instantiation of this class. |
|
|
*/ |
|
|
private Main() {} |
|
|
|
|
|
private static RootDocImpl rootDoc; |
|
|
|
|
|
private ErrorReporter reporter; |
|
|
|
|
|
/** |
|
|
* <code>false</code> during Phase I: preparation |
|
|
* of the documentation data. <code>true</code> |
|
|
* during Phase II: documentation output by doclet. |
|
|
*/ |
|
|
boolean docletRunning=false; |
|
|
|
|
|
//---- Command line options |
|
|
|
|
|
/** |
|
|
* Option "-doclet": name of the Doclet class to use. |
|
|
*/ |
|
|
private String option_doclet = "gnu.classpath.tools.doclets.xmldoclet.Driver"; |
|
|
|
|
|
/** |
|
|
* Option "-overview": path to the special overview file. |
|
|
*/ |
|
|
private String option_overview; |
|
|
|
|
|
/** |
|
|
* Option "-coverage": which members to include in generated documentation. |
|
|
*/ |
|
|
private int option_coverage = COVERAGE_PROTECTED; |
|
|
|
|
|
/** |
|
|
* Option "-help": display command line usage. |
|
|
*/ |
|
|
private boolean option_help; |
|
|
|
|
|
/** |
|
|
* Option "-docletpath": path to doclet classes. |
|
|
*/ |
|
|
private String option_docletpath; |
|
|
|
|
|
/** |
|
|
* Option "-classpath": path to additional classes. |
|
|
*/ |
|
|
private String option_classpath; |
|
|
|
|
|
/** |
|
|
* Option "-sourcepath": path to the Java source files to be documented. |
|
|
* FIXME: this should be a list of paths |
|
|
*/ |
|
|
private List option_sourcepath = new ArrayList(); |
|
|
|
|
|
/** |
|
|
* Option "-bootclasspath": path to Java bootstrap classes. |
|
|
*/ |
|
|
private String option_bootclasspath; |
|
|
|
|
|
/** |
|
|
* Option "-extdirs": path to Java extension files. |
|
|
*/ |
|
|
private String option_extdirs; |
|
|
|
|
|
/** |
|
|
* Option "-verbose": Be verbose when generating documentation. |
|
|
*/ |
|
|
private boolean option_verbose; |
|
|
|
|
|
/** |
|
|
* Option "-nowarn": Do not print warnings. |
|
|
*/ |
|
|
private boolean option_nowarn; |
|
|
|
|
|
/** |
|
|
* Option "-locale:" Specify the locale charset of Java source files. |
|
|
*/ |
|
|
private String option_locale; |
|
|
|
|
|
/** |
|
|
* Option "-encoding": Specify character encoding of Java source files. |
|
|
*/ |
|
|
private String option_encoding; |
|
|
|
|
|
/** |
|
|
* Option "-J": Specify flags to be passed to Java runtime. |
|
|
*/ |
|
|
private List option_java_flags = new LinkedList(); //ArrayList(); |
|
|
|
|
|
/** |
|
|
* Parse all source files/packages and subsequentially |
|
|
* start the Doclet given on the command line. |
|
|
* |
|
|
* @param customOptions List of unrecognized command line tokens |
|
|
*/ |
|
|
private void startDoclet(List customOptions) { |
|
|
|
|
|
try { |
|
|
|
|
|
//--- Fetch the Class object for the Doclet. |
|
|
|
|
|
Debug.log(1, "loading doclet class..."); |
|
|
|
|
|
Class docletClass = Class.forName(option_doclet); |
|
|
//Object docletInstance = docletClass.newInstance(); |
|
|
|
|
|
Debug.log(1, "doclet class loaded..."); |
|
|
|
|
|
Method startTempMethod=null; |
|
|
Method startMethod=null; |
|
|
Method optionLenMethod=null; |
|
|
Method validOptionsMethod=null; |
|
|
|
|
|
//--- Try to find the optionLength method in the Doclet class. |
|
|
|
|
|
try { |
|
|
optionLenMethod = docletClass.getMethod("optionLength", new Class[]{String.class}); |
|
|
} |
|
|
catch (NoSuchMethodException e) { |
|
|
// Ignore if not found; it's OK it the Doclet class doesn't define this method. |
|
|
} |
|
|
|
|
|
//--- Try to find the validOptions method in the Doclet class. |
|
|
|
|
|
try { |
|
|
validOptionsMethod = docletClass.getMethod("validOptions", new Class[]{String[][].class, DocErrorReporter.class}); |
|
|
} |
|
|
catch (NoSuchMethodException e) { |
|
|
// Ignore if not found; it's OK it the Doclet class doesn't define this method. |
|
|
} |
|
|
|
|
|
//--- Find the start method in the Doclet class; complain if not found |
|
|
|
|
|
try { |
|
|
startTempMethod = docletClass.getMethod("start", new Class[]{TemporaryStore.class}); |
|
|
} |
|
|
catch (Exception e) { |
|
|
// ignore |
|
|
} |
|
|
startMethod = docletClass.getMethod("start", new Class[]{RootDoc.class}); |
|
|
|
|
|
//--- Feed the custom command line tokens to the Doclet |
|
|
|
|
|
// stores all recognized options |
|
|
List options = new LinkedList(); |
|
|
|
|
|
// stores packages and classes defined on the command line |
|
|
List packageAndClasses = new LinkedList(); |
|
|
|
|
|
for (Iterator it = customOptions.iterator(); it.hasNext(); ) { |
|
|
String option = (String)it.next(); |
|
|
|
|
|
Debug.log(9, "parsing option '"+option+"'"); |
|
|
|
|
|
if (option.startsWith("-")) { |
|
|
|
|
|
//--- Parse option |
|
|
|
|
|
int optlen=0; |
|
|
|
|
|
//--- Try to get option length from Doclet class |
|
|
|
|
|
if (optionLenMethod!=null) { |
|
|
|
|
|
optionLenMethod.invoke(null, new Object[]{option}); |
|
|
|
|
|
Debug.log(3, "invoking optionLen method"); |
|
|
|
|
|
optlen=((Integer)optionLenMethod.invoke(null, new Object[]{option})).intValue(); |
|
|
|
|
|
Debug.log(3, "done"); |
|
|
} |
|
|
|
|
|
if (optlen<=0) { |
|
|
|
|
|
//--- Complain if not found |
|
|
|
|
|
reporter.printError("Unknown option "+option); |
|
|
shutdown(); |
|
|
} |
|
|
else { |
|
|
|
|
|
//--- Read option values |
|
|
|
|
|
String[] optionAndValues=new String[optlen]; |
|
|
optionAndValues[0]=option; |
|
|
for (int i=1; i<optlen; ++i) { |
|
|
if (!it.hasNext()) { |
|
|
reporter.printError("Missing value for option "+option); |
|
|
shutdown(); |
|
|
} |
|
|
else { |
|
|
optionAndValues[i]=(String)it.next(); |
|
|
} |
|
|
} |
|
|
|
|
|
//--- Store option for processing later |
|
|
|
|
|
options.add(optionAndValues); |
|
|
} |
|
|
} |
|
|
else { |
|
|
|
|
|
//--- Add to list of packages/classes if not option or option value |
|
|
|
|
|
packageAndClasses.add(option); |
|
|
} |
|
|
} |
|
|
|
|
|
Debug.log(9, "options parsed..."); |
|
|
|
|
|
|
|
|
//--- Complain if no packages or classes specified |
|
|
|
|
|
if (packageAndClasses.isEmpty()) { |
|
|
reporter.printError("No packages or classes specified."); |
|
|
usage(); |
|
|
shutdown(); |
|
|
} |
|
|
|
|
|
//--- For each class or package specified on the command line, |
|
|
// check that it exists and find out whether it is a class |
|
|
// or a package |
|
|
|
|
|
for (Iterator it=packageAndClasses.iterator(); it.hasNext(); ) { |
|
|
|
|
|
String classOrPackage=(String)it.next(); |
|
|
|
|
|
//--- Check for illegal name |
|
|
|
|
|
if (classOrPackage.startsWith(".") |
|
|
|| classOrPackage.endsWith(".") |
|
|
|| classOrPackage.indexOf("..")>0 |
|
|
|| !checkCharSet(classOrPackage,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_.")) { |
|
|
throw new ParseException("Illegal class or package name '"+classOrPackage+"'"); |
|
|
} |
|
|
|
|
|
//--- Assemble absolute path to package |
|
|
|
|
|
String classOrPackageRelPath = classOrPackage.replace('.', File.separatorChar); |
|
|
|
|
|
//--- Create one file object each for a possible package directory |
|
|
// and a possible class file, and find out if they exist. |
|
|
|
|
|
File packageDir = rootDoc.findSourceFile(classOrPackageRelPath); |
|
|
File sourceFile = rootDoc.findSourceFile(classOrPackageRelPath+".java"); |
|
|
|
|
|
boolean packageDirExists = packageDir!=null && packageDir.exists() |
|
|
&& packageDir.getCanonicalFile().getAbsolutePath().endsWith(classOrPackageRelPath); |
|
|
|
|
|
boolean sourceFileExists = sourceFile!=null && sourceFile.exists() |
|
|
&& sourceFile.getCanonicalFile().getAbsolutePath().endsWith(classOrPackageRelPath+".java"); |
|
|
|
|
|
//--- Complain if neither exists: not found |
|
|
|
|
|
if (!packageDirExists && !sourceFileExists) { |
|
|
reporter.printError("Class or package "+classOrPackage+" not found."); |
|
|
shutdown(); |
|
|
} |
|
|
|
|
|
//--- Complain if both exist: ambigious |
|
|
|
|
|
else if (packageDirExists && sourceFileExists) { |
|
|
reporter.printError("Ambigious class/package name "+classOrPackage+"."); |
|
|
shutdown(); |
|
|
} |
|
|
|
|
|
//--- Otherwise, if the package directory exists, it is a package |
|
|
|
|
|
else if (packageDirExists) { |
|
|
if (!packageDir.isDirectory()) { |
|
|
reporter.printError("File \""+packageDir+"\" doesn't have .java extension."); |
|
|
shutdown(); |
|
|
} |
|
|
else { |
|
|
rootDoc.addSpecifiedPackageName(classOrPackage); |
|
|
} |
|
|
} |
|
|
|
|
|
//--- Otherwise, it must be a Java source file file |
|
|
|
|
|
else /* if (sourceFileExists) */ { |
|
|
if (sourceFile.isDirectory()) { |
|
|
reporter.printError("File \""+sourceFile+"\" is a directory!"); |
|
|
shutdown(); |
|
|
} |
|
|
else { |
|
|
rootDoc.addSpecifiedClassName(classOrPackage); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
//--- Validate custom options passed on command line |
|
|
// by asking the Doclet if they are OK. |
|
|
|
|
|
String[][] customOptionArr=(String[][])options.toArray(new String[0][0]); |
|
|
if (validOptionsMethod!=null |
|
|
&& !((Boolean)validOptionsMethod.invoke(null, |
|
|
new Object[]{customOptionArr, |
|
|
this})).booleanValue()) { |
|
|
// Not ok: shutdown system. |
|
|
shutdown(); |
|
|
} |
|
|
|
|
|
rootDoc.setOptions(customOptionArr); |
|
|
|
|
|
rootDoc.build(); |
|
|
|
|
|
//--- Our work is done, tidy up memory |
|
|
|
|
|
System.gc(); |
|
|
System.gc(); |
|
|
|
|
|
//--- Set flag indicating Phase II of documentation generation |
|
|
|
|
|
docletRunning=true; |
|
|
|
|
|
//--- Invoke the start method on the Doclet: produce output |
|
|
|
|
|
reporter.printNotice("Running doclet..."); |
|
|
|
|
|
TemporaryStore tstore = new TemporaryStore(this.rootDoc); |
|
|
|
|
|
if (null != startTempMethod) { |
|
|
startTempMethod.invoke(null, new Object[]{ tstore }); |
|
|
} |
|
|
else { |
|
|
startMethod.invoke(null, new Object[]{ tstore.getAndClear() }); |
|
|
} |
|
|
|
|
|
//--- Let the user know how many warnings/errors occured |
|
|
|
|
|
if (reporter.getWarningCount()>0) { |
|
|
System.err.println(reporter.getWarningCount()+" warnings"); |
|
|
} |
|
|
|
|
|
if (reporter.getErrorCount()>0) { |
|
|
System.err.println(reporter.getErrorCount()+" errors"); |
|
|
} |
|
|
|
|
|
System.gc(); |
|
|
|
|
|
//--- Done. |
|
|
} |
|
|
catch (Exception e) { |
|
|
e.printStackTrace(); |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
* |
|
|
*/ |
|
|
private static boolean validOptions(String options[][], |
|
|
DocErrorReporter reporter) { |
|
|
|
|
|
boolean foundDocletOption = false; |
|
|
for (int i = 0; i < options.length; i++) { |
|
|
String[] opt = options[i]; |
|
|
if (opt[0].equals("-doclet")) { |
|
|
if (foundDocletOption) { |
|
|
reporter.printError("Only one -doclet option allowed."); |
|
|
return false; |
|
|
} else { |
|
|
foundDocletOption = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
return true; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Main entry point. |
|
|
* |
|
|
* This is the method called when gjdoc is invoked |
|
|
* from the command line. |
|
|
*/ |
|
|
public static void main(String[] args) { |
|
|
|
|
|
try { |
|
|
|
|
|
//--- For testing purposes only |
|
|
|
|
|
//System.err.println("getting locale..."); |
|
|
//java.util.Locale loc = java.util.Locale.getDefault(); |
|
|
//System.err.println("locale="+loc.getLanguage()+" ("+loc.getDefault()+"), "+loc.getLanguage()+", "+loc.getVariant()+", "+loc.getCountry()); |
|
|
|
|
|
//--- Remember current time for profiling purposes |
|
|
|
|
|
Timer.setStartTime(); |
|
|
|
|
|
//--- Handle control to the Singleton instance of this class |
|
|
|
|
|
instance.start(args); |
|
|
} |
|
|
catch (Exception e) { |
|
|
|
|
|
//--- Report any error |
|
|
|
|
|
e.printStackTrace(); |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
* Parses command line arguments and subsequentially |
|
|
* handles control to the startDoclet() method |
|
|
* |
|
|
* @param args Command line arguments, as passed to the main() method |
|
|
*/ |
|
|
public void start(String[] args) throws ParseException, IOException { |
|
|
|
|
|
//--- Collect unparsed arguments in array and resolve references |
|
|
// to external argument files. |
|
|
|
|
|
List arguments = new ArrayList(args.length); |
|
|
|
|
|
for (int i=0; i<args.length; ++i) { |
|
|
if (!args[i].startsWith("@")) { |
|
|
arguments.add(args[i]); |
|
|
} |
|
|
else { |
|
|
FileReader reader = new FileReader(args[i].substring(1)); |
|
|
StreamTokenizer st = new StreamTokenizer(reader); |
|
|
st.resetSyntax(); |
|
|
st.wordChars('\u0000', '\uffff'); |
|
|
st.quoteChar('\"'); |
|
|
st.whitespaceChars(' ', ' '); |
|
|
st.whitespaceChars('\t', '\t'); |
|
|
st.whitespaceChars('\r', '\r'); |
|
|
st.whitespaceChars('\n', '\n'); |
|
|
while (st.nextToken() != StreamTokenizer.TT_EOF) { |
|
|
arguments.add(st.sval); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
//--- Initialize Map for option parsing |
|
|
|
|
|
initOptions(); |
|
|
|
|
|
//--- This will hold all options recognized by gjdoc itself |
|
|
// and their associated arguments. |
|
|
// Contains objects of type String[], where each entry |
|
|
// specifies an option along with its aguments. |
|
|
|
|
|
List options=new LinkedList(); |
|
|
|
|
|
//--- This will hold all command line tokens not recognized |
|
|
// to be part of a standard option. |
|
|
// These options are intended to be processed by the doclet |
|
|
// Contains objects of type String, where each entry is |
|
|
// one unrecognized token. |
|
|
|
|
|
List customOptions=new LinkedList(); |
|
|
|
|
|
|
|
|
rootDoc = new RootDocImpl(); |
|
|
reporter = rootDoc.getReporter(); |
|
|
|
|
|
//--- Iterate over all options given on the command line |
|
|
|
|
|
for (Iterator it = arguments.iterator(); it.hasNext(); ) { |
|
|
|
|
|
String arg = (String)it.next(); |
|
|
|
|
|
//--- Check if gjdoc recognizes this option as a standard option |
|
|
// and remember the options' argument count |
|
|
|
|
|
int optlen = optionLength(arg); |
|
|
|
|
|
//--- Argument count == 0 indicates that the option is not recognized. |
|
|
// Add it to the list of custom option tokens |
|
|
|
|
|
if (optlen == 0) { |
|
|
customOptions.add(arg); |
|
|
} |
|
|
|
|
|
//--- Otherwise the option is recognized as a standard option. |
|
|
// if all required arguments are supplied. Create a new String |
|
|
// array for the option and its arguments, and store it |
|
|
// in the options array. |
|
|
|
|
|
else { |
|
|
String[] option=new String[optlen]; |
|
|
option[0] = arg; |
|
|
boolean optargs_ok = true; |
|
|
for (int j=1; j<optlen && optargs_ok; ++j) { |
|
|
if (it.hasNext()) { |
|
|
option[j] = (String)it.next(); |
|
|
if (option[j].startsWith("-")) { |
|
|
optargs_ok = false; |
|
|
} |
|
|
} |
|
|
else { |
|
|
optargs_ok = false; |
|
|
} |
|
|
} |
|
|
if (optargs_ok) |
|
|
options.add(option); |
|
|
else { |
|
|
// If the option requires more arguments than given on the |
|
|
// command line, issue a fatal error |
|
|
|
|
|
reporter.printFatal("Missing value for option "+arg+"."); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
//--- Create an array of String arrays from the dynamic array built above |
|
|
|
|
|
String[][] optionArr=(String[][])options.toArray(new String[options.size()][0]); |
|
|
|
|
|
//--- Validate all options and issue warnings/errors |
|
|
|
|
|
if (validOptions(optionArr, rootDoc)) { |
|
|
|
|
|
//--- We got valid options; parse them and store the parsed values |
|
|
// in 'option_*' fields. |
|
|
|
|
|
readOptions(optionArr); |
|
|
|
|
|
// If we have an empty source path list, add the current directory ('.') |
|
|
|
|
|
if (option_sourcepath.size()==0) option_sourcepath.add(new File(".")); |
|
|
|
|
|
//--- We have all information we need to start the doclet at this time |
|
|
|
|
|
rootDoc.setSourcePath(option_sourcepath); |
|
|
|
|
|
startDoclet(customOptions); |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
* Helper class for parsing command line arguments. |
|
|
* An instance of this class represents a particular |
|
|
* option accepted by gjdoc (e.g. '-sourcepath') |
|
|
* along with the number of expected arguments and |
|
|
* behavior to parse the arguments. |
|
|
*/ |
|
|
private abstract class OptionProcessor { |
|
|
|
|
|
/** |
|
|
* Number of arguments expected by this option. |
|
|
*/ |
|
|
private int argCount; |
|
|
|
|
|
/** |
|
|
* Initializes this instance. |
|
|
*/ |
|
|
public OptionProcessor(int argCount) { |
|
|
this.argCount=argCount; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Overridden by derived classes with behavior |
|
|
* to parse the arguments specified with this |
|
|
* option. |
|
|
*/ |
|
|
abstract void process(String[] args); |
|
|
} |
|
|
|
|
|
/** |
|
|
* Maps option tags (e.g. '-sourcepath') to |
|
|
* OptionProcessor objects. Initialized only once |
|
|
* by method initOptions(). |
|
|
* FIXME: Rename to 'optionProcessors'. |
|
|
*/ |
|
|
private static Map options = null; |
|
|
|
|
|
/** |
|
|
* Initialize all OptionProcessor objects needed |
|
|
* to scan/parse command line options. |
|
|
* |
|
|
* This cannot be done in a static initializer block |
|
|
* because OptionProcessors need access to the |
|
|
* Singleton instance of the Main class. |
|
|
*/ |
|
|
private void initOptions() { |
|
|
|
|
|
options = new HashMap(); |
|
|
|
|
|
//--- Put one OptionProcessor object into the map |
|
|
// for each option recognized. |
|
|
|
|
|
options.put("-overview", new OptionProcessor(2) { |
|
|
void process(String[] args) { option_overview = args[0]; } |
|
|
}); |
|
|
options.put("-public", new OptionProcessor(1) { |
|
|
void process(String[] args) { option_coverage = COVERAGE_PUBLIC; } |
|
|
}); |
|
|
options.put("-protected", new OptionProcessor(1) { |
|
|
void process(String[] args) { |
|
|
option_coverage = COVERAGE_PROTECTED; |
|
|
} |
|
|
}); |
|
|
options.put("-package", new OptionProcessor(1) { |
|
|
void process(String[] args) { |
|
|
option_coverage = COVERAGE_PACKAGE; |
|
|
} |
|
|
}); |
|
|
options.put("-private", new OptionProcessor(1) { |
|
|
void process(String[] args) { |
|
|
option_coverage = COVERAGE_PRIVATE; |
|
|
} |
|
|
}); |
|
|
options.put("-help", new OptionProcessor(1) { |
|
|
void process(String[] args) { |
|
|
option_help = true; |
|
|
} |
|
|
}); |
|
|
options.put("-doclet", new OptionProcessor(2) { |
|
|
void process(String[] args) { |
|
|
option_doclet = args[0]; |
|
|
} |
|
|
}); |
|
|
options.put("-nowarn", new OptionProcessor(1) { |
|
|
void process(String[] args) { |
|
|
option_nowarn = true; |
|
|
} |
|
|
}); |
|
|
options.put("-sourcepath", new OptionProcessor(2) { |
|
|
void process(String[] args) { |
|
|
Debug.log(1, "-sourcepath is '"+args[0]+"'"); |
|
|
for (StringTokenizer st=new StringTokenizer(args[0], File.pathSeparator); st.hasMoreTokens(); ) { |
|
|
String path = st.nextToken(); |
|
|
File file = new File(path); |
|
|
if (!(file.exists())) { |
|
|
throw new RuntimeException("The source path " + path + " does not exist."); |
|
|
} |
|
|
option_sourcepath.add(file); |
|
|
} |
|
|
} |
|
|
}); |
|
|
options.put("-verbose", new OptionProcessor(1) { |
|
|
void process(String[] args) { |
|
|
option_verbose = true; |
|
|
} |
|
|
}); |
|
|
options.put("-locale", new OptionProcessor(1) { |
|
|
void process(String[] args) { |
|
|
option_locale = args[0]; |
|
|
} |
|
|
}); |
|
|
options.put("-encoding", new OptionProcessor(1) { |
|
|
void process(String[] args) { |
|
|
option_encoding = args[0]; |
|
|
} |
|
|
}); |
|
|
} |
|
|
|
|
|
/** |
|
|
* Determine how many arguments the given option |
|
|
* requires. |
|
|
* |
|
|
* @param option The name of the option without leading dash. |
|
|
*/ |
|
|
private static int optionLength(String option) { |
|
|
|
|
|
OptionProcessor op=(OptionProcessor)options.get(option); |
|
|
if (op!=null) |
|
|
return op.argCount; |
|
662 |
else |
else |
663 |
return 0; |
{ |
664 |
} |
String[] option = new String[optlen]; |
665 |
|
option[0] = arg; |
666 |
|
boolean optargs_ok = true; |
667 |
|
for (int j = 1; j < optlen && optargs_ok; ++j) |
668 |
|
{ |
669 |
|
if (it.hasNext()) |
670 |
|
{ |
671 |
|
option[j] = (String) it.next(); |
672 |
|
if (option[j].startsWith("-")) |
673 |
|
{ |
674 |
|
optargs_ok = false; |
675 |
|
} |
676 |
|
} |
677 |
|
else |
678 |
|
{ |
679 |
|
optargs_ok = false; |
680 |
|
} |
681 |
|
} |
682 |
|
if (optargs_ok) |
683 |
|
options.add(option); |
684 |
|
else |
685 |
|
{ |
686 |
|
// If the option requires more arguments than given on the |
687 |
|
// command line, issue a fatal error |
688 |
|
|
689 |
|
reporter.printFatal("Missing value for option " + arg + "."); |
690 |
|
} |
691 |
|
} |
692 |
|
} |
693 |
|
|
694 |
|
//--- Create an array of String arrays from the dynamic array built above |
695 |
|
|
696 |
|
String[][] optionArr = (String[][]) options.toArray(new String[options |
697 |
|
.size()][0]); |
698 |
|
|
699 |
|
//--- Validate all options and issue warnings/errors |
700 |
|
|
701 |
|
if (validOptions(optionArr, rootDoc)) |
702 |
|
{ |
703 |
|
|
704 |
|
//--- We got valid options; parse them and store the parsed values |
705 |
|
// in 'option_*' fields. |
706 |
|
|
707 |
|
readOptions(optionArr); |
708 |
|
|
709 |
|
// If we have an empty source path list, add the current directory ('.') |
710 |
|
|
711 |
|
if (option_sourcepath.size() == 0) |
712 |
|
option_sourcepath.add(new File(".")); |
713 |
|
|
714 |
|
//--- We have all information we need to start the doclet at this time |
715 |
|
|
716 |
|
rootDoc.setSourcePath(option_sourcepath); |
717 |
|
|
718 |
|
startDoclet(customOptions); |
719 |
|
} |
720 |
|
} |
721 |
|
|
722 |
|
/** |
723 |
|
* Helper class for parsing command line arguments. An instance of this class |
724 |
|
* represents a particular option accepted by gjdoc (e.g. '-sourcepath') along |
725 |
|
* with the number of expected arguments and behavior to parse the arguments. |
726 |
|
*/ |
727 |
|
private abstract class OptionProcessor |
728 |
|
{ |
729 |
|
|
730 |
|
/** |
731 |
|
* Number of arguments expected by this option. |
732 |
|
*/ |
733 |
|
private int argCount; |
734 |
|
|
735 |
|
/** |
736 |
|
* Initializes this instance. |
737 |
|
* |
738 |
|
* @param argCount |
739 |
|
* number of arguments |
740 |
|
*/ |
741 |
|
public OptionProcessor(int argCount) |
742 |
|
{ |
743 |
|
this.argCount = argCount; |
744 |
|
} |
745 |
|
|
746 |
|
/** |
747 |
|
* Overridden by derived classes with behavior to parse the arguments |
748 |
|
* specified with this option. |
749 |
|
* |
750 |
|
* @param args |
751 |
|
* command line arguments |
752 |
|
*/ |
753 |
|
abstract void process(String[] args); |
754 |
|
} |
755 |
|
|
756 |
|
/** |
757 |
|
* Maps option tags (e.g. '-sourcepath') to OptionProcessor objects. |
758 |
|
* Initialized only once by method initOptions(). FIXME: Rename to |
759 |
|
* 'optionProcessors'. |
760 |
|
*/ |
761 |
|
private static Map options = null; |
762 |
|
|
763 |
|
/** |
764 |
|
* Initialize all OptionProcessor objects needed to scan/parse command line |
765 |
|
* options. This cannot be done in a static initializer block because |
766 |
|
* OptionProcessors need access to the Singleton instance of the Main class. |
767 |
|
*/ |
768 |
|
private void initOptions() |
769 |
|
{ |
770 |
|
|
771 |
|
options = new HashMap(); |
772 |
|
|
773 |
|
//--- Put one OptionProcessor object into the map |
774 |
|
// for each option recognized. |
775 |
|
|
776 |
|
options.put("-overview", new OptionProcessor(2) |
777 |
|
{ |
778 |
|
|
779 |
|
void process(String[] args) |
780 |
|
{ |
781 |
|
option_overview = args[0]; |
782 |
|
} |
783 |
|
}); |
784 |
|
options.put("-public", new OptionProcessor(1) |
785 |
|
{ |
786 |
|
|
787 |
|
void process(String[] args) |
788 |
|
{ |
789 |
|
option_coverage = COVERAGE_PUBLIC; |
790 |
|
} |
791 |
|
}); |
792 |
|
options.put("-protected", new OptionProcessor(1) |
793 |
|
{ |
794 |
|
|
795 |
|
void process(String[] args) |
796 |
|
{ |
797 |
|
option_coverage = COVERAGE_PROTECTED; |
798 |
|
} |
799 |
|
}); |
800 |
|
options.put("-package", new OptionProcessor(1) |
801 |
|
{ |
802 |
|
|
803 |
|
void process(String[] args) |
804 |
|
{ |
805 |
|
option_coverage = COVERAGE_PACKAGE; |
806 |
|
} |
807 |
|
}); |
808 |
|
options.put("-private", new OptionProcessor(1) |
809 |
|
{ |
810 |
|
|
811 |
|
void process(String[] args) |
812 |
|
{ |
813 |
|
option_coverage = COVERAGE_PRIVATE; |
814 |
|
} |
815 |
|
}); |
816 |
|
options.put("-help", new OptionProcessor(1) |
817 |
|
{ |
818 |
|
|
819 |
|
void process(String[] args) |
820 |
|
{ |
821 |
|
option_help = true; |
822 |
|
} |
823 |
|
}); |
824 |
|
options.put("-doclet", new OptionProcessor(2) |
825 |
|
{ |
826 |
|
|
827 |
|
void process(String[] args) |
828 |
|
{ |
829 |
|
option_doclet = args[0]; |
830 |
|
} |
831 |
|
}); |
832 |
|
options.put("-docletpath", new OptionProcessor(2) |
833 |
|
{ |
834 |
|
|
835 |
|
void process(String[] args) |
836 |
|
{ |
837 |
|
option_docletpath = args[0]; |
838 |
|
} |
839 |
|
}); |
840 |
|
options.put("-nowarn", new OptionProcessor(1) |
841 |
|
{ |
842 |
|
|
843 |
|
void process(String[] args) |
844 |
|
{ |
845 |
|
option_nowarn = true; |
846 |
|
} |
847 |
|
}); |
848 |
|
options.put("-source", new OptionProcessor(2) |
849 |
|
{ |
850 |
|
|
851 |
|
void process(String[] args) |
852 |
|
{ |
853 |
|
option_source = args[0]; |
854 |
|
} |
855 |
|
}); |
856 |
|
options.put("-sourcepath", new OptionProcessor(2) |
857 |
|
{ |
858 |
|
|
859 |
|
void process(String[] args) |
860 |
|
{ |
861 |
|
Debug.log(1, "-sourcepath is '" + args[0] + "'"); |
862 |
|
for (StringTokenizer st = new StringTokenizer(args[0], |
863 |
|
File.pathSeparator); st.hasMoreTokens();) |
864 |
|
{ |
865 |
|
String path = st.nextToken(); |
866 |
|
File file = new File(path); |
867 |
|
if (!(file.exists())) |
868 |
|
{ |
869 |
|
throw new RuntimeException("The source path " + path |
870 |
|
+ " does not exist."); |
871 |
|
} |
872 |
|
option_sourcepath.add(file); |
873 |
|
} |
874 |
|
} |
875 |
|
}); |
876 |
|
// TODO include other options here |
877 |
|
options.put("-verbose", new OptionProcessor(1) |
878 |
|
{ |
879 |
|
|
880 |
|
void process(String[] args) |
881 |
|
{ |
882 |
|
option_verbose = true; |
883 |
|
} |
884 |
|
}); |
885 |
|
options.put("-locale", new OptionProcessor(2) |
886 |
|
{ |
887 |
|
|
888 |
|
void process(String[] args) |
889 |
|
{ |
890 |
|
option_locale = args[0]; |
891 |
|
} |
892 |
|
}); |
893 |
|
options.put("-encoding", new OptionProcessor(2) |
894 |
|
{ |
895 |
|
|
896 |
|
void process(String[] args) |
897 |
|
{ |
898 |
|
option_encoding = args[0]; |
899 |
|
} |
900 |
|
}); |
901 |
|
} |
902 |
|
|
903 |
|
/** |
904 |
|
* Determine how many arguments the given option requires. |
905 |
|
* |
906 |
|
* @param option |
907 |
|
* The name of the option without leading dash. |
908 |
|
*/ |
909 |
|
private static int optionLength(String option) |
910 |
|
{ |
911 |
|
|
912 |
|
OptionProcessor op = (OptionProcessor) options.get(option); |
913 |
|
if (op != null) |
914 |
|
return op.argCount; |
915 |
|
else |
916 |
|
return 0; |
917 |
|
} |
918 |
|
|
919 |
|
/** |
920 |
|
* Process all given options. Assumes that the options have been validated |
921 |
|
* before. |
922 |
|
* |
923 |
|
* @param optionArr |
924 |
|
* Each element is a series of Strings where [0] is the name of the |
925 |
|
* option and [1..n] are the arguments to the option. |
926 |
|
*/ |
927 |
|
private void readOptions(String[][] optionArr) |
928 |
|
{ |
929 |
|
|
930 |
|
//--- For each option, find the appropriate OptionProcessor |
931 |
|
// and call its process() method |
932 |
|
|
933 |
|
for (int i = 0; i < optionArr.length; ++i) |
934 |
|
{ |
935 |
|
String[] opt = optionArr[i]; |
936 |
|
String[] args = new String[opt.length - 1]; |
937 |
|
System.arraycopy(opt, 1, args, 0, opt.length - 1); |
938 |
|
OptionProcessor op = (OptionProcessor) options.get(opt[0]); |
939 |
|
op.process(args); |
940 |
|
} |
941 |
|
} |
942 |
|
|
943 |
|
/** |
944 |
|
* Print command line usage. |
945 |
|
*/ |
946 |
|
private static void usage() |
947 |
|
{ |
948 |
|
System.err |
949 |
|
.print("\n" |
950 |
|
+ "USAGE: gjdoc [options] [packagenames] " |
951 |
|
+ /* "[sourcefiles] "+ */"[classnames] [@files]\n\n" |
952 |
|
/* + " -overview <file> Read overview documentation from HTML file\n" */ |
953 |
|
+ " -public Include only public classes and members\n" |
954 |
|
+ " -protected Include protected and public classes and members.\n" |
955 |
|
+ " This is the default.\n" |
956 |
|
+ " -package Include package/protected/public classes and members\n" |
957 |
|
+ " -private Include all classes and members\n" |
958 |
|
+ " -help Show this information\n" |
959 |
|
+ " -doclet <class> Doclet class to use for generating output\n" |
960 |
|
/* + " -docletpath <classpath> Specifies the path of the doclet and any jars that depends on\n" */ |
961 |
|
/* + " -source <release> Provide source compatibility with specified release (1.4 to handle assertion)\n" */ |
962 |
|
+ " -sourcepath <pathlist> Where to look for source files\n" |
963 |
|
/* + " -classpath <pathlist> Where to find additional libs (if it is not set, CLASSPATH variable is used)\n" */ |
964 |
|
/* + " -bootclasspath <path> Where the classes are found\n" */ |
965 |
|
/* + " -extdirs <dirlist> Where the extensions classes are\n" */ |
966 |
|
+ " -verbose Output messages about what Gjdoc is doing\n" |
967 |
|
/* + " -quiet Do not print non-error and non-warning messages\n" */ |
968 |
|
/* + " -locale <name> Locale to be used, e.g. en_US or en_US_WIN\n" */ |
969 |
|
/* + " -encoding <name> Source file encoding name\n" */ |
970 |
|
/* + " -J<flag> Passes the flag to the virtual machine\n" */ |
971 |
|
+ "Standard doclet options:\n" |
972 |
|
+ " -d Set target directory\n" |
973 |
|
/* + " -use Includes the 'Use' page for each documented class and package\n" */ |
974 |
|
/* + " -version Includes the '@version' tag\n" */ |
975 |
|
/* + " -author Includes the '@author' tag\n" */ |
976 |
|
/* + " -splitindex Splits the index file into multiple files\n" */ |
977 |
|
/* + " -windowtitle <text> Browser window title\n" */ |
978 |
|
/* + " -doctitle <text> Title near the top of the overview summary file (html allowed)\n" */ |
979 |
|
+ " -title Title for this set of API documentation (deprecated -doctitle should be used).\n" |
980 |
|
/* + " -header <text> Text at the top of each output file (html allowed)\n" */ |
981 |
|
/* + " -footer <text> Text at the bottom of each output file (html allowed)\n" */ |
982 |
|
/* + " -link <extdoc URL> Link to external javadoc-generated documentation you want to link to\n" */ |
983 |
|
/* + " -linkoffline <extdoc URL> <packagelistLoc> Link to external javadoc-generated documentation for the specified package-list\n" */ |
984 |
|
/* + " -linksource Creates an HTML version of each source file\n" */ |
985 |
|
/* + " -group <groupheading> <packagepattern:packagepattern:...> Separates packages on the overview page into groups\n" */ |
986 |
|
/* + " -nodeprecated Prevents the generation of any deprecated API\n" */ |
987 |
|
/* + " -nodeprecatedlist Prevents the generation of the file containing the list of deprecated APIs and the link to the navigation bar to that page\n" */ |
988 |
|
/* + " -nosince Omit the '@since' tag\n" */ |
989 |
|
/* + " -notree Do not generate the class/interface hierarchy page\n" */ |
990 |
|
/* + " -noindex Do not generate the index file\n" */ |
991 |
|
/* + " -nohelp Do not generate the HELP link\n" */ |
992 |
|
/* + " -nonavbar Do not generate the navbar, header and footer\n" */ |
993 |
|
/* + " -helpfile <filename> Path of an alternate help file\n" */ |
994 |
|
/* + " -stylesheet <filename> Path of an alternate html stylesheet\n" */ |
995 |
|
/* + " -serialwarn Generate compile time error for missing '@serial' tags\n" */ |
996 |
|
/* + " -charset <IANACharset> Specifies the HTML charset\n" */ |
997 |
|
/* + " -docencoding <IANACharset> Specifies the encoding of the generated HTML files\n" */ |
998 |
|
/* + " -tag <tagname>:Xaoptcmf:\"<taghead>\" Enables gjdoc to interpreta custom tag\n" */ |
999 |
|
+ " -taglet Adds a Taglet class to the map of taglets.\n" |
1000 |
|
+ " -tagletpath Sets the CLASSPATH to load subsequent Taglets from.\n" |
1001 |
|
/* + " -subpackages <spkglist> List of subpackages to recursivly load\n" */ |
1002 |
|
/* + " -exclude <pkglist> List of packages to exclude\n" */ |
1003 |
|
/* + " -breakiterator Compute first sentence with BreakIterator\n" */ |
1004 |
|
/* + " -docfilessubdirs Enables deep copy of 'doc-files' directories\n" */ |
1005 |
|
/* + " -excludedocfilessubdir <name1:name2:...> Excludes 'doc-files' subdirectories with a give name\n" */ |
1006 |
|
/* + " -noqualifier all|<packagename1:packagename2:...> Do not qualify package name from ahead of class names\n" */ |
1007 |
|
/* + " -nocomment Suppress the entire comment body including the main description and all tags, only generate the declarations\n" */ |
1008 |
|
+ " -genhtml Generate HTML code instead of XML code. This is the\n" |
1009 |
|
+ " default.\n" |
1010 |
|
+ " -geninfo Generate Info code instead of XML code.\n" |
1011 |
|
+ " -xslsheet <file> If specified, XML files will be written to a\n" |
1012 |
|
+ " temporary directory and transformed using the\n" |
1013 |
|
+ " given XSL sheet. The result of the transformation\n" |
1014 |
|
+ " is written to the output directory. Not required if\n" |
1015 |
|
+ " -genhtml or -geninfo has been specified.\n" |
1016 |
|
+ " -xmlonly Generate XML code only, do not generate HTML code.\n" |
1017 |
|
+ " -bottomnote HTML code to include at the bottom of each page.\n" |
1018 |
|
+ " -nofixhtml If not specified, heurestics will be applied to\n" |
1019 |
|
+ " fix broken HTML code in comments.\n" |
1020 |
|
+ " -nohtmlwarn Do not emit warnings when encountering broken HTML\n" |
1021 |
|
+ " code.\n" |
1022 |
|
+ " -noemailwarn Do not emit warnings when encountering strings like\n" |
1023 |
|
+ " <abc@foo.com>.\n" |
1024 |
|
+ " -indentstep <n> How many spaces to indent each tag level in\n" |
1025 |
|
+ " generated XML code.\n" |
1026 |
|
+ " -xsltdriver <class> Specifies the XSLT driver to use for transformation.\n" |
1027 |
|
+ " By default, xsltproc is used.\n" |
1028 |
|
+ " -postprocess <class> XmlDoclet postprocessor class to apply after XSL\n" |
1029 |
|
+ " transformation.\n" |
1030 |
|
+ " -compress Generated info pages will be Zip-compressed.\n" |
1031 |
|
+ " -workpath Specify a temporary directory to use.\n" |
1032 |
|
+ "\n"); |
1033 |
|
} |
1034 |
|
|
1035 |
|
/** |
1036 |
|
* Shutdown the generator. |
1037 |
|
*/ |
1038 |
|
public void shutdown() |
1039 |
|
{ |
1040 |
|
System.exit(5); |
1041 |
|
} |
1042 |
|
|
1043 |
|
/** |
1044 |
|
* The root of the gjdoc tool. |
1045 |
|
* |
1046 |
|
* @return all the options of the gjdoc application. |
1047 |
|
*/ |
1048 |
|
public static RootDocImpl getRootDoc() |
1049 |
|
{ |
1050 |
|
return rootDoc; |
1051 |
|
} |
1052 |
|
|
1053 |
|
/** |
1054 |
|
* Get the gjdoc singleton. |
1055 |
|
* |
1056 |
|
* @return the gjdoc instance. |
1057 |
|
*/ |
1058 |
|
public static Main getInstance() |
1059 |
|
{ |
1060 |
|
return instance; |
1061 |
|
} |
1062 |
|
|
1063 |
|
/** |
1064 |
|
* Is this access level covered? |
1065 |
|
* |
1066 |
|
* @param accessLevel |
1067 |
|
* the access level we want to know if it is covered. |
1068 |
|
* @return true if the access level is covered. |
1069 |
|
*/ |
1070 |
|
public boolean includeAccessLevel(int accessLevel) |
1071 |
|
{ |
1072 |
|
return coverageTemplates[option_coverage][accessLevel]; |
1073 |
|
} |
1074 |
|
|
1075 |
|
/** |
1076 |
|
* Is the doclet running? |
1077 |
|
* |
1078 |
|
* @return true if it's running |
1079 |
|
*/ |
1080 |
|
public boolean isDocletRunning() |
1081 |
|
{ |
1082 |
|
return docletRunning; |
1083 |
|
} |
1084 |
|
|
1085 |
|
/** |
1086 |
|
* Check the charset. Check that all the characters of the string 'toCheck' |
1087 |
|
* and query if they exist in the 'charSet'. The order does not matter. The |
1088 |
|
* number of times a character is in the variable does not matter. |
1089 |
|
* |
1090 |
|
* @param toCheck |
1091 |
|
* the charset to check. |
1092 |
|
* @param charSet |
1093 |
|
* the reference charset |
1094 |
|
* @return true if they match. |
1095 |
|
*/ |
1096 |
|
public static boolean checkCharSet(String toCheck, String charSet) |
1097 |
|
{ |
1098 |
|
for (int i = 0; i < toCheck.length(); ++i) |
1099 |
|
{ |
1100 |
|
if (charSet.indexOf(toCheck.charAt(i)) < 0) |
1101 |
|
return false; |
1102 |
|
} |
1103 |
|
return true; |
1104 |
|
} |
1105 |
|
|
1106 |
|
/** |
1107 |
|
* Makes the RootDoc eligible for the GC. |
1108 |
|
*/ |
1109 |
|
public static void releaseRootDoc() |
1110 |
|
{ |
1111 |
|
rootDoc = null; |
1112 |
|
} |
1113 |
|
|
|
/** |
|
|
* Process all given options. |
|
|
* |
|
|
* Assumes that the options have been validated before. |
|
|
* |
|
|
* @param optionArr Each element is a series of Strings where [0] is |
|
|
* the name of the option and [1..n] are the arguments |
|
|
* to the option. |
|
|
*/ |
|
|
private void readOptions(String[][] optionArr) { |
|
|
|
|
|
//--- For each option, find the appropriate OptionProcessor |
|
|
// and call its process() method |
|
|
|
|
|
for (int i=0; i<optionArr.length; ++i) { |
|
|
String[] opt = optionArr[i]; |
|
|
String[] args = new String[opt.length-1]; |
|
|
System.arraycopy(opt,1,args,0,opt.length-1); |
|
|
OptionProcessor op=(OptionProcessor)options.get(opt[0]); |
|
|
op.process(args); |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
* Print command line usage. |
|
|
* |
|
|
*/ |
|
|
private static void usage() { |
|
|
System.err.print("\n"+ |
|
|
"USAGE: gjdoc [options] [packagenames] "+/*"[sourcefiles] "+*/"[classnames] [@files]\n\n"+ |
|
|
" -doclet <class> Doclet class to use for generating output\n"+ |
|
|
" -sourcepath <pathlist> Where to look for source files\n"+ |
|
|
" -d Set target directory\n"+ |
|
|
/* |
|
|
" -overview <file> Read overview documentation from HTML file\n"+ |
|
|
*/ |
|
|
" -public Include only public classes and members\n"+ |
|
|
" -protected Include protected and public classes and members.\n"+ |
|
|
" This is the default.\n" + |
|
|
" -package Include package/protected/public classes and members\n"+ |
|
|
" -private Include all classes and members\n"+ |
|
|
" -verbose Output messages about what Gjdoc is doing\n"+ |
|
|
/* |
|
|
" -locale <name> Locale to be used, e.g. en_US or en_US_WIN\n"+ |
|
|
" -encoding <name> Source file encoding name\n"+ |
|
|
*/ |
|
|
" -help Show this information\n" + |
|
|
"\n" + |
|
|
"Standard doclet options:\n" + |
|
|
" -genhtml Generate HTML code instead of XML code. This is the\n" + |
|
|
" default.\n" + |
|
|
" -geninfo Generate Info code instead of XML code.\n" + |
|
|
" -xslsheet <file> If specified, XML files will be written to a\n" + |
|
|
" temporary directory and transformed using the\n" + |
|
|
" given XSL sheet. The result of the transformation\n" + |
|
|
" is written to the output directory. Not required if\n" + |
|
|
" -genhtml or -geninfo has been specified.\n" + |
|
|
" -xmlonly Generate XML code only, do not generate HTML code.\n" + |
|
|
" -title Title for this set of API documentation.\n" + |
|
|
" -bottomnote HTML code to include at the bottom of each page.\n" + |
|
|
" -nofixhtml If not specified, heurestics will be applied to\n" + |
|
|
" fix broken HTML code in comments.\n" + |
|
|
" -nohtmlwarn Do not emit warnings when encountering broken HTML\n" + |
|
|
" code.\n" + |
|
|
" -noemailwarn Do not emit warnings when encountering strings like\n" + |
|
|
" <abc@foo.com>.\n" + |
|
|
" -indentstep <n> How many spaces to indent each tag level in\n" + |
|
|
" generated XML code.\n" + |
|
|
" -xsltdriver <class> Specifies the XSLT driver to use for transformation.\n" + |
|
|
" By default, xsltproc is used.\n" + |
|
|
" -postprocess <class> XmlDoclet postprocessor class to apply after XSL\n" + |
|
|
" transformation.\n" + |
|
|
" -compress Generated info pages will be Zip-compressed.\n" + |
|
|
" -workpath Specify a temporary directory to use.\n" + |
|
|
" -taglet Adds a Taglet class to the map of taglets.\n" + |
|
|
" -tagletpath Sets the CLASSPATH to load subsequent Taglets from.\n" + |
|
|
"\n" |
|
|
); |
|
|
} |
|
|
|
|
|
/** |
|
|
* Shutdown the generator. |
|
|
*/ |
|
|
public void shutdown() { |
|
|
System.exit(5); |
|
|
} |
|
|
|
|
|
public static RootDocImpl getRootDoc() { return rootDoc; } |
|
|
|
|
|
public static Main getInstance() { return instance; } |
|
|
|
|
|
public boolean includeAccessLevel(int accessLevel) { |
|
|
return coverageTemplates[option_coverage][accessLevel]; |
|
|
} |
|
|
|
|
|
|
|
|
public boolean isDocletRunning() { return docletRunning; } |
|
|
|
|
|
public static boolean checkCharSet(String toCheck, String charSet) { |
|
|
for (int i=0; i<toCheck.length(); ++i) { |
|
|
if (charSet.indexOf(toCheck.charAt(i))<0) |
|
|
return false; |
|
|
} |
|
|
return true; |
|
|
} |
|
|
|
|
|
public static void releaseRootDoc() { |
|
|
rootDoc = null; |
|
|
} |
|
1114 |
} |
} |
1115 |
|
|