/Users/lyon/j4p/src/rtf/JavaDocUtil.java

1    package rtf; 
2     
3    import futils.Futil; 
4    import gui.In; 
5     
6    import java.io.File; 
7     
8    import gui.In; 
9     
10    
11   /** 
12    * DocJava, Inc. User: lyon Date: Aug 15, 2004 
13    * Time: 11:30:43 AM 
14    */ 
15   public class JavaDocUtil { 
16       public static void main(String args[]) { 
17           String packageName = In.getString("enter package name"); 
18           String options[] = { 
19               "html", 
20               "rtf" 
21           }; 
22           String sourcePath = getSourcePath(); 
23           String format = (String) In.multiPrompt(options, "output format", "format seletor"); 
24           if (format.equals("rtf")) 
25               outputRtf(packageName, sourcePath); 
26           if (format.equals("html")) 
27               outputHtml(packageName, sourcePath); 
28           In.message("done generating javadoc"); 
29       } 
30    
31       private static String getSourcePath() { 
32           final String sourcePath = "/Users/lyon/current/java/j4p/src"; 
33           File f = new File(sourcePath); 
34           if (f.exists()) return sourcePath; 
35           return Futil.getReadDirFile("select source path").toString(); 
36       } 
37    
38       public static void outputHtml(String packageName, String sourcePath) { 
39           final String windowTitle = "Another fine DocJava, Inc. API"; 
40           final String destination = "/home/lyon/current/java/j4p/docs"; 
41    
42           outputHtml(windowTitle, 
43                   destination, 
44                   sourcePath, 
45                   packageName); 
46       } 
47    
48       public static void outputHtml(final String windowTitle, 
49                                     final String destination, 
50                                     final String sourcePath, 
51                                     final String packageName) { 
52           String[] javadocargs = {"-public", 
53                                   "-splitindex", 
54                                   "-use", 
55                                   "-author", 
56                                   "-version", 
57                                   "-windowtitle", windowTitle, 
58                                   "-d", destination, 
59                                   "-sourcepath", sourcePath, 
60                                   packageName}; 
61           runJavaDoc(javadocargs); 
62       } 
63    
64       public static void outputRtf(String packageName, String sourcePath) { 
65           final String docletPath = "/Users/lyon/current/java/j4p/jars/RTFDoclet.jar"; 
66           outputRtf(docletPath, sourcePath, packageName); 
67       } 
68    
69       public static void outputRtf(final String docletPath, 
70                                    final String sourcePath, 
71                                    final String packageName) { 
72           String[] javadocargs = {"-public", 
73                                   "-docletpath", docletPath, 
74                                   "-doclet", "RTFDoclet", 
75                                   "-sourcepath", sourcePath, 
76                                   "-filename", "docs/" + 
77                   packageName + 
78                   ".rtf", 
79                                   packageName}; 
80           runJavaDoc(javadocargs); 
81       } 
82    
83       public static void runJavaDoc(String[] javadocargs) { 
84           com.sun.tools.javadoc.Main.main(javadocargs); 
85       } 
86   } 
87