From 2e0e732cadd86846b57b7b02b3303a2e0e3b842a Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Tue, 17 May 2011 22:12:23 +0200 Subject: Check whether links do exist and throw exception --- docs/src/ngdoc.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'docs/src') diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index 869fe4c5..c2f5256a 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -29,6 +29,7 @@ function Doc(text, file, line) { this.param = this.param || []; this.properties = this.properties || []; this.methods = this.methods || []; + this.links = this.links || []; } Doc.METADATA_IGNORE = (function(){ var words = require('fs').readFileSync(__dirname + '/ignore.words', 'utf8'); @@ -124,11 +125,16 @@ Doc.prototype = { text = text.replace(//gm, '<angular/>'); text = text.replace(/{@link\s+([^\s}]+)\s*([^}]*?)\s*}/g, function(_all, url, title){ - var isFullUrl = url.match(IS_URL); - return '' - + (url.match(IS_ANGULAR) ? '' : '') + var isFullUrl = url.match(IS_URL), + isAngular = url.match(IS_ANGULAR); + + url = isFullUrl ? url : self.sectionHuristic(url); + self.links.push(url); + + return '' + + (isAngular ? '' : '') + (title || url).replace(/\n/g, ' ') - + (url.match(IS_ANGULAR) ? '' : '') + + (isAngular ? '' : '') + ''; }); text = new Showdown.converter().makeHtml(text); @@ -659,9 +665,12 @@ function indent(text, spaceCount) { ////////////////////////////////////////////////////////// function merge(docs){ - var byName = {}; + var byName = {}, + byFullId = {}; + docs.forEach(function(doc){ byName[doc.name] = doc; + byFullId[doc.section + '/' + doc.id] = doc; }); for(var i=0; i