Hello Erik,

I implemented support for @ant:task category="...".  Attached is a patch.

0. If a category attribute isn't specified, "other" is used.

1. The lower cased version of the category is now used as the output
directory.  Previously, this was based on the class package converted to a
directory tree.

2. The generated XML now contains a category attribute, i.e.:
   <task name="ant" category="control"
      classname="org.apache.tools.ant.taskdefs.Ant">

-Bill

Bill Burton wrote:
> 
> Hello Erik,
> 
> Erik Hatcher wrote:
> > I did not inject the
> > @ant:task category="..." into the XML yet, but that is the goal so that we
> > can segregate these things in our manual by type of functionality similar to
> > Diane's work.
> 
> When you implement support for categories, I suggest making
> AntSubTask.getGeneratedFileName return the destination directory based on
> the @ant:category tag rather than the package directory.  This way, the
> generated XML will be in the same relative directory structure we'll want
> for the transformed HTML.  Otherwise, it will be rather messy trying to do
> this as part of the XML to HTML transformation.
> 
> -Bill
> P.S. Where's Diane's work?
--- ./src/org/apache/tools/ant/xdoclet/AntSubTask.java.orig     Wed Feb 27 
14:39:41 2002
+++ ./src/org/apache/tools/ant/xdoclet/AntSubTask.java  Wed Feb 27 20:25:37 2002
@@ -124,8 +124,7 @@
         String dir = getDestDir().getAbsolutePath();
 
         if (filename.indexOf("{0}") != -1) {
-            PackageDoc pak = clazz.containingPackage();
-            dir = PackageTagsHandler.packageNameAsPathFor(pak);
+            dir = AntTagsHandler.getCategoryName(clazz);
             String taskName = AntTagsHandler.getTaskName(clazz);
             filename = MessageFormat.format(getDestinationFile(), new 
Object[]{taskName});
         }
--- ./src/org/apache/tools/ant/xdoclet/AntTagsHandler.java.orig Wed Feb 27 
14:39:41 2002
+++ ./src/org/apache/tools/ant/xdoclet/AntTagsHandler.java      Wed Feb 27 
20:44:17 2002
@@ -81,6 +81,9 @@
  */
 public class AntTagsHandler extends XDocletTagSupport {
 
+    /** Default category for tasks without a category attribute. */
+    public static final String DEFAULT_CATEGORY = "other";
+
     /**
      * @todo add check for execute method
      */
@@ -192,6 +195,33 @@
             }
 
             tagValue = tagValue.toLowerCase();
+        }
+        return tagValue;
+    }
+
+
+    /**
+     * Provides the Ant category name.
+     *
+     * @see getCategoryName
+     */
+    public String categoryName() throws XDocletException {
+        return getCategoryName(getCurrentClass());
+    }
+
+    /**
+     * Provides the Ant category name as the Value of the category attribute, 
+     * <code>@ant:task&nbsp;category="..."</code>.  This attribute is 
mandatory.
+     */
+    public static final String getCategoryName(ClassDoc clazz) throws 
XDocletException {
+        String tagValue = getTagValue(clazz, "ant:task", "category", -1,
+                null, null, null, null,
+                null, false, XDocletTagSupport.FOR_CLASS, true);
+        if (tagValue != null) {
+            tagValue = tagValue.toLowerCase();
+        }
+        else {
+            tagValue = DEFAULT_CATEGORY;
         }
         return tagValue;
     }
--- ./templates/task_xdoc.template.orig Wed Feb 27 00:26:41 2002
+++ ./templates/task_xdoc.template      Wed Feb 27 20:04:59 2002
@@ -1,6 +1,7 @@
 <XDtTagDef:tagDef namespace="Ant" 
handler="org.apache.tools.ant.xdoclet.AntTagsHandler"/>
 
-<task name="<XDtAnt:taskName/>" classname="<XDtClass:fullClassName/>">
+<task name="<XDtAnt:taskName/>" category="<XDtAnt:categoryName/>"
+      classname="<XDtClass:fullClassName/>">
 
   
<short-description><![CDATA[<XDtClass:firstSentenceDescription/>]]></short-description>
   <long-description>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to