Friday, 1 January 2010

NAnt.ToDo a NAnt Plugin

This simple plugin for NAnt parses your source code and creates a report of all the TODO and comment tags in your source code. The code is hosted over at google code.

Comments


The task automatically identify comments in the following style

//TODO: First Test to do Item
//FIXME: First Fix me Item
//HACK: First Hack Item


Additional matches can be made by adding in Token elements to the NAnt task.

Sample



<ToDo source="path/to/source" output="report.xml" searchpattern="*.cs;*.txt">
<Tokens>
<Tokens Value="BUGFIX" />
</Tokens>
</ToDo>


Output



<ToDo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Items>
<Item>
<Message>First Test to do Item</Message>
<File>NAnt.ToDo\ToDoTask.cs</File>
<Line>0</Line>
<Type>TODO</Type>
</Item>
<Item>
<Message>First Hack Item</Message>
<File>NAnt.ToDo\ToDoTask.cs</File>
<Line>0</Line>
<Type>HACK</Type>
</Item>
<Item>
<Message>First Fix me Item</Message>
<File>NAnt.ToDo\ToDoTask.cs</File>
<Line>0</Line>
<Type>FIXME</Type>
</Item>
</Items>
</ToDo>


Cruise Control Xsl


Below is a basic xsl style sheet that can be used with CruiseControl.NET to display the output from NAnt.ToDo.

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:param name="applicationPath"/>
<xsl:template match="/">
<div id="ToDo">
<h1>ToDo List</h1>
<div id="Summary">
<h3>To Do</h3>
<table>
<tbody>
<xsl:for-each select="//ToDo/Items/Item">
<tr>
<td>
<xsl:value-of select="Type/text()"/>
</td>
<td>
<xsl:value-of select="Message/text()"/>
</td>
<td>
<xsl:value-of select="File/text()"/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</div>    
</div>
</xsl:template>
</xsl:stylesheet>

No comments:

Post a Comment