From 8f5f41f78c365eb049fde76eef1f9d9ac1f66504 Mon Sep 17 00:00:00 2001 From: Michael Mathews Date: Sun, 16 Jan 2011 12:08:23 +0000 Subject: [PATCH] Tests for @augment and @private. --- modules/jsdoc/doclet.js | 5 ---- modules/jsdoc/tag/dictionary/definitions.js | 29 ++++++++++++--------- test/cases/augmentstag.js | 14 ++++++++++ test/cases/privatetag.js | 11 ++++++++ test/runner.js | 2 ++ test/t/cases/augmentstag.js | 12 +++++++++ test/t/cases/privatetag.js | 11 ++++++++ 7 files changed, 66 insertions(+), 18 deletions(-) create mode 100644 test/cases/augmentstag.js create mode 100644 test/cases/privatetag.js create mode 100644 test/t/cases/augmentstag.js create mode 100644 test/t/cases/privatetag.js diff --git a/modules/jsdoc/doclet.js b/modules/jsdoc/doclet.js index f759f6dc..85fdbfbb 100644 --- a/modules/jsdoc/doclet.js +++ b/modules/jsdoc/doclet.js @@ -75,11 +75,6 @@ applyTag.call(this, newTag); } - exports.Doclet.prototype.augment = function(base) { - if (!this.mixins) { this.mixins = []; } - this.mixins.push( {source: source, target: (target||'this')} ); - } - exports.Doclet.prototype.setMemberof = function(sid) { this.memberof = sid; } diff --git a/modules/jsdoc/tag/dictionary/definitions.js b/modules/jsdoc/tag/dictionary/definitions.js index 96332ed9..226a4495 100644 --- a/modules/jsdoc/tag/dictionary/definitions.js +++ b/modules/jsdoc/tag/dictionary/definitions.js @@ -31,25 +31,28 @@ } }); + // I add on to that dictionary.defineTag('augments', { mustHaveValue: true, onTagged: function(doclet, tag) { - doclet.augment(tag.value); - - return false; - } - }) - .synonym('extends'); - - dictionary.defineTag('borrows', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - parseBorrows(doclet, tag); + doclet.augment( firstWordOf(tag.value) ); return false; } }) .synonym('extends') + .synonym('inherits'); + + // that adds on to me + dictionary.defineTag('borrows', { + mustHaveValue: true, + onTagged: function(doclet, tag) { + var [target, source] = parseBorrows(doclet, tag); + doclet.borrow(target, source); + + return false; + } + }) .synonym('mixes'); dictionary.defineTag('class', { @@ -444,10 +447,10 @@ var m = /^(\S+)(?:\s+as\s+(\S+))?$/.exec(tag.text); if (m) { if (m[1] && m[2]) { - doclet.borrow(m[1], m[2]); + return [ m[1], m[2] ]; } else if (m[1]) { - doclet.borrow(m[1]); + return [ m[1] ]; } } } diff --git a/test/cases/augmentstag.js b/test/cases/augmentstag.js new file mode 100644 index 00000000..7c2bd4c5 --- /dev/null +++ b/test/cases/augmentstag.js @@ -0,0 +1,14 @@ +/** +* @constructor +*/ +function Foo() { +} + + +/** +* @extends Foo +*/ +function Bar() { +} + + diff --git a/test/cases/privatetag.js b/test/cases/privatetag.js new file mode 100644 index 00000000..71e0d971 --- /dev/null +++ b/test/cases/privatetag.js @@ -0,0 +1,11 @@ +/** +* @constructor +* @private +*/ +function Foo() { + + /** document me */ + this.bar = 1; +} + + diff --git a/test/runner.js b/test/runner.js index 847632ea..70460019 100644 --- a/test/runner.js +++ b/test/runner.js @@ -89,6 +89,7 @@ testFile('test/t/cases/modules/data/mod-2.js'); testFile('test/t/cases/alias.js'); testFile('test/t/cases/alias2.js'); +testFile('test/t/cases/augmentstag.js'); testFile('test/t/cases/accesstag.js'); testFile('test/t/cases/authortag.js'); testFile('test/t/cases/copyrighttag.js'); @@ -97,6 +98,7 @@ testFile('test/t/cases/exceptiontag.js'); testFile('test/t/cases/globaltag.js'); testFile('test/t/cases/ignoretag.js'); testFile('test/t/cases/paramtag.js'); +testFile('test/t/cases/privatetag.js'); testFile('test/t/cases/requirestag.js'); testFile('test/t/cases/returnstag.js'); testFile('test/t/cases/seetag.js'); diff --git a/test/t/cases/augmentstag.js b/test/t/cases/augmentstag.js new file mode 100644 index 00000000..dbaf4b0c --- /dev/null +++ b/test/t/cases/augmentstag.js @@ -0,0 +1,12 @@ +(function() { + var docSet = testhelpers.getDocSetFromFile('test/cases/augmentstag.js'), + foo = docSet.getByLongname('Foo')[0], + bar = docSet.getByLongname('Bar')[0]; + + //dump(docSet.doclets); exit(0); + + test('When a symbol has an @augments tag, the doclet has a augments property that includes that value.', function() { + assert.equal(typeof bar.augments, 'object'); + assert.equal(bar.augments[0], 'Foo'); + }); +})(); \ No newline at end of file diff --git a/test/t/cases/privatetag.js b/test/t/cases/privatetag.js new file mode 100644 index 00000000..9eae4304 --- /dev/null +++ b/test/t/cases/privatetag.js @@ -0,0 +1,11 @@ +(function() { + var docSet = testhelpers.getDocSetFromFile('test/cases/privatetag.js'), + foo = docSet.getByLongname('Foo')[0], + bar = docSet.getByLongname('Foo#bar')[0]; + + //dump(docSet.doclets); exit(0); + + test('When a symbol has an @private tag, the doclet has an access property that is "private".', function() { + assert.equal(foo.access, 'private'); + }); +})(); \ No newline at end of file