Summary
Searches files for a regular-expression and produces an XML report of
the matches.
- Assembly
- NAnt
.Contrib .dll - Namespace
- NAnt
.Contrib .Tasks .Grep - Base Types
-
- Task
graph BT
Type-->Base0["Task"]
Type["GrepTask"]
class Type type-node
Syntax
[TaskName("grep")]
public class GrepTask : Task
Examples
Extract all TODO:, UNDONE: or HACK:- comment-tags from C# source files and write them to a file out.xml. (A xslt-stylesheet could then transform it to a nice html-page for your project-homepage, but that is beyond the scope of this example.)
Path, File and LineNumber are automatically generated elements.
<grep output="out.xml" pattern="// (?'Type'TODO|UNDONE|HACK): (\[(?'Author'\w*),(?'Date'.*)\])? (?'Text'[^\n\r]*)">
<fileset>
<include name="*.cs" />
</fileset>
</grep>
The resulting XML file for a comment-tag 'TODO: [md, 14-02-2004] comment this method' will look like
<?xml version="1.0" encoding="utf-8" ?>
<Matches>
<Match>
<Type>TODO</Type>
<Text>comment this method</Text>
<Path>C:\MyProjects\MyPath</Path>
<File>MyFile.cs</Filename>
<LineNumber>146</LineNumber>
<Author>md</Author>
<Date>14-02-2004</Date>
</Match>
...
</Matches>
Attributes
Type | Description |
---|---|
TaskName |
Properties
Name | Value | Summary |
---|---|---|
InputFiles | FileSet |
The set of files in which the expression is searched.
|
OutputFile | FileInfo |
Specifies the name of the output file.
|
Pattern | string |
Specifies the regular-expression to search for.
|
Methods
Name | Value | Summary |
---|---|---|
ExecuteTask |
void |
Performs the regex-search.
|