maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r589140 - in /maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/html: Pass1.java Pass2.java
Date Sat, 27 Oct 2007 15:46:18 GMT
Author: vsiveton
Date: Sat Oct 27 08:46:18 2007
New Revision: 589140

URL: http://svn.apache.org/viewvc?rev=589140&view=rev
Log:
o imptoved the rendering to make difference between Javadoc comments (i.e. /** ... */) and
other comments (i.e. /* ... */)
o added encoding option for JavaDocBuilder
o improve performance

Modified:
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/html/Pass1.java
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/html/Pass2.java

Modified: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/html/Pass1.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/html/Pass1.java?rev=589140&r1=589139&r2=589140&view=diff
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/html/Pass1.java
(original)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/html/Pass1.java
Sat Oct 27 08:46:18 2007
@@ -23,7 +23,6 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
-import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.LineNumberReader;
@@ -48,11 +47,6 @@
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.StringUtils;
 
-import com.thoughtworks.qdox.JavaDocBuilder;
-import com.thoughtworks.qdox.model.Annotation;
-import com.thoughtworks.qdox.model.DocletTag;
-import com.thoughtworks.qdox.model.JavaMethod;
-
 import antlr.ANTLRException;
 
 /**
@@ -67,6 +61,32 @@
     /** Logger for this class  */
     private static final Logger log = Logger.getLogger( Pass1.class );
 
+    /**
+     * Default Javadoc tags.
+     *
+     * @see <a href="http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html#javadoctags">http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html#javadoctags</a>
+     */
+    private static final String[] TAGS = {
+        "@author",
+        "{@code}",
+        "{@docRoot}",
+        "@deprecated",
+        "@exception",
+        "{@inheritDoc}",
+        "{@link}",
+        "{@linkplain}",
+        "{@literal}",
+        "@param",
+        "@return",
+        "@see",
+        "@serial",
+        "@serialData",
+        "@serialField",
+        "@since",
+        "@throws",
+        "{@value}",
+        "@version" };
+
     int currentColumn;
 
     int currentChar;
@@ -495,7 +515,7 @@
         int i = 0;
 
         StringBuffer sb = new StringBuffer();
-        sb.append( "<SPAN CLASS=\"multiLinesComment\">" );
+        sb.append( "<SPAN CLASS=\"singleLineComment\">" );
 
         while ( i < length )
         {
@@ -521,7 +541,7 @@
 
             if ( currentChar == '\n' )
             {
-                sb.append( "<SPAN CLASS=\"multiLinesComment\">" );
+                sb.append( "<SPAN CLASS=\"singleLineComment\">" );
                 currentColumn = 0;
             }
 
@@ -534,27 +554,17 @@
 
         String comment = sb.toString();
 
-        // Highlight Javadoc reserved words
-        File javaFile = t.getFile();
-        JavaDocBuilder builder = new JavaDocBuilder();
-        builder.addSource( new FileReader( javaFile ) );
-        DocletTag[] classTags = builder.getClasses()[0].getTags();
-        for ( int j = 0; j < classTags.length; j++ )
-        {
-            comment = StringUtils.replace( comment, "@" + classTags[j].getName(), "<B>@"
+ classTags[j].getName()
-                + "</B>" );
-        }
-        JavaMethod[] methods = builder.getClasses()[0].getMethods();
-        for ( int j = 0; j < methods.length; j++ )
+        // Javadoc comments
+        if ( comment.startsWith( "<SPAN CLASS=\"singleLineComment\">/**" ) )
         {
-            DocletTag[] methodTags = methods[j].getTags();
-            for ( int k = 0; k < methodTags.length; k++ )
+            comment = StringUtils.replace( comment, "singleLineComment", "multiLinesComment"
);
+
+            // Highlight Javadoc reserved words
+            for ( int j = 0; j < TAGS.length; j++ )
             {
-                comment = StringUtils.replace( comment, "@" + methodTags[k].getName(), "<B>@"
+ methodTags[k].getName()
-                    + "</B>" );
+                comment = StringUtils.replace( comment, TAGS[j], "<B>" + TAGS[j] +
"</B>" );
             }
         }
-
         output.write( comment );
 
         if ( currentChar == '\n' )

Modified: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/html/Pass2.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/html/Pass2.java?rev=589140&r1=589139&r2=589140&view=diff
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/html/Pass2.java
(original)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/html/Pass2.java
Sat Oct 27 08:46:18 2007
@@ -957,14 +957,18 @@
 
             List classes = orderedPackageClasses( packageName );
 
-            JavaDocBuilder builder = new JavaDocBuilder();
+            JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
+            if ( StringUtils.isNotEmpty( getOptions().getEncoding() ) )
+            {
+                javaDocBuilder.setEncoding( getOptions().getEncoding() );
+            }
             for ( Iterator it = getSrcDirs().iterator(); it.hasNext(); )
             {
                 String srcDir = (String) it.next();
                 File packageDir = new File( srcDir, packageName.replace( '.', File.separatorChar
) + File.separatorChar );
                 if ( packageDir.exists() )
                 {
-                    builder.addSourceTree( packageDir );
+                    javaDocBuilder.addSourceTree( packageDir );
                 }
             }
 
@@ -1058,7 +1062,7 @@
                 pw.println( "</TD>" );
 
                 JavaClass clazz = null;
-                JavaClass[] clazzes = builder.getClasses();
+                JavaClass[] clazzes = javaDocBuilder.getClasses();
                 for ( int i = 0; i < clazzes.length; i++ )
                 {
                     if ( clazzes[i].getName().equals( className ) )



Mime
View raw message