From 277d712f3ec465c554d419a34dfd149d89a3723c Mon Sep 17 00:00:00 2001 From: Jeff Williams Date: Mon, 11 Aug 2014 14:13:11 -0700 Subject: [PATCH] cleanup --- lib/jsdoc/tag/dictionary/definitions.js | 49 ++++++++++++------------- test/fixtures/interface-implements.js | 2 + 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/lib/jsdoc/tag/dictionary/definitions.js b/lib/jsdoc/tag/dictionary/definitions.js index 1ab92471..b3acc19a 100644 --- a/lib/jsdoc/tag/dictionary/definitions.js +++ b/lib/jsdoc/tag/dictionary/definitions.js @@ -146,6 +146,11 @@ function setDocletNameToFilename(doclet, tag) { doclet.name = name; } +function parseTypeText(text) { + var tagType = jsdoc.tag.type.parse(text, false, true); + return tagType.typeExpression || text; +} + function parseBorrows(doclet, tag) { var m = /^(\S+)(?:\s+as\s+(\S+))?$/.exec(tag.text); if (m) { @@ -222,11 +227,7 @@ exports.defineTags = function(dictionary) { dictionary.defineTag('augments', { mustHaveValue: true, // Allow augments value to be specified as a normal type, e.g. {Type} - onTagText: function(text) { - - var tagType = jsdoc.tag.type.parse(text, false, true); - return tagType.typeExpression || text; - }, + onTagText: parseTypeText, onTagged: function(doclet, tag) { doclet.augment( firstWordOf(tag.value) ); } @@ -268,26 +269,6 @@ exports.defineTags = function(dictionary) { }) .synonym('constructor'); - dictionary.defineTag('interface', { - mustNotHaveValue: true, - onTagged: function(doclet, tag) { - doclet.addTag('kind', 'interface'); - } - }); - - dictionary.defineTag('implements', { - mustHaveValue: true, - onTagText: function(text) { - return text.replace(/(^\{|\}$)/g, ''); - }, - onTagged: function(doclet, tag) { - if (!doclet.implements) { - doclet.implements = []; - } - doclet.implements.push(tag.value); - } - }); - dictionary.defineTag('classdesc', { onTagged: function(doclet, tag) { doclet.classdesc = tag.value; @@ -487,6 +468,24 @@ exports.defineTags = function(dictionary) { } }); + dictionary.defineTag('implements', { + mustHaveValue: true, + onTagText: parseTypeText, + onTagged: function(doclet, tag) { + if (!doclet.implements) { + doclet.implements = []; + } + doclet.implements.push(tag.value); + } + }); + + dictionary.defineTag('interface', { + mustNotHaveValue: true, + onTagged: function(doclet, tag) { + doclet.addTag('kind', 'interface'); + } + }); + dictionary.defineTag('kind', { mustHaveValue: true }); diff --git a/test/fixtures/interface-implements.js b/test/fixtures/interface-implements.js index c9308f59..58b9a3d2 100644 --- a/test/fixtures/interface-implements.js +++ b/test/fixtures/interface-implements.js @@ -54,6 +54,7 @@ MyTester.prototype.it = function() {}; * @interface */ function IWorker() {} +/** Interface for doing some work. */ IWorker.prototype.work = function() {}; /** @@ -61,6 +62,7 @@ IWorker.prototype.work = function() {}; * @implements {IWorker} */ function MyWorker() {} +/** Do some work. */ MyWorker.prototype.work = function() {}; MyWorker.prototype.process = function() {};