34 |
import java.util.ArrayList; |
import java.util.ArrayList; |
35 |
import java.util.Arrays; |
import java.util.Arrays; |
36 |
import java.util.Comparator; |
import java.util.Comparator; |
37 |
import java.util.LinkedHashMap; |
import java.util.HashSet; |
|
import java.util.Locale; |
|
38 |
import java.util.Iterator; |
import java.util.Iterator; |
39 |
|
import java.util.LinkedHashMap; |
40 |
import java.util.List; |
import java.util.List; |
41 |
|
import java.util.Locale; |
42 |
import java.util.Map; |
import java.util.Map; |
43 |
|
import java.util.Properties; |
44 |
import java.util.Set; |
import java.util.Set; |
|
import java.util.HashSet; |
|
|
import java.util.TreeMap; |
|
45 |
import java.util.StringTokenizer; |
import java.util.StringTokenizer; |
46 |
|
import java.util.TreeMap; |
47 |
|
|
48 |
import gnu.classpath.tools.gjdoc.TemporaryStore; |
import gnu.classpath.tools.gjdoc.TemporaryStore; |
49 |
import gnu.classpath.tools.gjdoc.GjdocPackageDoc; |
import gnu.classpath.tools.gjdoc.GjdocPackageDoc; |
55 |
import gnu.classpath.tools.taglets.VersionTaglet; |
import gnu.classpath.tools.taglets.VersionTaglet; |
56 |
import gnu.classpath.tools.taglets.SinceTaglet; |
import gnu.classpath.tools.taglets.SinceTaglet; |
57 |
|
|
58 |
|
import gnu.classpath.tools.java2xhtml.Java2xhtml; |
59 |
|
|
60 |
/** |
/** |
61 |
* A Doclet which retrieves all information presented by the Doclet |
* A Doclet which retrieves all information presented by the Doclet |
62 |
* API, dumping it to stdout in XML format. |
* API, dumping it to stdout in XML format. |
230 |
*/ |
*/ |
231 |
private Map tagletMap = new LinkedHashMap(); |
private Map tagletMap = new LinkedHashMap(); |
232 |
|
|
233 |
|
/** |
234 |
|
* Stores options to be passed to the DocTranslet. |
235 |
|
*/ |
236 |
|
private DocTransletOptions docTransletOptions = new DocTransletOptions(); |
237 |
|
|
238 |
public static boolean start(TemporaryStore _rootDocWrapper) { |
public static boolean start(TemporaryStore _rootDocWrapper) { |
239 |
return new Driver().instanceStart((RootDoc)_rootDocWrapper.getAndClear()); |
return new Driver().instanceStart((RootDoc)_rootDocWrapper.getAndClear()); |
240 |
} |
} |
414 |
printCloseTag(1, "packagedoc"); |
printCloseTag(1, "packagedoc"); |
415 |
} |
} |
416 |
|
|
417 |
protected void outputClassDoc(ClassDoc classDoc) { |
protected void outputClassDoc(ClassDoc classDoc) throws IOException { |
418 |
|
|
419 |
currentClass = classDoc; |
currentClass = classDoc; |
420 |
|
|
456 |
outputFieldDoc(2, fields[i]); |
outputFieldDoc(2, fields[i]); |
457 |
} |
} |
458 |
|
|
459 |
|
Java2xhtml java2xhtml = new Java2xhtml(); |
460 |
|
Properties properties = new Properties(); |
461 |
|
properties.setProperty("isCodeSnippet", "true"); |
462 |
|
properties.setProperty("hasLineNumbers", "true"); |
463 |
|
java2xhtml.setProperties(properties); |
464 |
|
|
465 |
|
if (null == classDoc.containingClass() && docTransletOptions.linksource) { |
466 |
|
printOpenTag(2, "source"); |
467 |
|
StringWriter sourceBuffer = new StringWriter(); |
468 |
|
File sourceFile = new File(((GjdocPackageDoc)classDoc.containingPackage()).packageDirectory(), |
469 |
|
classDoc.name() + ".java"); |
470 |
|
FileReader sourceReader = new FileReader(sourceFile); |
471 |
|
Driver.copyStream(sourceReader, sourceBuffer); |
472 |
|
print(java2xhtml.makeHTML(sourceBuffer.getBuffer(), sourceFile.getName())); |
473 |
|
printCloseTag(2, "source"); |
474 |
|
} |
475 |
printCloseTag(1, "classdoc"); |
printCloseTag(1, "classdoc"); |
476 |
|
|
477 |
currentClass = null; |
currentClass = null; |
537 |
outputTags(level+1, doc.seeTags(), true, context); |
outputTags(level+1, doc.seeTags(), true, context); |
538 |
printCloseTag(level, "seeTags"); |
printCloseTag(level, "seeTags"); |
539 |
} |
} |
540 |
|
|
541 |
|
SourcePosition position = doc.position(); |
542 |
|
if (null != position) { |
543 |
|
printAtomTag(level, "position file=\"" + position.file().getAbsolutePath() + "\" line=\"" + position.line() + "\" column=\"" + position.column() + "\""); |
544 |
|
} |
545 |
} |
} |
546 |
|
|
547 |
protected void outputProgramElementDocBody(int level, ProgramElementDoc programElementDoc) { |
protected void outputProgramElementDocBody(int level, ProgramElementDoc programElementDoc) { |
730 |
VersionTaglet.setTagletEnabled(false); |
VersionTaglet.setTagletEnabled(false); |
731 |
SinceTaglet.setTagletEnabled(true); |
SinceTaglet.setTagletEnabled(true); |
732 |
|
|
|
DocTransletOptions docTransletOptions = new DocTransletOptions(); |
|
|
|
|
733 |
try { |
try { |
734 |
{ |
{ |
735 |
|
|
965 |
else if ("-splitindex".equals(optionTag)) { |
else if ("-splitindex".equals(optionTag)) { |
966 |
docTransletOptions.splitindex = true; |
docTransletOptions.splitindex = true; |
967 |
} |
} |
968 |
|
else if ("-linksource".equals(optionTag)) { |
969 |
|
docTransletOptions.linksource = true; |
970 |
|
} |
971 |
|
else if ("-windowtitle".equals(optionTag)) { |
972 |
|
docTransletOptions.windowtitle = option[1]; |
973 |
|
} |
974 |
|
else if ("-helpfile".equals(optionTag)) { |
975 |
|
docTransletOptions.helpfile = new File(option[1]).toURL().toString(); |
976 |
|
} |
977 |
|
else if ("-stylesheet".equals(optionTag)) { |
978 |
|
docTransletOptions.stylesheet = new File(option[1]).toURL().toString(); |
979 |
|
} |
980 |
} |
} |
981 |
|
|
982 |
// Use current directory if target directory hasn't been set. |
// Use current directory if target directory hasn't been set. |
1452 |
else if ("-author".equals(option)) return 1; |
else if ("-author".equals(option)) return 1; |
1453 |
else if ("-version".equals(option)) return 1; |
else if ("-version".equals(option)) return 1; |
1454 |
else if ("-nosince".equals(option)) return 1; |
else if ("-nosince".equals(option)) return 1; |
1455 |
|
else if ("-linksource".equals(option)) return 1; |
1456 |
|
else if ("-windowtitle".equals(option)) return 2; |
1457 |
|
else if ("-helpfile".equals(option)) return 2; |
1458 |
|
else if ("-stylesheet".equals(option)) return 2; |
1459 |
|
|
1460 |
else return -1; |
else return -1; |
1461 |
} |
} |
1798 |
|
|
1799 |
closeTargetFile(); |
closeTargetFile(); |
1800 |
} |
} |
1801 |
|
|
1802 |
|
public static void copyStream(InputStream in, OutputStream out) |
1803 |
|
throws IOException { |
1804 |
|
|
1805 |
|
byte[] buf = new byte[256]; |
1806 |
|
int nread; |
1807 |
|
|
1808 |
|
while ((nread = in.read(buf)) >= 0) { |
1809 |
|
out.write(buf, 0, nread); |
1810 |
|
} |
1811 |
|
} |
1812 |
|
|
1813 |
|
public static void copyStream(Reader in, Writer out) |
1814 |
|
throws IOException { |
1815 |
|
|
1816 |
|
char[] buf = new char[256]; |
1817 |
|
int nread; |
1818 |
|
|
1819 |
|
while ((nread = in.read(buf)) >= 0) { |
1820 |
|
out.write(buf, 0, nread); |
1821 |
|
} |
1822 |
|
} |
1823 |
} |
} |