');
dom.html('| ');
@@ -1211,22 +1223,7 @@ function merge(docs){
});
for(var i = 0; i < docs.length;) {
- var doc = docs[i];
-
- // check links - do they exist ?
- doc.links.forEach(function(link) {
- // convert #id to path#id
- if (link[0] == '#') {
- link = doc.section + '/' + doc.id.split('#').shift() + link;
- }
- link = link.split('#').shift();
- if (!byFullId[link]) {
- console.log('WARNING: In ' + doc.section + '/' + doc.id + ', non existing link: "' + link + '"');
- }
- });
-
- // merge into parents
- if (findParent(doc, 'method') || findParent(doc, 'property') || findParent(doc, 'event')) {
+ if (findParent(docs[i], 'method') || findParent(docs[i], 'property') || findParent(docs[i], 'event')) {
docs.splice(i, 1);
} else {
i++;
@@ -1255,6 +1252,36 @@ function merge(docs){
}
//////////////////////////////////////////////////////////
+
+function checkBrokenLinks(docs) {
+ var byFullId = Object.create(null);
+
+ docs.forEach(function(doc) {
+ byFullId[doc.section + '/' + doc.id] = doc;
+ });
+
+ docs.forEach(function(doc) {
+ doc.links.forEach(function(link) {
+ // convert #id to path#id
+ if (link[0] == '#') {
+ link = doc.section + '/' + doc.id.split('#').shift() + link;
+ }
+
+ var parts = link.split('#');
+ var pageLink = parts[0];
+ var anchorLink = parts[1];
+ var linkedPage = byFullId[pageLink];
+
+ if (!linkedPage) {
+ console.log('WARNING: ' + doc.section + '/' + doc.id + ' (defined in ' + doc.file + ') points to a non existing page "' + link + '"!');
+ } else if (anchorLink && linkedPage.anchors.indexOf(anchorLink) === -1) {
+ console.log('WARNING: ' + doc.section + '/' + doc.id + ' (defined in ' + doc.file + ') points to a non existing anchor "' + link + '"!');
+ }
+ });
+ });
+}
+
+
function property(name) {
return function(value){
return value[name];
--
cgit v1.2.3
|