Permalink
Browse files

Completed documentation for taskdef task.

  • Loading branch information...
1 parent 87bc794 commit 996f32b5df8c283089e37058f739d7beb7b737f6 FlukeFan committed Jan 26, 2007
Showing with 148 additions and 37 deletions.
  1. +84 −11 Source/NAntTasks/TaskDefTask.cs
  2. +64 −26 Source/Source.build
@@ -28,8 +28,81 @@ namespace broloco.NAntTasks
/// </remarks>
/// <example>
/// <para>
+ /// Create a custom task that takes two parameters. Parameter 1 can be set to 'echo' or 'fail', and
+ /// parameter 2 is the message to echo/fail.
/// <code>
/// <![CDATA[
+ /// <taskdef name="echoFail" >
+ ///
+ /// <stringparams>
+ /// <stringparam name="task" />
+ /// <stringparam name="message" required="false" />
+ /// </stringparams>
+ ///
+ /// <do>
+ /// <property name="customMessage" value="__message__" />
+ /// <if test="${customMessage == ''}" >
+ /// <property name="customMessage" value="this is a default message" />
+ /// </if>
+ /// <__task__ message="${customMessage}" />
+ /// </do>
+ ///
+ /// </taskdef>
+ /// ...
+ /// <!-- echos the default message -->
+ /// <echoFail task="echo" />
+ /// ...
+ /// <echoFail task="fail" message="this will fail the build" />
+ /// ]]>
+ /// </code>
+ /// </para>
+ /// </example>
+ /// <example>
+ /// <para>
+ /// Create a custom task that takes a list of source files, target files, and
+ /// a list of tasks to execute when the target files are not up to date.
+ /// <code>
+ /// <![CDATA[
+ /// <taskdef name="execIfNotUpToDate" >
+ ///
+ /// <nodeparams>
+ /// <nodeparam name="sourceFiles" />
+ /// <nodeparam name="targetFiles" />
+ /// <nodeparam name="do" />
+ /// </nodeparams>
+ ///
+ /// <do>
+ /// <uptodate property="execIfNotUpToDate.uptodate">
+ /// <sourcefiles>
+ /// <__sourceFiles__/>
+ /// </sourcefiles>
+ /// <targetfiles>
+ /// <__targetFiles__/>
+ /// </targetfiles>
+ /// </uptodate>
+ /// <if test="${not execIfNotUpToDate.uptodate}" >
+ /// <__do__/>
+ /// </if>
+ /// </do>
+ ///
+ /// </taskdef>
+ /// ...
+ /// <!-- echos the a message if the files are not up to date -->
+ /// <execIfNotUpToDate>
+ ///
+ /// <sourceFiles>
+ /// <include name="*.cs" />
+ /// </sourceFiles>
+ ///
+ /// <targetFiles>
+ /// <include name="myAssembly.dll" />
+ /// </targetFiles>
+ ///
+ /// <do>
+ /// <echo message="work needs done" />
+ /// </do>
+ ///
+ /// </execIfNotUpToDate>
/// ]]>
/// </code>
/// </para>
@@ -99,27 +172,27 @@ public string GenerateCSharpCode()
// generate named string parameters
foreach (StringParam stringParam in StringParams)
{
- customTaskCode += " private string _" + stringParam.ParameterName + " = string.Empty ;\n";
+ customTaskCode += " private string __" + stringParam.ParameterName + " = string.Empty ;\n";
customTaskCode += "\n";
customTaskCode += " [TaskAttribute(\"" + stringParam.ParameterName + "\", Required=" + stringParam.Required.ToString().ToLower() + ")]\n";
- customTaskCode += " public string " + stringParam.ParameterName + "\n";
+ customTaskCode += " public string _" + stringParam.ParameterName + "\n";
customTaskCode += " {\n";
- customTaskCode += " get { return _" + stringParam.ParameterName + "; }\n";
- customTaskCode += " set { _" + stringParam.ParameterName + " = value; }\n";
+ customTaskCode += " get { return __" + stringParam.ParameterName + "; }\n";
+ customTaskCode += " set { __" + stringParam.ParameterName + " = value; }\n";
customTaskCode += " }\n";
customTaskCode += "\n";
}
// generate named xml-node parameters
foreach (NodeParam nodeParam in NodeParams)
{
- customTaskCode += " private RawXml _" + nodeParam.ParameterName + ";\n";
+ customTaskCode += " private RawXml __" + nodeParam.ParameterName + ";\n";
customTaskCode += "\n";
customTaskCode += " [BuildElement(\"" + nodeParam.ParameterName + "\", Required=" + nodeParam.Required.ToString().ToLower() + ")]\n";
- customTaskCode += " public RawXml " + nodeParam.ParameterName + "\n";
+ customTaskCode += " public RawXml _" + nodeParam.ParameterName + "\n";
customTaskCode += " {\n";
- customTaskCode += " get { return _" + nodeParam.ParameterName + "; }\n";
- customTaskCode += " set { _" + nodeParam.ParameterName + " = value; }\n";
+ customTaskCode += " get { return __" + nodeParam.ParameterName + "; }\n";
+ customTaskCode += " set { __" + nodeParam.ParameterName + " = value; }\n";
customTaskCode += " }\n";
customTaskCode += "\n";
}
@@ -142,9 +215,9 @@ public string GenerateCSharpCode()
customTaskCode += " nodes = scriptDom.SelectNodes(\"//__" + nodeParam.ParameterName + "__\");\n";
customTaskCode += " foreach (XmlNode node in nodes)\n";
customTaskCode += " {\n";
- customTaskCode += " if (" + nodeParam.ParameterName + " != null)\n";
+ customTaskCode += " if (_" + nodeParam.ParameterName + " != null)\n";
customTaskCode += " {\n";
- customTaskCode += " foreach (XmlNode task in " + nodeParam.ParameterName + ".Xml.ChildNodes)\n";
+ customTaskCode += " foreach (XmlNode task in _" + nodeParam.ParameterName + ".Xml.ChildNodes)\n";
customTaskCode += " {\n";
customTaskCode += " node.ParentNode.InsertBefore(scriptDom.ImportNode(task, true), node);\n";
customTaskCode += " }\n";
@@ -157,7 +230,7 @@ public string GenerateCSharpCode()
customTaskCode += " xml = scriptDom.OuterXml;\n";
foreach (StringParam stringParam in StringParams)
{
- customTaskCode += " xml = xml.Replace(\"__" + stringParam.ParameterName + "__\", " + stringParam.ParameterName + ");\n";
+ customTaskCode += " xml = xml.Replace(\"__" + stringParam.ParameterName + "__\", _" + stringParam.ParameterName + ");\n";
}
customTaskCode += " scriptDom.LoadXml(xml);\n";
View
@@ -39,32 +39,70 @@
<nant buildfile="Tests\Tests.build" inheritall="true" target="build"/>
- <ndoc>
- <assemblies basedir="${build.dir}/bin">
- <include name="broloco.NAntTasks.dll" />
- </assemblies>
- <documenters>
- <documenter name="NAnt">
- <property name="OutputDirectory" value="${build.dir}/doc/help" />
- <property name="SdkDocVersion" value="SDK_v1_1" />
- <property name="SdkLinksOnWeb" value="false" />
- <!-- set base uri used for linking to other NAnt docs -->
- <property name="NAntBaseUri" value="http://nant.sourceforge.net/release/latest/help/" />
- <!-- do not filter on namespace -->
- <property name="NamespaceFilter" value="" />
- <!-- set the name and version of the product for which docs are generated -->
- <property name="ProductName" value="NAntScript" />
- <property name="ProductVersion" value="${project.version}" />
- <property name="ProductUrl" value="http://code.google.com/p/nantscript" />
- <property name="Preliminary" value="${not(project.config == 'release')}" />
- <property name="DocumentAttributes" value="True" />
- <property name="IncludeAssemblyVersion" value="True" />
- <property name="ShowMissingParams" value="True" />
- <property name="ShowMissingReturns" value="True" />
- <property name="ShowMissingValues" value="True" />
- </documenter>
- </documenters>
- </ndoc>
+ <taskdef name="execIfNotUpToDate" >
+
+ <nodeparams>
+ <nodeparam name="sourceFiles" />
+ <nodeparam name="targetFiles" />
+ <nodeparam name="do" />
+ </nodeparams>
+
+ <do>
+ <uptodate property="execIfNotUpToDate.uptodate">
+ <sourcefiles>
+ <__sourceFiles__/>
+ </sourcefiles>
+ <targetfiles>
+ <__targetFiles__/>
+ </targetfiles>
+ </uptodate>
+ <if test="${not execIfNotUpToDate.uptodate}" >
+ <__do__/>
+ </if>
+ </do>
+
+ </taskdef>
+
+ <execIfNotUpToDate>
+
+ <sourceFiles>
+ <include name="${build.dir}/bin/broloco.NAntTasks.dll" />
+ </sourceFiles>
+
+ <targetFiles>
+ <include name="${build.dir}/doc/help/tasks/taskdef.html" />
+ </targetFiles>
+
+ <do>
+ <ndoc>
+ <assemblies basedir="${build.dir}/bin">
+ <include name="broloco.NAntTasks.dll" />
+ </assemblies>
+ <documenters>
+ <documenter name="NAnt">
+ <property name="OutputDirectory" value="${build.dir}/doc/help" />
+ <property name="SdkDocVersion" value="SDK_v1_1" />
+ <property name="SdkLinksOnWeb" value="true" />
+ <!-- set base uri used for linking to other NAnt docs -->
+ <property name="NAntBaseUri" value="http://nant.sourceforge.net/release/latest/help/" />
+ <!-- do not filter on namespace -->
+ <property name="NamespaceFilter" value="" />
+ <!-- set the name and version of the product for which docs are generated -->
+ <property name="ProductName" value="NAntScript" />
+ <property name="ProductVersion" value="${project.version}" />
+ <property name="ProductUrl" value="http://code.google.com/p/nantscript" />
+ <property name="Preliminary" value="${not(project.config == 'release')}" />
+ <property name="DocumentAttributes" value="True" />
+ <property name="IncludeAssemblyVersion" value="True" />
+ <property name="ShowMissingParams" value="True" />
+ <property name="ShowMissingReturns" value="True" />
+ <property name="ShowMissingValues" value="True" />
+ </documenter>
+ </documenters>
+ </ndoc>
+ </do>
+
+ </execIfNotUpToDate>
<delete dir="${build.dir}/doc/help/enums" />
<delete dir="${build.dir}/doc/help/filters" />

0 comments on commit 996f32b

Please sign in to comment.