1 19 20 package doclet; 21 22 import com.sun.javadoc.*; 23 import com.sun.tools.doclets.standard.Standard; 24 25 import java.io.*; 26 import java.util.Arrays ; 27 28 public class GenerateTocXML 29 { 30 public static final String OUT = "toc.xml"; 31 public static final String HEADER = "<?xml version='1.0'?>\n<TOC>\n" 32 + "<ENTRY HREF='overview-summary.html'><TITLE>jEdit API Reference</TITLE>"; 33 public static final String FOOTER = "</ENTRY></TOC>\n"; 34 35 public static boolean start(RootDoc root) 36 { 37 if (!Standard.start(root)) 38 { 39 return false; 40 } 41 try 42 { 43 FileWriter out = new FileWriter(Standard.htmlDoclet.configuration().destDirName + OUT); 44 out.write(HEADER); 45 46 PackageDoc[] packages = root.specifiedPackages(); 47 for(int i = 0; i < packages.length; ++i) 48 { 49 processPackage(out,packages[i]); 50 } 51 52 out.write(FOOTER); 53 out.close(); 54 55 return true; 56 } 57 catch(IOException e) 58 { 59 e.printStackTrace(); 60 return false; 61 } 62 } 63 64 public static int optionLength(String option) 65 { 66 return Standard.optionLength(option); 67 } 68 69 public static boolean validOptions(String [][] options, DocErrorReporter reporter) 70 { 71 return Standard.validOptions(options,reporter); 72 } 73 74 public static LanguageVersion languageVersion() 75 { 76 return Standard.languageVersion(); 77 } 78 79 private static void processPackage(Writer out, PackageDoc pkg) 80 throws IOException 81 { 82 out.write("<ENTRY HREF='"); 83 String pkgPath = pkg.name().replace('.','/') + "/"; 84 out.write(pkgPath); 85 out.write("package-summary.html'><TITLE>"); 86 out.write(pkg.name()); 87 out.write("</TITLE>\n"); 88 89 ClassDoc[] classes = pkg.allClasses(); 90 String [] classNames = new String [classes.length]; 91 for(int i = 0; i < classes.length; i++) 92 { 93 classNames[i] = classes[i].name(); 94 } 95 Arrays.sort(classNames); 96 97 for(int i = 0; i < classes.length; i++) 98 { 99 processClass(out,pkgPath,classNames[i]); 100 } 101 102 out.write("</ENTRY>"); 103 } 104 105 private static void processClass(Writer out, String pkgPath, String clazz) 106 throws IOException 107 { 108 out.write("<ENTRY HREF='"); 109 out.write(pkgPath); 110 out.write(clazz); 111 out.write(".html'><TITLE>"); 112 out.write(clazz); 113 out.write("</TITLE>\n"); 114 out.write("</ENTRY>"); 115 } 116 } 117 | Popular Tags |