From 434fa8175a39f159142e191dbb83a90c757b90c5 Mon Sep 17 00:00:00 2001 From: Erik Hatcher Date: Thu, 28 Feb 2002 03:45:09 +0000 Subject: [PATCH] Changes by Bill Burton to collect tasks into categories rather than package space. Very cool, thanks! git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271596 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/xdoclet/AntSubTask.java | 8 +---- .../tools/ant/xdoclet/AntTagsHandler.java | 31 +++++++++++++++++++ proposal/xdocs/templates/task_xdoc.template | 3 +- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/proposal/xdocs/src/org/apache/tools/ant/xdoclet/AntSubTask.java b/proposal/xdocs/src/org/apache/tools/ant/xdoclet/AntSubTask.java index 086c182f7..954924359 100644 --- a/proposal/xdocs/src/org/apache/tools/ant/xdoclet/AntSubTask.java +++ b/proposal/xdocs/src/org/apache/tools/ant/xdoclet/AntSubTask.java @@ -83,11 +83,6 @@ public class AntSubTask extends TemplateSubTask { * - and only throw BuildException if at all */ protected boolean matchesGenerationRules(ClassDoc clazz) throws XDocletException { - - if (clazz.isAbstract()) { - return false; - } - return isAntTask(clazz);; } @@ -124,8 +119,7 @@ public class AntSubTask extends TemplateSubTask { 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}); } diff --git a/proposal/xdocs/src/org/apache/tools/ant/xdoclet/AntTagsHandler.java b/proposal/xdocs/src/org/apache/tools/ant/xdoclet/AntTagsHandler.java index 2b4ebedfd..1de8ae711 100644 --- a/proposal/xdocs/src/org/apache/tools/ant/xdoclet/AntTagsHandler.java +++ b/proposal/xdocs/src/org/apache/tools/ant/xdoclet/AntTagsHandler.java @@ -81,6 +81,9 @@ import java.util.Properties; */ 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 */ @@ -163,6 +166,7 @@ public class AntTagsHandler extends XDocletTagSupport { * Provides the Ant task name. * * @see getTaskName + * @doc:tag type="content" */ public String taskName() throws XDocletException { return getTaskName(getCurrentClass()); @@ -197,6 +201,33 @@ public class AntTagsHandler extends XDocletTagSupport { } + /** + * 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, + * @ant:task category="...". 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; + } + + /** * Returns true if the method corresponds to an Ant task attribute using * the rules from IntrospectionHelper diff --git a/proposal/xdocs/templates/task_xdoc.template b/proposal/xdocs/templates/task_xdoc.template index 5bc6e1d02..21b60cf54 100644 --- a/proposal/xdocs/templates/task_xdoc.template +++ b/proposal/xdocs/templates/task_xdoc.template @@ -1,6 +1,7 @@ - + ]]>