ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject cvs commit: jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet TaskTagsHandler.java
Date Wed, 19 Jun 2002 04:34:57 GMT
ehatcher    2002/06/18 21:34:57

  Modified:    proposal/xdocs Tag: ANT_15_BRANCH build.xml
               proposal/xdocs/templates Tag: ANT_15_BRANCH
                        task_xdoc.template
               proposal/xdocs/src/org/apache/tools/ant/xdoclet Tag:
                        ANT_15_BRANCH TaskTagsHandler.java
  Log:
  lots of tweaks and hacks to get this all working.  i know, should not commit on the 1.5
branch, but i've already committed these files once and HEAD has not been touched.  refactorings
are certainly in order, but so far its generating nice output at least.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.9.2.1   +10 -7     jakarta-ant/proposal/xdocs/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/xdocs/build.xml,v
  retrieving revision 1.9
  retrieving revision 1.9.2.1
  diff -u -r1.9 -r1.9.2.1
  --- build.xml	23 Mar 2002 03:14:46 -0000	1.9
  +++ build.xml	19 Jun 2002 04:34:57 -0000	1.9.2.1
  @@ -45,6 +45,9 @@
         <pathelement location="${build.dir}"/>
       </path>
   
  +    <property name="the.classpath" refid="xdoclet.classpath"/>
  +    <echo>the.classpath = ${the.classpath}</echo>
  +
       <taskdef name="document"
                classname="xdoclet.doc.DocumentDocletTask"
                classpathref="xdoclet.classpath"/>
  @@ -71,7 +74,7 @@
              classpathref="xdoclet.classpath">
         <fileset dir="${src.dir}">
           <include name="**/*.java" unless="class.name"/>
  -        <include name="**/${class.name}.java" if="class.name"/>
  +        <include name="**/*${class.name}*.java" if="class.name"/>
         </fileset>
   
         <!-- Generate XML task descriptor files -->
  @@ -79,9 +82,9 @@
                destinationfile="{0}.xml"/>
   
         <!-- Generate XML datatype descriptor files -->
  -      <datatypes templateFile="${datatype_xdoc.template}"
  +<!--      <datatypes templateFile="${datatype_xdoc.template}"
                    destdir="${gen.dir}/datatypes"
  -                 destinationfile="{0}.xml"/>
  +                 destinationfile="{0}.xml"/> -->
   
         <!-- @todo - with some additional logic in these subtasks, they
              could be used similar to above instead of <template> -->
  @@ -91,14 +94,14 @@
                   destinationfile="task_defaults.properties"/>
   
         <!-- Generate datatype defaults.properties -->
  -      <template subTaskClassName="org.apache.tools.ant.xdoclet.DatatypeSubTask"
  +<!--      <template subTaskClassName="org.apache.tools.ant.xdoclet.DatatypeSubTask"
                   templateFile="${type.properties.template}"
  -                destinationfile="type_defaults.properties"/>
  +                destinationfile="type_defaults.properties"/> -->
   
         <!-- Generate to-do list -->
  -      <info destdir="${gen.dir}/todo/ant"
  +<!--      <info destdir="${gen.dir}/todo/ant"
               header="To-do List"
  -            projectname="Ant"/>
  +            projectname="Ant"/> -->
       </xdocs>
   
     </target>
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.5.2.2   +4 -12     jakarta-ant/proposal/xdocs/templates/task_xdoc.template
  
  Index: task_xdoc.template
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/xdocs/templates/task_xdoc.template,v
  retrieving revision 1.5.2.1
  retrieving revision 1.5.2.2
  diff -u -r1.5.2.1 -r1.5.2.2
  --- task_xdoc.template	3 Jun 2002 03:28:45 -0000	1.5.2.1
  +++ task_xdoc.template	19 Jun 2002 04:34:57 -0000	1.5.2.2
  @@ -1,7 +1,8 @@
   <XDtTagDef:tagDef namespace="Ant" handler="org.apache.tools.ant.xdoclet.TaskTagsHandler"/>
   <task name="<XDtAnt:taskName/>" category="<XDtAnt:categoryName/>"
         classname="<XDtClass:fullClassName/>"
  -      <XDtClass:ifHasClassTag tagName="deprecated">deprecated="true"</XDtClass:ifHasClassTag>>
  +      <XDtClass:ifHasClassTag tagName="deprecated">deprecated="true"</XDtClass:ifHasClassTag>
  +      <XDtType:ifIsOfType type="org.apache.tools.ant.taskdefs.MatchingTask">matchingTask="true"</XDtType:ifIsOfType>>
   
     <XDtMerge:merge file="{0}.xml" generateMergedFile="false"></XDtMerge:merge>
   
  @@ -16,6 +17,7 @@
       <XDtAnt:forAllAttributes>
         <attribute name="<XDtMethod:propertyName/>" type="<XDtParameter:forAllMethodParams><XDtParameter:methodParamType/></XDtParameter:forAllMethodParams>"
                    <XDtMethod:ifHasMethodTag tagName="deprecated">deprecated="true"</XDtMethod:ifHasMethodTag>>
  +        <short-description><![CDATA[<XDtAnt:shortMethodDescription/>]]></short-description>
           <description><![CDATA[
             <XDtMethod:methodComment no-comment-signs="true"/>
           ]]></description>
  @@ -29,18 +31,8 @@
                  <XDtMethod:ifHasMethodTag tagName="deprecated">deprecated="true"</XDtMethod:ifHasMethodTag>
           <XDtClass:pushClass value="<XDtAnt:elementType/>">
                  <XDtClass:ifIsClassAbstract>abstract="true"</XDtClass:ifIsClassAbstract>>
  -        <XDtAnt:ifHasAttributes>
  -        <attributes>
  -          <XDtAnt:forAllAttributes>
  -          <attribute name="<XDtMethod:propertyName/>" type="<XDtParameter:forAllMethodParams><XDtParameter:methodParamType/></XDtParameter:forAllMethodParams>">
  -            <description><![CDATA[
  -              <XDtMethod:methodComment no-comment-signs="true"/>
  -            ]]></description>
  -          </attribute>
  -          </XDtAnt:forAllAttributes>
  -        </attributes>
  -        </XDtAnt:ifHasAttributes>
           </XDtClass:pushClass>
  +        <short-description><![CDATA[<XDtAnt:shortMethodDescription/>]]></short-description>
           <description>
             <![CDATA[<XDtMethod:methodComment no-comment-signs="true"/>]]>
           </description>
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.5   +70 -11    jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet/TaskTagsHandler.java
  
  Index: TaskTagsHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet/TaskTagsHandler.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- TaskTagsHandler.java	17 Jun 2002 05:46:57 -0000	1.1.2.4
  +++ TaskTagsHandler.java	19 Jun 2002 04:34:57 -0000	1.1.2.5
  @@ -53,12 +53,11 @@
    */
   package org.apache.tools.ant.xdoclet;
   
  -import com.sun.javadoc.ClassDoc;
  -import com.sun.javadoc.MethodDoc;
  -import com.sun.javadoc.Parameter;
  +import com.sun.javadoc.*;
   import org.apache.tools.ant.IntrospectionHelper;
   import xdoclet.XDocletException;
   import xdoclet.XDocletTagSupport;
  +import xdoclet.util.TypeConversionUtil;
   import xdoclet.tags.AbstractProgramElementTagsHandler;
   
   import java.util.ArrayList;
  @@ -222,6 +221,36 @@
           return getTaskName(getCurrentClass());
       }
   
  +    private static String[] fluffPrefixes = { "set a","set the","sets a","sets the" };
  +
  +    public String shortMethodDescription() throws XDocletException {
  +		Tag[] tags = getCurrentMethod().firstSentenceTags();
  +		String desc = null;
  +
  +		if( tags != null && tags.length > 0 ) {
  +			desc = tags[0].text();
  +        }
  +
  +		if( desc == null || desc.length() == 0 )
  +		{
  +        	desc = "no description";
  +		}
  +
  +        desc = desc.trim();
  +        String descLower = desc.toLowerCase();
  +        for (int i=0; i < fluffPrefixes.length; i++) {
  +            String prefix = fluffPrefixes[i].toLowerCase() + " ";
  +            if (descLower.startsWith(prefix)) {
  +                desc = desc.substring(prefix.length());
  +                break;
  +            }
  +        }
  +
  +        desc = desc.substring(0,1).toUpperCase() + desc.substring(1);
  +
  +		return desc;
  +    }
  +
       /**
        * Provides the Ant task name.
        *
  @@ -286,7 +315,7 @@
           try {
               is = IntrospectionHelper.getHelper(Class.forName(cur_class.qualifiedName()));
           } catch (ClassNotFoundException e) {
  -            throw new XDocletException(e.getMessage());
  +            throw new XDocletException(e,e.getMessage());
           }
   
           // Regroup the attributes, since IntrospectionHelper
  @@ -320,7 +349,14 @@
               }
               String attributeType = method.parameters()[0].typeName();
   
  -            if (!attributeType.equals(attributeTypeMap.getProperty(attributeName))) {
  +            String mapAttribute = attributeTypeMap.getProperty(attributeName);
  +            if (mapAttribute == null) {
  +                continue;
  +            }
  +
  +            // inner classes are noted with $ in our map, but not
  +            // n the parameter type name.
  +            if (!attributeType.equals(mapAttribute.replace('$','.'))) {
                   continue;
               }
   
  @@ -392,7 +428,7 @@
                   continue;
               }
   
  -            //System.out.println("elementName = " + elementName);
  +            System.out.println("elementName = " + elementName);
               String elementType = null;
               if (adder) {
                   if (method.parameters().length != 1) {
  @@ -407,8 +443,15 @@
                   continue;
               }
   
  -            //System.out.println(elementName + " = " + elementType);
  -            if (!elementType.equals(elementTypeMap.getProperty(elementName))) {
  +            String mapElementType = elementTypeMap.getProperty(elementName);
  +            System.out.println("elementType = " + elementType + " mapElementType = " +
mapElementType);
  +            if (mapElementType == null) {
  +                continue;
  +            }
  +
  +            // inner classes are noted with $ in our map, but not
  +            // the parameter type name.
  +            if (!elementType.equals(mapElementType.replace('$','.'))) {
                   continue;
               }
   
  @@ -432,16 +475,21 @@
           while (cur_class != null) {
               // hardcoded to stop when it hits Task, nothing there
               // or above that needs to be processed
  -            if (cur_class.qualifiedName().equals("org.apache.tools.ant.Task")) {
  +            if (cur_class.qualifiedName().equals("org.apache.tools.ant.Task") ||
  +                cur_class.qualifiedName().equals("org.apache.tools.ant.taskdefs.MatchingTask"))
{
                   break;
               }
               List curMethods = Arrays.asList(cur_class.methods());
   
               for (int j = 0; j < curMethods.size(); j++) {
                   MethodDoc method = (MethodDoc) curMethods.get(j);
  +                if (isDeprecated(method)) {
  +                  continue;
  +                }
  +                String methodName = method.name();
                   if (method.containingClass() == cur_class) {
  -                    if (already.containsKey(method) == false) {
  -                        already.put(method, method);
  +                    if (already.containsKey(methodName) == false) {
  +                        already.put(methodName, method);
                           methods.add(method);
                       }
                   }
  @@ -451,6 +499,17 @@
           }
   
           return sortMethods(methods);
  +    }
  +
  +    private boolean isDeprecated (MethodDoc method) {
  +        Tag[] tags = method.tags();
  +        for (int i=0; i < tags.length; i++) {
  +            System.out.println("tag = " + tags[i].name());
  +            if (tags[i].name().equals("@deprecated")) {
  +                return true;
  +            }
  +        }
  +        return false;
       }
   
       private MethodDoc[] sortMethods(List methods) {
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message