diff --git a/modules/jsdoc/doclet.js b/modules/jsdoc/doclet.js index d431bf39..cf5d7b26 100644 --- a/modules/jsdoc/doclet.js +++ b/modules/jsdoc/doclet.js @@ -98,7 +98,7 @@ */ exports.Doclet.prototype.borrow = function(source, target) { if (!this.borrowed) { this.borrowed = []; } - this.borrowed.push( {from: source, as: (target||'this')} ); + this.borrowed.push( {from: source, as: (target||source)} ); } exports.Doclet.prototype.augment = function(base) { diff --git a/package.json b/package.json index 45510207..47757df5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jsdoc", "version": "3.0.0beta1", - "revision": "2011-01-24-2242", + "revision": "2011-01-30-1553", "description": "An automatic documentation generator for javascript.", "keywords": [ "documentation", "javascript" ], "licenses": [ diff --git a/test/cases/borrowstag2.js b/test/cases/borrowstag2.js new file mode 100644 index 00000000..797c446d --- /dev/null +++ b/test/cases/borrowstag2.js @@ -0,0 +1,14 @@ +/** @namespace + @borrows rtrim +*/ +var str = { + rtrim: rtrim +}; + +/** + Remove whitespace from the right side of a string. + @param {string} str + */ +function rtrim(str) { +} + diff --git a/test/runner.js b/test/runner.js index 5181246d..dad77e87 100644 --- a/test/runner.js +++ b/test/runner.js @@ -93,6 +93,7 @@ testFile('test/t/cases/alias3.js'); testFile('test/t/cases/augmentstag.js'); testFile('test/t/cases/authortag.js'); testFile('test/t/cases/borrowstag.js'); +testFile('test/t/cases/borrowstag2.js'); testFile('test/t/cases/classtag.js'); testFile('test/t/cases/constructstag.js'); testFile('test/t/cases/constructstag2.js'); diff --git a/test/t/cases/borrowstag.js b/test/t/cases/borrowstag.js index 666c5fb3..4bef5814 100644 --- a/test/t/cases/borrowstag.js +++ b/test/t/cases/borrowstag.js @@ -6,7 +6,7 @@ //dump(found); - test('When a symbol has a @borrows tag, that is added to the symbol\'s "borrowed" property.', function() { + test('When a symbol has a @borrows-as tag, that is added to the symbol\'s "borrowed" property.', function() { assert.equal(util.borrowed.length, 1); assert.equal(util.borrowed[0].from, 'trstr'); assert.equal(util.borrowed[0].as, 'trim'); diff --git a/test/t/cases/borrowstag2.js b/test/t/cases/borrowstag2.js new file mode 100644 index 00000000..e7fcd17d --- /dev/null +++ b/test/t/cases/borrowstag2.js @@ -0,0 +1,14 @@ +(function() { + var docSet = testhelpers.getDocSetFromFile('test/cases/borrowstag2.js'), + str = docSet.getByLongname('str').filter(function($) { + return ! $.undocumented; + })[0]; + + //dump(found); + + test('When a symbol has a @borrows tag, that is added to the symbol\'s "borrowed" property and the from is the same as the as property.', function() { + assert.equal(str.borrowed.length, 1); + assert.equal(str.borrowed[0].from, 'rtrim'); + assert.equal(str.borrowed[0].as, str.borrowed[0].from); + }); +})(); \ No newline at end of file