Modified: forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/java/src/symtab/ReferencePersistor.java URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/java/src/symtab/ReferencePersistor.java?view=diff&rev=556752&r1=556751&r2=556752 ============================================================================== --- forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/java/src/symtab/ReferencePersistor.java (original) +++ forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/java/src/symtab/ReferencePersistor.java Mon Jul 16 15:17:40 2007 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,6 +16,8 @@ */ package org.apache.forrest.forrestdoc.java.src.symtab; +import org.apache.log4j.Logger; + import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; @@ -27,9 +29,14 @@ * A visitor (in the Visitor design pattern sense) for persisting * references. All references to anything in a package are stored * in that package's references.txt file. + * + * @version $Id: $ */ public class ReferencePersistor implements Visitor, ReferenceTypes { + /** Logger for this class */ + private static final Logger log = Logger.getLogger( ReferencePersistor.class ); + /** * @param outDirPath the root of the output directory tree */ @@ -52,9 +59,7 @@ } /** - * Prepare to process this package. Close the previous package's file. - * - * @param def + * @see org.apache.forrest.forrestdoc.java.src.symtab.Visitor#visit(org.apache.forrest.forrestdoc.java.src.symtab.PackageDef) */ public void visit(PackageDef def) { @@ -65,7 +70,11 @@ String finalDirPath = outDirPath + File.separatorChar + def.getName().replace('.', File.separatorChar); - // System.out.println("visit:finalDirPath="+finalDirPath); + if (log.isDebugEnabled()) + { + log.debug("visit(PackageDef) - String finalDirPath=" + finalDirPath); + } + File dir = new File(finalDirPath); dir.mkdirs(); @@ -77,7 +86,7 @@ fw = new FileWriter(filePath, append); } catch (IOException ex) { - ex.printStackTrace(); + log.error( "IOException: " + ex.getMessage(), ex ); fw = null; // TBD: fix this hack } @@ -89,33 +98,35 @@ // ReferentType -- Class Method, or Variable // ReferentClass - name of this referent's class. If that class is an inner class, format is outer.inner // ReferentTag - referent's name as used below [TBD: change usage in Pass1] - // + // // Referent's URL in source code is {ReferentFileClass}_java.html#{ReferentTag} // Referent's URL in referent list is {ReferentFileClass}_java_ref.html#{ReferentTag} // Referent class's name in package list is {ReferentClass} - // + // pw.println( "# ReferentFileClass | ReferentClass | ReferentType | ReferentTag | ReferringPackage | ReferringClass | ReferringMethod | ReferringFile | ReferringLineNumber"); } /** * Method getReferentFileClass - * - * @param def - * @return + * + * @param def + * @return */ private String getReferentFileClass(Definition def) { String temp = def.getOccurrence().getFile().getName(); // HACK! - // System.out.println("name="+def.getClassScopeName()+" temp="+temp); + if (log.isDebugEnabled()) + { + log.debug("getReferentFileClass(Definition) - name="+def.getClassScopeName()+" temp="+temp); + } + return temp.substring(0, temp.length() - ".java".length()); } /** - * Method visit - * - * @param def + * @see org.apache.forrest.forrestdoc.java.src.symtab.Visitor#visit(org.apache.forrest.forrestdoc.java.src.symtab.ClassDef) */ public void visit(ClassDef def) { @@ -123,8 +134,12 @@ return; } - // System.out.println(def.getName()+" is defined in "+def.getOccurrence().getFile().getName()); - // System.out.println("persist "+def.getName()); + if (log.isDebugEnabled()) + { + log.debug("visit(ClassDef) - " + def.getName()+" is defined in "+def.getOccurrence().getFile().getName()); + log.debug("visit(ClassDef) - persist "+def.getName()); + } + String referentFileClass = getReferentFileClass(def); String referentTag = def.getClassScopeName(); String referentClass; @@ -142,9 +157,7 @@ } /** - * Method visit - * - * @param def + * @see org.apache.forrest.forrestdoc.java.src.symtab.Visitor#visit(org.apache.forrest.forrestdoc.java.src.symtab.MethodDef) */ public void visit(MethodDef def) { @@ -166,9 +179,7 @@ } /** - * Method visit - * - * @param def + * @see org.apache.forrest.forrestdoc.java.src.symtab.Visitor#visit(org.apache.forrest.forrestdoc.java.src.symtab.VariableDef) */ public void visit(VariableDef def) { @@ -207,23 +218,23 @@ /** * Method persist - * - * @param referentFileClass - * @param referentType - * @param referentTag - * @param referentClass - * @param def + * + * @param referentFileClass + * @param referentType + * @param referentTag + * @param referentClass + * @param def */ private void persist(String referentFileClass, String referentType, String referentTag, String referentClass, Definition def) { - // System.out.println("persist: referentType="+referentType+" referentTag="+referentTag); - // boolean debugFlag = referentClass.equals("ReferencePersistor") && referentTag.equals("ReferencePersistor"); - // if (debugFlag) { - // System.out.println("references "+references); - // System.out.println("output file "+filePath); - // } + if (log.isDebugEnabled()) + { + log.debug("persist(String, String, String, String, Definition) - String referentFileClass=" + referentFileClass); + log.debug("persist(String, String, String, String, Definition) - String referentType=" + referentType); + } + JavaVector refs = def.getReferences(); if (refs != null) { @@ -232,7 +243,6 @@ while (enumList.hasMoreElements()) { Occurrence occ = (Occurrence) enumList.nextElement(); - // if (debugFlag) System.out.println("occ="+occ); persist(referentFileClass, referentType, referentTag, referentClass, occ); } @@ -244,12 +254,12 @@ /** * Method persist - * - * @param referentFileClass - * @param referentType - * @param referentTag - * @param referentClass - * @param occ + * + * @param referentFileClass + * @param referentType + * @param referentTag + * @param referentClass + * @param occ */ private void persist(String referentFileClass, String referentType, String referentTag, String referentClass, @@ -284,8 +294,7 @@ bw.close(); fw.close(); } catch (IOException ex) { - System.err.println("Hell has frozen over."); - ex.printStackTrace(); + log.error( "Hell has frozen over.", ex); } } Modified: forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/java/src/symtab/ReferenceTypes.java URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/java/src/symtab/ReferenceTypes.java?view=diff&rev=556752&r1=556751&r2=556752 ============================================================================== --- forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/java/src/symtab/ReferenceTypes.java (original) +++ forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/java/src/symtab/ReferenceTypes.java Mon Jul 16 15:17:40 2007 @@ -19,7 +19,7 @@ /** * Interface ReferenceTypes * - * @version %I%, %G% + * @version $Id: $ */ public interface ReferenceTypes { Modified: forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/java/src/symtab/ScopedDef.java URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/java/src/symtab/ScopedDef.java?view=diff&rev=556752&r1=556751&r2=556752 ============================================================================== --- forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/java/src/symtab/ScopedDef.java (original) +++ forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/java/src/symtab/ScopedDef.java Mon Jul 16 15:17:40 2007 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,6 +16,8 @@ */ package org.apache.forrest.forrestdoc.java.src.symtab; +import org.apache.log4j.Logger; + import org.apache.forrest.forrestdoc.java.src.xref.JavaToken; import java.util.Hashtable; @@ -23,11 +25,13 @@ /** * An abstract class representing a symbol that provides a scope that * contains other symbols. + * + * @version $Id: $ */ public abstract class ScopedDef extends Definition { - /** Field debug */ - public static final boolean debug = false; + /** Logger for this class */ + private static final Logger log = Logger.getLogger( ScopedDef.class ); // ========================================================================== // == Class Variables @@ -65,10 +69,10 @@ /** * Constructor to create the base part of a scoped definition - * - * @param name - * @param occ - * @param parentScope + * + * @param name + * @param occ + * @param parentScope */ ScopedDef(String name, // the scoped name Occurrence occ, // where it's defined @@ -82,8 +86,8 @@ /** * Method getSymbols - * - * @return + * + * @return */ public Hashtable getSymbols() { return elements; @@ -91,8 +95,8 @@ /** * Add a symbol to our scope - * - * @param def + * + * @param def */ void add(Definition def) { @@ -133,14 +137,17 @@ /** * Add a token to the list of unresolved references - * - * @param t + * + * @param t */ void addUnresolved(JavaToken t) { // be lazy in our creation of the reference vector // (many definitions might not contain refs to other symbols) - // System.out.println("Adding unresolved reference to:"+getQualifiedName()); + if (log.isDebugEnabled()) + { + log.debug("addUnresolved(JavaToken) - Adding unresolved reference to:"+getQualifiedName()); + } if (unresolvedStuff == null) { unresolvedStuff = new JavaVector(); } @@ -150,8 +157,8 @@ /** * Return whether or not this scope actually contains any elements - * - * @return + * + * @return */ public JavaHashtable getElements() { return elements; @@ -159,8 +166,8 @@ /** * Return whether or not this scope actually contains any elements - * - * @return + * + * @return */ boolean hasElements() { return !elements.isEmpty(); @@ -170,22 +177,15 @@ * Return if this is a base or default scope. This is used when printing * information to the report so we won't prefix elements in these * scopes. - * - * @return + * + * @return */ public boolean isDefaultOrBaseScope() { return iAmDefaultOrBaseScope; } /** - * Lookup a method in the scope - * This is usually just a hashtable lookup, but if the element returned - * is a MultiDef, we need to ask it to find the best match - * - * @param name - * @param numParams - * @param type - * @return + * @see org.apache.forrest.forrestdoc.java.src.symtab.Definition#lookup(java.lang.String, int, java.lang.Class) */ Definition lookup(String name, int numParams, Class type) { @@ -214,8 +214,8 @@ /** * Create tag info about elements - * - * @param tagList + * + * @param tagList */ void tagElements(HTMLTagContainer tagList) { @@ -228,16 +228,15 @@ static private int resolveLevel = 0; /** - * Resolve referenced names - * - * @param symbolTable + * @see org.apache.forrest.forrestdoc.java.src.symtab.Definition#resolveTypes(org.apache.forrest.forrestdoc.java.src.symtab.SymbolTable) */ void resolveTypes(SymbolTable symbolTable) { + if (log.isDebugEnabled()) + { + log.debug("resolveTypes(SymbolTable) - SymbolTable symbolTable=" + symbolTable); + log.debug("resolveTypes(SymbolTable) - resolving types for "+this.getQualifiedName()); + } - // for (int i=0; i"); } catch (IOException e) { + log.error( "IOException: " + e.getMessage(), e ); } - ; } /** - * Method generateTags - * - * @param tagList + * @see org.apache.forrest.forrestdoc.java.src.symtab.Definition#generateTags(org.apache.forrest.forrestdoc.java.src.symtab.HTMLTagContainer) */ public void generateTags(HTMLTagContainer tagList) { - String linkString; - String linkFileName; String nameString = "" + getName() + ""; @@ -145,17 +144,18 @@ } /** - * Method getOccurrenceTag - * - * @param occ - * @return + * @see org.apache.forrest.forrestdoc.java.src.symtab.Definition#getOccurrenceTag(org.apache.forrest.forrestdoc.java.src.symtab.Occurrence) */ public HTMLTag getOccurrenceTag(Occurrence occ) { + if (log.isDebugEnabled()) + { + log.debug("getOccurrenceTag(Occurrence) - Occurrence occ=" + occ); + } + String linkString; String linkFileName; - // System.out.println("Occurrence:"+o.getLine()); linkFileName = getRelativePath(occ) + getSourceName(); linkString = "".getBytes()); } catch (IOException ioe) { - ioe.printStackTrace(); + log.error( "IOException: " + ioe.getMessage(), ioe ); } - System.out.println("Html generated with success!"); + if ( log.isInfoEnabled() ) + { + log.info( "Html generated with success!"); + } } public static void main(String args[]) throws Exception{ GenerateHTMLDoc main1 = new GenerateHTMLDoc(new File(args[0]), args[1]); - } } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Modified: forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/js/doc/GenerateHTMLIndex.java URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/js/doc/GenerateHTMLIndex.java?view=diff&rev=556752&r1=556751&r2=556752 ============================================================================== --- forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/js/doc/GenerateHTMLIndex.java (original) +++ forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/js/doc/GenerateHTMLIndex.java Mon Jul 16 15:17:40 2007 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,6 +17,8 @@ package org.apache.forrest.forrestdoc.js.doc; +import org.apache.log4j.Logger; + import org.apache.tools.ant.BuildException; import java.io.BufferedReader; @@ -29,12 +31,17 @@ import java.util.Vector; /** - * Searches all javascript files and creates a index HTML - * with links to documentation + * Searches all javascript files and creates a index HTML + * with links to documentation + * + * @version $Id: $ */ public class GenerateHTMLIndex { - private static File file, file2 = null; + /** Logger for this class */ + private static final Logger log = Logger.getLogger( GenerateHTMLIndex.class ); + + private static File file = null; private static FileInputStream fis; private static FileOutputStream fos; private static BufferedReader br; @@ -59,13 +66,13 @@ } file = new File(jSDir); - + if (!file.isDirectory()) { throw new BuildException("destDir has to be a directory"); } - + collectFiles(file, v); - + try { fos = new FileOutputStream(destDir + "index.htm"); @@ -75,6 +82,7 @@ file.mkdir(); fos = new FileOutputStream(destDir + "index.htm"); } catch (FileNotFoundException e) { + log.error( "FileNotFoundException: " + e.getMessage(), e ); } } try { @@ -103,9 +111,17 @@ file = (File) v.get(i); docGenerator = new GenerateHTMLDoc(file, destDir); } - System.out.println("Number of .js files: " + v.size()); + + if ( log.isInfoEnabled() ) + { + log.info( "Number of .js files: " + v.size()); + } + for (int i = 0; i < v.size(); i++) { - System.out.println(file.getName()); + if ( log.isInfoEnabled() ) + { + log.info( "file: " + file.getName()); + } file = (File) v.get(i); fos.write(("" + LINE_SEPARATOR).getBytes()); @@ -134,7 +150,7 @@ } } catch (FileNotFoundException fnfe) { - fnfe.printStackTrace(); + log.error( "FileNotFoundException: " + fnfe.getMessage(), fnfe ); } fos.write(("" + LINE_SEPARATOR).getBytes()); @@ -146,45 +162,24 @@ fos.write("".getBytes()); } catch (IOException ioe) { - ioe.printStackTrace(); + log.error( "IOException: " + ioe.getMessage(), ioe ); } } - + 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]); } } - - - - - - - - - - - - - - - - - - - - - Modified: forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/js/doc/JSDocTask.java URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/js/doc/JSDocTask.java?view=diff&rev=556752&r1=556751&r2=556752 ============================================================================== --- forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/js/doc/JSDocTask.java (original) +++ forrest/trunk/whiteboard/forrestdoc/src/java/org/apache/forrest/forrestdoc/js/doc/JSDocTask.java Mon Jul 16 15:17:40 2007 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,7 +21,9 @@ import org.apache.tools.ant.Task; /** - * Ant task responsible for creating automatic documentation for .js files + * Ant task responsible for creating automatic documentation for .js files + * + * @version $Id: $ */ public class JSDocTask extends Task { @@ -38,7 +40,7 @@ /** * Sets the destDir. - * + * * @param destDir The destDir to set */ public void setDestDir(String destDir) { @@ -47,13 +49,10 @@ /** * Sets the jSDir. - * + * * @param jSDir The jSDir to set */ public void setJSDir(String jSDir) { this.jSDir = jSDir; } - } - -