From 6cea9a9d9a20a71b09bcf375313f0bb52aa787c6 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Fri, 2 May 2014 12:10:03 +0200 Subject: [PATCH] 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. --- apidoc/template/publish.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apidoc/template/publish.js b/apidoc/template/publish.js index ebdf4920eb..afbfd68b4e 100644 --- a/apidoc/template/publish.js +++ b/apidoc/template/publish.js @@ -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>/g); + if (links) { + for (var i = links.length - 1; i >= 0; --i) { + var link = links[i]; + var linkLongname = link.match(/]*>([^<]*)<\/a>/)[1]; + var doclet = find({longname: linkLongname})[0]; + if (!doclet) { + markup = markup.replace(link, linkLongname); + } + } + } + return markup; +} var htmlsafe = helper.htmlsafe;