diff options
| -rw-r--r-- | docs/spec/ngdocSpec.js | 23 | ||||
| -rw-r--r-- | docs/src/ngdoc.js | 14 |
2 files changed, 18 insertions, 19 deletions
diff --git a/docs/spec/ngdocSpec.js b/docs/spec/ngdocSpec.js index e8b8959d..52b2ce03 100644 --- a/docs/spec/ngdocSpec.js +++ b/docs/spec/ngdocSpec.js @@ -208,31 +208,26 @@ describe('ngdoc', function(){ describe('links checking', function() { var docs; beforeEach(function() { + spyOn(console, 'log'); docs = [new Doc({section: 'api', id: 'fake.id1', links: ['non-existing-link']}), new Doc({section: 'api', id: 'fake.id2'}), new Doc({section: 'api', id: 'fake.id3'})]; }); - it('should throw exception when any link doesn\'t exist', function() { - expect(function() { - ngdoc.merge(docs); - }).toThrow(); + it('should log warning when any link doesn\'t exist', function() { + ngdoc.merge(docs); + expect(console.log).toHaveBeenCalled(); + expect(console.log.argsForCall[0][0]).toContain('WARNING:'); }); it('should say which link doesn\'t exist', function() { - try { - ngdoc.merge(docs); - } catch (e) { - expect(e).toContain('non-existing-link'); - } + ngdoc.merge(docs); + expect(console.log.argsForCall[0][0]).toContain('non-existing-link'); }); it('should say where is the non-existing link', function() { - try { - ngdoc.merge(docs); - } catch (e) { - expect(e).toContain('api/fake.id1'); - } + ngdoc.merge(docs); + expect(console.log.argsForCall[0][0]).toContain('api/fake.id1'); }); }); }); diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index c2f5256a..c814c968 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -126,12 +126,16 @@ Doc.prototype = { text = text.replace(/{@link\s+([^\s}]+)\s*([^}]*?)\s*}/g, function(_all, url, title){ var isFullUrl = url.match(IS_URL), + // FIXME(vojta) angular link could be api.angular now with sections isAngular = url.match(IS_ANGULAR); - url = isFullUrl ? url : self.sectionHuristic(url); - self.links.push(url); + if (!isFullUrl) { + // TODO(vojta) there could be relative link, but not angular + // do we want to store all links (and check even the full links like http://github.com ? + self.links.push(self.sectionHuristic(url)); + } - return '<a href="' + (isFullUrl ? '' + url : '#!' + url) + '">' + return '<a href="' + (isFullUrl ? '' + url : '#!' + self.sectionHuristic(url)) + '">' + (isAngular ? '<code>' : '') + (title || url).replace(/\n/g, ' ') + (isAngular ? '</code>' : '') @@ -680,11 +684,11 @@ function merge(docs){ i++; } } - + // check links docs.forEach(function(doc) { doc.links.forEach(function(link) { - if (!byFullId[link]) throw 'Not existing link "' + link + '" in ' + doc.section + '/' + doc.id; + if (!byFullId[link]) console.log('WARNING: Non existing link "' + link + '" in ' + doc.section + '/' + doc.id); }); }); |
