From 1c52170c096ca912c4871becb25c150d9cc0261c Mon Sep 17 00:00:00 2001 From: mathematicalcoffee Date: Fri, 8 Feb 2013 13:52:12 +1000 Subject: [PATCH] FIX: in Tag constructor, we should look up the tag definition using the trimmed (and lowercased) title --- lib/jsdoc/tag.js | 3 ++- test/specs/jsdoc/tag.js | 20 ++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/jsdoc/tag.js b/lib/jsdoc/tag.js index 349b15c5..32808562 100644 --- a/lib/jsdoc/tag.js +++ b/lib/jsdoc/tag.js @@ -41,13 +41,14 @@ function trim(text, newlines) { @param {object=} meta */ exports.Tag = function(tagTitle, tagBody, meta) { - var tagDef = jsdoc.tag.dictionary.lookUp(tagTitle); meta = meta || {}; this.originalTitle = trim(tagTitle); /** The title part of the tag: @title text */ this.title = jsdoc.tag.dictionary.normalise( this.originalTitle ); + + var tagDef = jsdoc.tag.dictionary.lookUp(this.title); /** The text part of the tag: @title text */ this.text = trim(tagBody, tagDef.keepsWhitespace); diff --git a/test/specs/jsdoc/tag.js b/test/specs/jsdoc/tag.js index e874a097..e40a55a5 100644 --- a/test/specs/jsdoc/tag.js +++ b/test/specs/jsdoc/tag.js @@ -19,12 +19,11 @@ describe("jsdoc/tag", function() { describe('Tag', function() { var meta = {lineno: 1, filename: 'asdf.js'}, desc = 'lalblakd lkjasdlib\n lija', - text = '{!number} [foo=] - ' + desc, + text = '{!number} [foo=1] - ' + desc, textEg = 'Asdf\n' + ' * myFunction(1, 2); // returns 3\n' + ' * myFunction(3, 4); // returns 7\n'; - // note arg is a synonym of param. - var tagArg = new jsdoc.tag.Tag('arg ', text, meta), // <-- a symonym, space in the title. + var tagArg = new jsdoc.tag.Tag('arg ', text, meta), // <-- a symonym of param, space in the title. tagEg = new jsdoc.tag.Tag('example', textEg, meta), // <-- for keepsWhitespace tagType = new jsdoc.tag.Tag('type', 'MyType ', meta); // <-- for onTagText @@ -78,9 +77,6 @@ describe("jsdoc/tag", function() { }); }); - // BUG: when Tag() looks up a tag definition it should used the trimmed tag title. - // otherwise, tag properties are not looked up. - // This makes all of tagArg.value wrong (because of the spaces in the name). describe("'value' property", function() { it("'value' property should equal tag text if tagDef.canHaveType and canHaveName are both false", function() { // @example can't have type or name @@ -90,7 +86,7 @@ describe("jsdoc/tag", function() { it("'value' property should be an object if tagDef can have type or name", function () { expect(typeof tagType.value).toEqual('object'); - // expect(typeof tagArg.value).toEqual('object'); + expect(typeof tagArg.value).toEqual('object'); }); function verifyTagType(tag) { @@ -113,19 +109,19 @@ describe("jsdoc/tag", function() { it("if the tag has a type, tag.value should contain the type information", function() { // we assume jsdoc/tag/type.parse works (it has its own tests to verify this); verifyTagType(tagType); - // verifyTagType(tagArg); + verifyTagType(tagArg); }); it("if the tag has a description beyond the name/type, this should be in tag.value.description", function() { expect(tagType.value.description).not.toBeDefined(); - // expect(tagArg.value.description).toBeDefined(); - // expect(tagArg.value.description).toEqual(desc); + expect(tagArg.value.description).toBeDefined(); + expect(tagArg.value.description).toEqual(desc); }); it("if the tag can have a name, it should be stored in tag.value.name", function() { - //expect(tagArg.value.name).toBeDefined(); - //expect(tagArg.value.name).toEqual('foo'); + expect(tagArg.value.name).toBeDefined(); + expect(tagArg.value.name).toEqual('foo'); expect(tagType.value.name).not.toBeDefined(); });