diff --git a/lib/jsdoc/src/handlers.js b/lib/jsdoc/src/handlers.js index bdb9e38c..931b239a 100644 --- a/lib/jsdoc/src/handlers.js +++ b/lib/jsdoc/src/handlers.js @@ -17,6 +17,7 @@ function getNewDoclet(parser, comment, e) { err = new Error( util.format('cannot create a doclet in the file %s for the comment ' + '"%s": %s', parser._currentSourceName, comment.replace(/[\r\n]/g, ''), error.message) ); require('jsdoc/util/error').handle(err); + return new jsdoc.doclet.Doclet('', {}); } } diff --git a/lib/jsdoc/util/templateHelper.js b/lib/jsdoc/util/templateHelper.js index 92de911b..b3353976 100644 --- a/lib/jsdoc/util/templateHelper.js +++ b/lib/jsdoc/util/templateHelper.js @@ -100,6 +100,20 @@ var tutorialLinkMap = { var longnameToUrl = exports.longnameToUrl = linkMap.longnameToUrl; +function parseType(longname) { + var catharsis = require('catharsis'); + var err; + + try { + return catharsis.parse(longname, {jsdoc: true}); + } + catch (e) { + err = new Error('unable to parse ' + longname + ': ' + e.message); + require('jsdoc/util/error').handle(err); + return longname; + } +} + /** * Retrieve an HTML link to the member with the specified longname. If the longname is not * associated with a URL, this method returns the link text, if provided, or the longname. @@ -123,19 +137,16 @@ var linkto = exports.linkto = function(longname, linktext, cssClass) { var url = hasOwnProp.call(longnameToUrl, longname) && longnameToUrl[longname]; var parsedType; - // type applications require special treatment - var typeAppInfo = /(\S+)<(\S+)>/.exec(longname); - if (typeAppInfo) { - typeAppInfo[1] = linkto(typeAppInfo[1], null, cssClass); - parsedType = catharsis.parse(typeAppInfo[2], {jsdoc: true}); - typeAppInfo[2] = catharsis.stringify(parsedType, { + // handle complex type expressions that may require multiple links + if (text.search(/[<{(]/) !== -1) { + parsedType = parseType(longname); + return catharsis.stringify(parsedType, { cssClass: cssClass, htmlSafe: true, links: longnameToUrl }); - return typeAppInfo[1] + '<' + typeAppInfo[2] + '>'; } - + if (!url) { return text; }