maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r417945 - /maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
Date Thu, 29 Jun 2006 05:51:09 GMT
Author: brett
Date: Wed Jun 28 22:51:08 2006
New Revision: 417945

URL: http://svn.apache.org/viewvc?rev=417945&view=rev
Log:
[MPLUGIN-7] improve reference documentation
Submitted by: Edwin Punzalan

Modified:
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java

Modified: maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java?rev=417945&r1=417944&r2=417945&view=diff
==============================================================================
--- maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
(original)
+++ maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
Wed Jun 28 22:51:08 2006
@@ -28,6 +28,7 @@
 import java.io.IOException;
 import java.util.Iterator;
 import java.util.List;
+import java.util.ArrayList;
 
 /**
  * @todo add example usage tag that can be shown in the doco
@@ -271,12 +272,6 @@
 
         w.endElement(); // p
 
-        w.startElement( "p" );
-
-        w.writeText( "Parameters for the goal: " );
-
-        w.endElement(); // p
-
         writeGoalParameterTable( mojoDescriptor, w );
 
         w.endElement(); // section
@@ -288,214 +283,167 @@
 
     private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w )
     {
-        w.startElement( "table" );
-
-        w.startElement( "tr" );
-
-        w.startElement( "th" );
-
-        w.writeText( "Parameter" );
+        List parameterList = mojoDescriptor.getParameters();
 
-        w.endElement(); // th
+        //remove components and read-only parameters
+        List list = filterParameters( parameterList );
 
-        w.startElement( "th" );
-
-        w.writeText( "Type" );
-
-        w.endElement(); // th
-
-        w.startElement( "th" );
-
-        w.writeText( "Expression" );
-
-        w.endElement(); // th
-
-        w.startElement( "th" );
-
-        w.writeText( "Default Value" );
-
-        w.endElement(); // th
-
-        w.startElement( "th" );
-
-        w.writeText( "Since" );
-
-        w.endElement(); // th
-
-        w.startElement( "th" );
-
-        w.writeText( "Description" );
-
-        w.endElement(); // th
-
-        w.endElement(); // tr
-
-        List parameters = mojoDescriptor.getParameters();
-
-        if ( parameters != null )
+        if ( list != null )
         {
-            for ( int i = 0; i < parameters.size(); i++ )
-            {
-                Parameter parameter = (Parameter) parameters.get( i );
-
-                w.startElement( "tr" );
-
-                // ----------------------------------------------------------------------
-                //
-                // ----------------------------------------------------------------------
-
-                w.startElement( "td" );
-
-                String paramName = parameter.getAlias();
-
-                if ( StringUtils.isEmpty( paramName ) )
-                {
-                    paramName = parameter.getName();
-                }
-
-                w.startElement( "code" );
-
-                w.writeText( paramName );
-
-                w.endElement(); // code
-
-                if ( !parameter.isRequired() )
-                {
-                    w.writeMarkup( " <i>(Optional)</i>" );
-                }
-
-                if ( parameter.getExpression() != null && parameter.getExpression().startsWith(
"${component." ) )
-                {
-                    w.writeMarkup( " <i>(Discovered)</i>" );
-                }
-                else if ( parameter.getRequirement() != null )
-                {
-                    w.writeMarkup( " <i>(Discovered)</i>" );
-                }
-
-                w.endElement(); // td
+            writeParameterSummary( list, w );
 
-                // ----------------------------------------------------------------------
-                //
-                // ----------------------------------------------------------------------
+            writeParameterDetails( list, w );
+        }
+    }
 
-                w.startElement( "td" );
+    private List filterParameters( List parameterList )
+    {
+        List filtered = new ArrayList();
 
-                w.startElement( "code" );
+        for ( Iterator parameters = parameterList.iterator(); parameters.hasNext(); )
+        {
+            Parameter parameter = (Parameter) parameters.next();
 
-                w.addAttribute( "title", parameter.getType() );
+            if ( parameter.isEditable() )
+            {
+                String expression = parameter.getExpression();
 
-                int index = parameter.getType().lastIndexOf( "." );
-                if ( index >= 0 )
+                if ( expression != null && !expression.startsWith( "${component."
) )
                 {
-                    w.writeText( parameter.getType().substring( index + 1 ) );
-                }
-                else
-                {
-                    w.writeText( parameter.getType() );
+                    filtered.add( parameter );
                 }
+            }
+        }
 
-                w.endElement(); // code
+        return filtered;
+    }
 
-                w.endElement(); // td
+    private void writeParameterDetails( List parameterList, XMLWriter w )
+    {
+        w.startElement( "section" );
+        w.addAttribute( "name", "Parameter Details" );
 
-                // ----------------------------------------------------------------------
-                //
-                // ----------------------------------------------------------------------
+        for( Iterator parameters = parameterList.iterator(); parameters.hasNext(); )
+        {
+            Parameter parameter = (Parameter) parameters.next();
 
-                w.startElement( "td" );
+            w.writeMarkup( "<p><b><a name=\"" + parameter.getName() + "\">"
+ parameter.getName() + "</a></b></p>" );
+            w.writeMarkup( "<p/>" );
 
-                w.startElement( "code" );
+            String description = parameter.getDescription();
+            if ( StringUtils.isEmpty( description ) )
+            {
+                description = "No Description.";
+            }
+            w.writeMarkup( "<p>" + description + "</p>" );
 
-                if ( StringUtils.isNotEmpty( parameter.getExpression() ) &&
-                    !parameter.getExpression().startsWith( "${component." ) )
-                {
-                    w.writeText( parameter.getExpression() );
-                }
-                else
-                {
-                    w.writeText( "-" );
-                }
+            w.startElement( "ul" );
 
-                w.endElement(); // code
+            writeDetail( "Type", parameter.getType(), w );
 
-                w.endElement(); // td
+            writeDetail( "Since", parameter.getSince(), w );
 
-                // ----------------------------------------------------------------------
-                //
-                // ----------------------------------------------------------------------
+            if ( parameter.isRequired() )
+            {
+                writeDetail( "Required", "Yes", w );
+            }
+            else
+            {
+                writeDetail( "Required", "No", w );
+            }
 
-                w.startElement( "td" );
+            writeDetail( "Expression", parameter.getExpression(), w );
 
-                w.startElement( "code" );
+            writeDetail( "Default", parameter.getDefaultValue(), w );
 
-                if ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) )
-                {
-                    w.writeText( parameter.getDefaultValue() );
-                }
-                else
-                {
-                    w.writeText( "-" );
-                }
+            w.endElement();//ul
 
-                w.endElement(); // code
+            w.writeMarkup( "<hr/>" );
+        }
 
-                w.endElement(); // td
+        w.endElement();
+    }
 
-                // ----------------------------------------------------------------------
-                //
-                // ----------------------------------------------------------------------
+    private void writeDetail( String param, String value, XMLWriter w )
+    {
+        if ( StringUtils.isNotEmpty( value ) )
+        {
+            w.writeMarkup( "<li><b>" + param + "</b>: <code>" + value
+ "</code></li>" );
+        }
+    }
 
-                w.startElement( "td" );
+    private void writeParameterSummary( List parameterList, XMLWriter w )
+    {
+        List requiredParams = getParametersByRequired( true, parameterList );
+        List optionalParams = getParametersByRequired( false, parameterList );
 
-                w.startElement( "code" );
+        writeParameterList( "Required Parameters", requiredParams, w );
+        writeParameterList( "Optional Parameters", optionalParams, w );
+    }
 
-                String since = parameter.getSince();
-                if ( StringUtils.isNotEmpty( since ) )
-                {
-                    w.writeText( since );
-                }
-                else
-                {
-                    w.writeText( "-" );
-                }
+    private void writeParameterList( String title, List parameterList, XMLWriter w )
+    {
+        w.startElement( "section" );
+        w.addAttribute( "name", title );
 
-                w.endElement(); // code
+        w.startElement( "table" );
 
-                w.endElement(); // td
+        w.startElement( "tr" );
+        w.startElement( "th" );
+        w.writeText( "Name" );
+        w.endElement();//th
+        w.startElement( "th" );
+        w.writeText( "Type" );
+        w.endElement();//th
+        w.startElement( "th" );
+        w.writeText( "Description" );
+        w.endElement();//th
+        w.endElement();//tr
 
-                // ----------------------------------------------------------------------
-                //
-                // ----------------------------------------------------------------------
+        for( Iterator parameters = parameterList.iterator(); parameters.hasNext(); )
+        {
+            Parameter parameter = (Parameter) parameters.next();
 
-                w.startElement( "td" );
+            w.startElement( "tr" );
+            w.startElement( "td" );
+            w.writeMarkup( "<b><a href=\"#" + parameter.getName() + "\">" + parameter.getName()
+ "</a></b>");
+            w.endElement();//td
+            w.startElement( "td" );
+            int index = parameter.getType().lastIndexOf( "." );
+            w.writeMarkup( "<code>" + parameter.getType().substring( index + 1 ) +
"</code>" );
+            w.endElement();//td
+            w.startElement( "td" );
+            String description = parameter.getDescription();
+            if ( StringUtils.isEmpty( description ) )
+            {
+                w.writeText( "No description." );
+            }
+            else
+            {
+                w.writeMarkup( parameter.getDescription() );
+            }
+            w.endElement();//td
+            w.endElement(); //tr
+        }
 
-                if ( StringUtils.isNotEmpty( parameter.getDescription() ) )
-                {
-                    w.writeMarkup( parameter.getDescription() );
-                }
-                else
-                {
-                    w.writeText( "No description." );
-                }
+        w.endElement();//table
+        w.endElement();//section
+    }
 
-                String deprecationWarning = parameter.getDeprecated();
-                if ( deprecationWarning != null )
-                {
-                    w.writeMarkup( "<br/><b>Deprecated:</b> " );
-                    w.writeMarkup( deprecationWarning );
-                    if ( deprecationWarning.length() == 0 )
-                    {
-                        w.writeText( "No reason given." );
-                    }
-                }
+    private List getParametersByRequired( boolean required, List parameterList )
+    {
+        List list = new ArrayList();
 
-                w.endElement(); // td
+        for ( Iterator parameters = parameterList.iterator(); parameters.hasNext(); )
+        {
+            Parameter parameter = (Parameter) parameters.next();
 
-                w.endElement(); // tr
+            if ( parameter.isRequired() == required )
+            {
+                list.add( parameter );
             }
         }
 
-        w.endElement(); // table
+        return list;
     }
-}
\ No newline at end of file
+}



Mime
View raw message