mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
FEATURE/FIX: jsdoc/util/templateHelper.getAncestorLinks: direct parents punctuation should be part of the link text. <a href="">Parent~</a> vs <a href="">Parent</a>~
This commit is contained in:
parent
9183a90aa5
commit
dad08be08a
@ -280,18 +280,21 @@ exports.getSignatureReturns = function(d, cssClass) {
|
|||||||
*/
|
*/
|
||||||
exports.getAncestorLinks = function(data, doclet, cssClass) {
|
exports.getAncestorLinks = function(data, doclet, cssClass) {
|
||||||
var ancestors = [],
|
var ancestors = [],
|
||||||
doc = doclet.memberof;
|
doc = doclet.memberof,
|
||||||
|
directParent = false;
|
||||||
|
|
||||||
while (doc) {
|
while (doc) {
|
||||||
doc = find( data, {longname: doc}, false );
|
doc = find( data, {longname: doc}, false );
|
||||||
if (doc) { doc = doc[0]; }
|
if (doc) { doc = doc[0]; }
|
||||||
if (!doc) { break; }
|
if (!doc) { break; }
|
||||||
|
if (!directParent) { directParent = doc; }
|
||||||
ancestors.unshift( linkto(doc.longname, (exports.scopeToPunc[doc.scope] || '') + doc.name,
|
ancestors.unshift( linkto(doc.longname, (exports.scopeToPunc[doc.scope] || '') + doc.name,
|
||||||
cssClass) );
|
cssClass) );
|
||||||
doc = doc.memberof;
|
doc = doc.memberof;
|
||||||
}
|
}
|
||||||
if (ancestors.length) {
|
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;
|
return ancestors;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -682,9 +682,7 @@ describe("jsdoc/util/templateHelper", function() {
|
|||||||
|
|
||||||
var links = helper.getAncestorLinks(data, lackeys);
|
var links = helper.getAncestorLinks(data, lackeys);
|
||||||
expect(links.length).toBe(3);
|
expect(links.length).toBe(3);
|
||||||
// BUG: the link text is ~Henchman and there is a '#' on the end.
|
expect(links).toContain('<a href="henchman.html">~Henchman#</a>');
|
||||||
// should probably have link text ~Henchman#.
|
|
||||||
//expect(links).toContain('<a href="henchman.html">~Henchman#</a>');
|
|
||||||
expect(links).toContain('.Sharks');
|
expect(links).toContain('.Sharks');
|
||||||
expect(links).toContain('<a href="mafia_gangs.html">mafia/gangs</a>');
|
expect(links).toContain('<a href="mafia_gangs.html">mafia/gangs</a>');
|
||||||
|
|
||||||
@ -699,7 +697,7 @@ describe("jsdoc/util/templateHelper", function() {
|
|||||||
|
|
||||||
var links = helper.getAncestorLinks(data, lackeys, 'myClass');
|
var links = helper.getAncestorLinks(data, lackeys, 'myClass');
|
||||||
expect(links.length).toBe(3);
|
expect(links.length).toBe(3);
|
||||||
//expect(links).toContain('<a href="henchman.html" class="myClass">~Henchman#</a>');
|
expect(links).toContain('<a href="henchman.html" class="myClass">~Henchman#</a>');
|
||||||
expect(links).toContain('.Sharks');
|
expect(links).toContain('.Sharks');
|
||||||
expect(links).toContain('<a href="mafia_gangs.html" class="myClass">mafia/gangs</a>');
|
expect(links).toContain('<a href="mafia_gangs.html" class="myClass">mafia/gangs</a>');
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user