You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2012/05/20 21:16:01 UTC

svn commit: r1340805 - in /maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main: java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java resources/pluginxdoc.properties resources/pluginxdoc_fr.properties

Author: hboutemy
Date: Sun May 20 19:16:01 2012
New Revision: 1340805

URL: http://svn.apache.org/viewvc?rev=1340805&view=rev
Log:
[MPLUGIN-201] added "User Property" to the parameter description report to clearly show the property that can be used to override default value of a parameter

Modified:
    maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
    maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/resources/pluginxdoc.properties
    maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/resources/pluginxdoc_fr.properties

Modified: maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java?rev=1340805&r1=1340804&r2=1340805&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java Sun May 20 19:16:01 2012
@@ -462,7 +462,8 @@ public class PluginXdocGenerator
      */
     private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w )
     {
-        @SuppressWarnings( "unchecked" ) List<Parameter> parameterList = mojoDescriptor.getParameters();
+        @SuppressWarnings( "unchecked" )
+        List<Parameter> parameterList = mojoDescriptor.getParameters();
 
         //remove components and read-only parameters
         List<Parameter> list = filterParameters( parameterList );
@@ -608,16 +609,14 @@ public class PluginXdocGenerator
                 addedUl = true;
             }
             String expression = parameter.getExpression();
-            if ( StringUtils.isNotEmpty( expression ) && expression.startsWith( "${" ) && expression.endsWith( "}" )
-                && !expression.substring( 2 ).contains( "${" ) )
+            String property = getPropertyFromExpression( expression );
+            if ( property == null )
             {
-                // expression="${xxx}" -> property="xxx"
-                String property = expression.substring( 2, expression.length() - 1 );
-                writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.property" ), property, w );
+                writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.expression" ), expression, w );
             }
             else
             {
-                writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.expression" ), parameter.getExpression(), w );
+                writeDetail( getString( "pluginxdoc.mojodescriptor.parameter.property" ), property, w );
             }
 
             if ( !addedUl && StringUtils.isNotEmpty( parameter.getDefaultValue() ) )
@@ -642,6 +641,18 @@ public class PluginXdocGenerator
         w.endElement();
     }
 
+    private String getPropertyFromExpression( String expression )
+    {
+        if ( StringUtils.isNotEmpty( expression ) && expression.startsWith( "${" ) && expression.endsWith( "}" )
+            && !expression.substring( 2 ).contains( "${" ) )
+        {
+            // expression="${xxx}" -> property="xxx"
+            return expression.substring( 2, expression.length() - 1 );
+        }
+        // no property can be extracted
+        return null;
+    }
+    
     /**
      * @param param not null
      * @param value could be null
@@ -712,13 +723,19 @@ public class PluginXdocGenerator
         for ( Parameter parameter : parameterList )
         {
             w.startElement( "tr" );
+
+            // name
             w.startElement( "td" );
             w.writeMarkup( format( "pluginxdoc.mojodescriptor.parameter.name_link", parameter.getName() ) );
             w.endElement(); //td
+
+            //type
             w.startElement( "td" );
             int index = parameter.getType().lastIndexOf( "." );
             w.writeMarkup( "<code>" + parameter.getType().substring( index + 1 ) + "</code>" );
             w.endElement(); //td
+
+            // since
             w.startElement( "td" );
             if ( StringUtils.isNotEmpty( parameter.getSince() ) )
             {
@@ -736,6 +753,8 @@ public class PluginXdocGenerator
                 }
             }
             w.endElement(); //td
+
+            // description
             w.startElement( "td" );
             String description;
             if ( StringUtils.isNotEmpty( parameter.getDeprecated() ) )
@@ -757,7 +776,15 @@ public class PluginXdocGenerator
             {
                 w.writeMarkup( format( "pluginxdoc.mojodescriptor.parameter.defaultValue",
                                        escapeXml( parameter.getDefaultValue() ) ) );
+                w.writeMarkup( "<br/>" );
             }
+
+            String property = getPropertyFromExpression( parameter.getExpression() );
+            if ( property != null )
+            {
+                w.writeMarkup( format( "pluginxdoc.mojodescriptor.parameter.property.description", property ) );
+            }
+
             w.endElement(); //td
             w.endElement(); //tr
         }

Modified: maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/resources/pluginxdoc.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/resources/pluginxdoc.properties?rev=1340805&r1=1340804&r2=1340805&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/resources/pluginxdoc.properties (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/resources/pluginxdoc.properties Sun May 20 19:16:01 2012
@@ -50,6 +50,7 @@ pluginxdoc.mojodescriptor.parameter.sinc
 pluginxdoc.mojodescriptor.parameter.required=Required
 pluginxdoc.mojodescriptor.parameter.expression=Expression
 pluginxdoc.mojodescriptor.parameter.property=User Property
+pluginxdoc.mojodescriptor.parameter.property.description=<strong>User property is</strong>: <code>{0}</code>.
 pluginxdoc.mojodescriptor.parameter.default=Default
 pluginxdoc.mojodescriptor.parameter.defaultValue=<strong>Default value is</strong>: <code>{0}</code>.
 pluginxdoc.mojodescriptor.requiredParameters=Required Parameters

Modified: maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/resources/pluginxdoc_fr.properties
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/resources/pluginxdoc_fr.properties?rev=1340805&r1=1340804&r2=1340805&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/resources/pluginxdoc_fr.properties (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-generators/src/main/resources/pluginxdoc_fr.properties Sun May 20 19:16:01 2012
@@ -49,8 +49,9 @@ pluginxdoc.mojodescriptor.parameter.sinc
 pluginxdoc.mojodescriptor.parameter.required=Exig\u00e9
 pluginxdoc.mojodescriptor.parameter.expression=Expression
 pluginxdoc.mojodescriptor.parameter.property=Propri\u00e9t\u00e9 utilisateur
+pluginxdoc.mojodescriptor.parameter.property.description=<strong>Propri\u00e9t\u00e9 utilisateur</strong> : <code>{0}</code>.
 pluginxdoc.mojodescriptor.parameter.default=D\u00e9faut
-pluginxdoc.mojodescriptor.parameter.defaultValue=<strong>Valeur par d\u00e9faut est</strong> : <code>{0}</code>.
+pluginxdoc.mojodescriptor.parameter.defaultValue=<strong>Valeur par d\u00e9faut</strong> : <code>{0}</code>.
 pluginxdoc.mojodescriptor.requiredParameters=Param\u00e8tres requis
 pluginxdoc.mojodescriptor.optionalParameters=Param\u00e8tres optionnels
 pluginxdoc.mojodescriptor.parameters=Param\u00e8tres