You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by ni...@apache.org on 2004/02/11 20:13:59 UTC
cvs commit: xml-forrest/scratchpad/forrestdoc/src/java/org/apache/forrest/forrestdoc/js/doc GenerateHTMLDoc.java GenerateHTMLIndex.java
nicolaken 2004/02/11 11:13:59
Modified: scratchpad/forrestdoc/src/java/org/apache/forrest/forrestdoc/js/doc
GenerateHTMLDoc.java GenerateHTMLIndex.java
Log:
Fix javascript docs :-)
Now it traverses all the dirs under the specified one and describes
things in English.
Revision Changes Path
1.2 +11 -9 xml-forrest/scratchpad/forrestdoc/src/java/org/apache/forrest/forrestdoc/js/doc/GenerateHTMLDoc.java
Index: GenerateHTMLDoc.java
===================================================================
RCS file: /home/cvs/xml-forrest/scratchpad/forrestdoc/src/java/org/apache/forrest/forrestdoc/js/doc/GenerateHTMLDoc.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GenerateHTMLDoc.java 9 Feb 2004 11:09:18 -0000 1.1
+++ GenerateHTMLDoc.java 11 Feb 2004 19:13:59 -0000 1.2
@@ -61,7 +61,9 @@
package org.apache.forrest.forrestdoc.js.doc;
+import java.io.File;
import java.io.BufferedReader;
+import java.io.FileReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -88,11 +90,11 @@
private boolean summary = true;
private boolean description = true;
- public GenerateHTMLDoc(String jSDir, String destDir, String nomeArquivo) {
+ public GenerateHTMLDoc(File fis, String destDir) {
+ String nomeArquivo = fis.getName();
try {
- fis = new FileInputStream(jSDir + nomeArquivo);
fos = new FileOutputStream(destDir + nomeArquivo.substring(0, nomeArquivo.indexOf(".")) + ".htm");
- br = new BufferedReader(new InputStreamReader(fis));
+ br = new BufferedReader(new FileReader(fis));
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
@@ -109,7 +111,7 @@
fos.write(("<title>Javascript code documentation</title>" + LINE_SEPARATOR).getBytes());
fos.write(("</head>" + LINE_SEPARATOR).getBytes());
fos.write(("<body>" + LINE_SEPARATOR).getBytes());
- fos.write(("<H2>Arquivo: " + nomeArquivo + "</H2>" + LINE_SEPARATOR).getBytes());
+ fos.write(("<H2>Filename: " + nomeArquivo + "</H2>" + LINE_SEPARATOR).getBytes());
fos.write(("<br>" + LINE_SEPARATOR).getBytes());
fos.write(("<br>" + LINE_SEPARATOR).getBytes());
fos.write(("<TABLE BORDER='1' CELLPADDING='3' CELLSPACING='0' WIDTH='100%'>" + LINE_SEPARATOR).getBytes());
@@ -200,9 +202,9 @@
}
- public static void main(String args[]) {
+ public static void main(String args[]) throws Exception{
- GenerateHTMLDoc main1 = new GenerateHTMLDoc(args[0], args[1], args[2]);
+ GenerateHTMLDoc main1 = new GenerateHTMLDoc(new File(args[0]), args[1]);
}
}
1.2 +28 -20 xml-forrest/scratchpad/forrestdoc/src/java/org/apache/forrest/forrestdoc/js/doc/GenerateHTMLIndex.java
Index: GenerateHTMLIndex.java
===================================================================
RCS file: /home/cvs/xml-forrest/scratchpad/forrestdoc/src/java/org/apache/forrest/forrestdoc/js/doc/GenerateHTMLIndex.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GenerateHTMLIndex.java 9 Feb 2004 11:09:18 -0000 1.1
+++ GenerateHTMLIndex.java 11 Feb 2004 19:13:59 -0000 1.2
@@ -81,7 +81,6 @@
public class GenerateHTMLIndex {
private static File file, file2 = null;
- private static File[] fileList = null;
private static FileInputStream fis;
private static FileOutputStream fos;
private static BufferedReader br;
@@ -106,14 +105,13 @@
}
file = new File(jSDir);
- fileList = file.listFiles();
-
- for (int i = 0; i < fileList.length; i++) {
- if (fileList[i].getName().indexOf(".js") != -1) {
- v.addElement(fileList[i]);
- }
- }
-
+
+ if (!file.isDirectory()) {
+ throw new BuildException("destDir has to be a directory");
+ }
+
+ collectFiles(file, v);
+
try {
fos = new FileOutputStream(destDir + "index.htm");
@@ -136,20 +134,20 @@
fos.write(("<title>JavaScript Code Documentation</title>" + LINE_SEPARATOR).getBytes());
fos.write(("</head>" + LINE_SEPARATOR).getBytes());
fos.write(("<body>" + LINE_SEPARATOR).getBytes());
- fos.write(("<H2>�ndice de files</H2>" + LINE_SEPARATOR).getBytes());
+ fos.write(("<H2>Index</H2>" + LINE_SEPARATOR).getBytes());
fos.write(("<br>" + LINE_SEPARATOR).getBytes());
fos.write(("<br>" + LINE_SEPARATOR).getBytes());
fos.write(("<TABLE BORDER='1' CELLPADDING='3' CELLSPACING='0' WIDTH='100%'>" + LINE_SEPARATOR).getBytes());
fos.write(("<TR CLASS='TableHeadingColor'>" + LINE_SEPARATOR).getBytes());
fos.write(("<TD ALIGN='left'><FONT SIZE='+2' WIDTH='30%'>" + LINE_SEPARATOR).getBytes());
- fos.write(("<B>Nome do file</B></FONT></TD>" + LINE_SEPARATOR).getBytes());
+ fos.write(("<B>Filename</B></FONT></TD>" + LINE_SEPARATOR).getBytes());
fos.write(("<TD ALIGN='left'><FONT SIZE='+2' WIDTH='70%'>" + LINE_SEPARATOR).getBytes());
- fos.write(("<B>Resumo do conte�do</B></FONT></TD>" + LINE_SEPARATOR).getBytes());
+ fos.write(("<B>Summary</B></FONT></TD>" + LINE_SEPARATOR).getBytes());
fos.write(("</TR>" + LINE_SEPARATOR).getBytes());
for (int i = 0; i < v.size(); i++) {
file = (File) v.get(i);
- docGenerator = new GenerateHTMLDoc(jSDir, destDir, file.getName());
+ docGenerator = new GenerateHTMLDoc(file, destDir);
}
System.out.println("N�mero de files .js: " + v.size());
for (int i = 0; i < v.size(); i++) {
@@ -161,7 +159,7 @@
fos.write(("<TD WIDTH='70%'>" + LINE_SEPARATOR).getBytes());
try {
- fis = new FileInputStream(jSDir + file.getName());
+ fis = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(fis));
while (br.ready()) {
@@ -198,11 +196,21 @@
}
}
-
+
+ private void collectFiles(File baseDir, Vector fileVector) {
+ File[] fileList = baseDir.listFiles();
+ for (int i = 0; i < fileList.length; i++) {
+ if (fileList[i].isDirectory()){
+ collectFiles(fileList[i], fileVector);
+ }
+ else if (fileList[i].getName().indexOf(".js") != -1) {
+ v.addElement(fileList[i]);
+ }
+ }
+ }
+
public static void main(String[] args) {
-
GenerateHTMLIndex index = new GenerateHTMLIndex(args[0], args[1]);
-
}
}