keep the link text for longnames with variations (#857)

This commit is contained in:
Jeff Williams 2014-12-30 16:40:03 -08:00
parent 59fec8c696
commit 60b239fd33
2 changed files with 9 additions and 1 deletions

View File

@ -264,7 +264,7 @@ function hasUrlPrefix(text) {
function isComplexTypeExpression(expr) {
// record types, type unions, and type applications all count as "complex"
return expr.search(/[{(|]/) !== -1 || expr.search(/</) > 0;
return /^{.+}$/.test(expr) || /^.+\|.+$/.test(expr) || /^.+<.+>$/.test(expr);
}
function fragmentHash(fragmentId) {

View File

@ -333,11 +333,13 @@ describe("jsdoc/util/templateHelper", function() {
beforeEach(function() {
helper.longnameToUrl.linktoTest = 'test.html';
helper.longnameToUrl.LinktoFakeClass = 'fakeclass.html';
helper.longnameToUrl['Foo#bar(baz)'] = 'foo-bar-baz.html';
});
afterEach(function() {
delete helper.longnameToUrl.linktoTest;
delete helper.longnameToUrl.LinktoFakeClass;
delete helper.longnameToUrl['Foo#bar(baz)'];
});
it('returns the longname if only the longname is specified and has no URL', function() {
@ -414,6 +416,12 @@ describe("jsdoc/util/templateHelper", function() {
expect(logger.error).not.toHaveBeenCalled();
});
it('does not treat a longname with a variation as a type application', function() {
var link = helper.linkto('Foo#bar(baz)', 'link text');
expect(link).toBe('<a href="foo-bar-baz.html">link text</a>');
});
it('returns a link when a URL is specified', function() {
var link = helper.linkto('http://example.com');
expect(link).toBe('<a href="http://example.com">http://example.com</a>');