diff --git a/lib/jsdoc/util/templateHelper.js b/lib/jsdoc/util/templateHelper.js
index 94867bc4..e52ea89c 100644
--- a/lib/jsdoc/util/templateHelper.js
+++ b/lib/jsdoc/util/templateHelper.js
@@ -280,18 +280,21 @@ exports.getSignatureReturns = function(d, cssClass) {
*/
exports.getAncestorLinks = function(data, doclet, cssClass) {
var ancestors = [],
- doc = doclet.memberof;
+ doc = doclet.memberof,
+ directParent = false;
while (doc) {
doc = find( data, {longname: doc}, false );
if (doc) { doc = doc[0]; }
if (!doc) { break; }
+ if (!directParent) { directParent = doc; }
ancestors.unshift( linkto(doc.longname, (exports.scopeToPunc[doc.scope] || '') + doc.name,
cssClass) );
doc = doc.memberof;
}
if (ancestors.length) {
- ancestors[ancestors.length - 1] += (exports.scopeToPunc[doclet.scope] || '');
+ var last = ancestors[ancestors.length - 1];
+ ancestors[ancestors.length - 1] = last.replace(directParent.name, directParent.name + (exports.scopeToPunc[doclet.scope] || ''));
}
return ancestors;
};
diff --git a/test/specs/jsdoc/util/templateHelper.js b/test/specs/jsdoc/util/templateHelper.js
index 667cf606..6718a820 100644
--- a/test/specs/jsdoc/util/templateHelper.js
+++ b/test/specs/jsdoc/util/templateHelper.js
@@ -682,9 +682,7 @@ describe("jsdoc/util/templateHelper", function() {
var links = helper.getAncestorLinks(data, lackeys);
expect(links.length).toBe(3);
- // BUG: the link text is ~Henchman and there is a '#' on the end.
- // should probably have link text ~Henchman#.
- //expect(links).toContain('~Henchman#');
+ expect(links).toContain('~Henchman#');
expect(links).toContain('.Sharks');
expect(links).toContain('mafia/gangs');
@@ -699,7 +697,7 @@ describe("jsdoc/util/templateHelper", function() {
var links = helper.getAncestorLinks(data, lackeys, 'myClass');
expect(links.length).toBe(3);
- //expect(links).toContain('~Henchman#');
+ expect(links).toContain('~Henchman#');
expect(links).toContain('.Sharks');
expect(links).toContain('mafia/gangs');