From 19bdb5f18c6bec508ede7fa0d666dca0bc3fe444 Mon Sep 17 00:00:00 2001 From: yaacovCR Date: Fri, 25 Mar 2016 08:43:38 -0400 Subject: [PATCH 1/2] Add support for constructor functions A la grunt-ngdocs https://github.com/m7r/grunt-ngdocs/commit/c985bc6d --- src/ngdoc.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ngdoc.js b/src/ngdoc.js index 7f21675..09a5e6e 100644 --- a/src/ngdoc.js +++ b/src/ngdoc.js @@ -461,6 +461,8 @@ Doc.prototype = { } else if(atName == 'eventType') { match = text.match(/(broadcast|emit)/); self.type = match[1]; + } else if(atName == 'constructor') { + self.constructor = true; } else { self[atName] = text; } @@ -656,6 +658,9 @@ Doc.prototype = { dom.h('Usage', function() { dom.code(function() { + if (self.constructor) { + dom.text('new '); + } dom.text(name.split(':').pop()); dom.text('('); self.parameters(dom, ', '); From a8e229cef7c994dd837af4c7849cfe2dedee11a4 Mon Sep 17 00:00:00 2001 From: yaacovCR Date: Mon, 28 Mar 2016 01:16:47 -0400 Subject: [PATCH 2/2] [fix] Doc.constructor always returned true grunt-ngdocs likely has identical bug, secondary to constructor property on prototype and truthy versus truth. --- src/ngdoc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ngdoc.js b/src/ngdoc.js index 09a5e6e..d6fcbf3 100644 --- a/src/ngdoc.js +++ b/src/ngdoc.js @@ -462,7 +462,7 @@ Doc.prototype = { match = text.match(/(broadcast|emit)/); self.type = match[1]; } else if(atName == 'constructor') { - self.constructor = true; + self.functionIsConstructor = true; } else { self[atName] = text; } @@ -658,7 +658,7 @@ Doc.prototype = { dom.h('Usage', function() { dom.code(function() { - if (self.constructor) { + if (self.functionIsConstructor) { dom.text('new '); } dom.text(name.split(':').pop());