diff --git a/lib/jsdoc/tag/type.js b/lib/jsdoc/tag/type.js index a14df5be..d36b6820 100644 --- a/lib/jsdoc/tag/type.js +++ b/lib/jsdoc/tag/type.js @@ -35,7 +35,7 @@ function unescapeBraces(text) { var count = 0; var position = 0; var expression = ''; - var startIndex = string.indexOf('{'); + var startIndex = string.search(/\{[^@]/); var textStartIndex; if (startIndex !== -1) { diff --git a/test/fixtures/returnstag.js b/test/fixtures/returnstag.js index d3cf4de4..f8282770 100644 --- a/test/fixtures/returnstag.js +++ b/test/fixtures/returnstag.js @@ -9,3 +9,11 @@ function find(targetName) { */ function bind(callback) { } + +// This test exists because there used to be a bug in jsdoc which +// would cause it to fail parsing. +/** +* @return An object to be passed to {@link find}. +*/ +function convert(name) { +} diff --git a/test/specs/tags/returnstag.js b/test/specs/tags/returnstag.js index 2fcf2e59..ac8d890f 100644 --- a/test/specs/tags/returnstag.js +++ b/test/specs/tags/returnstag.js @@ -1,7 +1,8 @@ describe("@returns tag", function() { var docSet = jasmine.getDocSetFromFile('test/fixtures/returnstag.js'), find = docSet.getByLongname('find')[0], - bind = docSet.getByLongname('bind')[0]; + bind = docSet.getByLongname('bind')[0], + convert = docSet.getByLongname('convert')[0]; it('When a symbol has an @returns tag with a type and description, the doclet has a returns array that includes that return.', function() { expect(typeof find.returns).toBe('object'); @@ -15,4 +16,10 @@ describe("@returns tag", function() { expect(bind.returns.length).toBe(1); expect(bind.returns[0].description).toBe('The binding id.'); }); + + it('When a symbol has an @returns tag wihtout a type but with an inline tag, the doclet does not confuse the inline tag for a type.', function() { + expect(typeof convert.returns).toBe('object'); + expect(convert.returns.length).toBe(1); + expect(convert.returns[0].description).toBe('An object to be passed to {@link find}.'); + }); });