Avoid dead links

Because we remove doclets that are not part of the API, there
are cases where linkto will create a link to an undocumented
doclet. We now replace such links with the longname of the
doclet.
This commit is contained in:
Andreas Hocevar
2014-05-02 12:10:03 +02:00
parent 5a13488b11
commit 6cea9a9d9a

View File

@@ -23,7 +23,21 @@ function getAncestorLinks(doclet) {
return helper.getAncestorLinks(data, doclet);
}
var linkto = helper.linkto;
function linkto(longname, linkText, cssClass, fragmentId) {
var markup = helper.linkto.apply(this, arguments);
var links = markup.match(/<a [^>]*>[^<]*<\/a>/g);
if (links) {
for (var i = links.length - 1; i >= 0; --i) {
var link = links[i];
var linkLongname = link.match(/<a [^>]*>([^<]*)<\/a>/)[1];
var doclet = find({longname: linkLongname})[0];
if (!doclet) {
markup = markup.replace(link, linkLongname);
}
}
}
return markup;
}
var htmlsafe = helper.htmlsafe;