Extracts comments from a file into an array or mulit-dementional array when the "text" arg contains mulitple package or namepsace definitions.
Each entry in the returned array will be an object containing 3 properties
start : The line number that the comment started on
end : The line number that the comment ended on
data : The contents of the comment
var myComments = extract(str);
yields : [
{
start : 12,
end : 32,
data : "the descript"
},
{
start : 12,
end : 32,
data : "the descript"
}
]
A few things of note:
- The data will NOT include the beginDoc, nor the endDoc strings.
- Comment prefixing is stripped
- * [star space]
- tabs
- spaces - Code blocks maintain indentation.
- Splitting on package or namespace. When a single file contains mulitple references to a "package" or "namespace" comments will split into multiple arrays -- treating the single source file as being mulitple files.
Split Example:
/**
* Class A
* @package foo <-- this designates a new "page"
*/
/**
* Something for A
* @method something
*/
/**
* Class B
* @package bar <-- this designates a new "page"
*/
/**
* Something for B
* @method something
*/
var myComments = extract(str);
yields : [
[ // the first "page"
{
start : 12,
end : 32,
data : "Class A ... "
},
{
start : 12,
end : 32,
data : "Something for A ..."
},
],
[ // the second "page"
{
start : 64,
end : 96,
data : "Class B ... "
},
{
start : 128,
end : 142,
data : "Something for B ..."
},
,
]
the entire file as a string
The string is used to "open" a comment.
The string is used to "close" a comment.
An array of comments, or multi-dimentional array oaf page comments.