[JSDoc] Handle missing @constructor

WTD-1482
This commit is contained in:
Victor Woeltjen 2015-08-07 11:41:02 -07:00
parent 1558c9d1bd
commit 2f79323264

View File

@ -31,7 +31,20 @@
rewriter._transform = function (chunk, encoding, done) {
var data = String(chunk);
if (!reachedConstructor) {
if (data.match(/^ *\* @constructor/)) {
// First, check for constructors missing @constructor
if (data.match(/^ *\*\//) && data.indexOf("*") > 3) {
// Track position to detect inner methods
starDepth = data.indexOf("*");
reachedConstructor = true;
// Add a @memberof <namespace> annotation
this.push(spaces(starDepth) + "* @constructor\n");
this.push([
spaces(starDepth),
"* @memberof ",
bundleName(filename),
"\n"
].join(""));
} else if (data.match(/^ *\* @constructor/)) {
// Track position to detect inner methods
starDepth = data.indexOf("*");
reachedConstructor = true;