diff --git a/spec/ngdocSpec.js b/spec/ngdocSpec.js index 187cfac..dcf61f3 100644 --- a/spec/ngdocSpec.js +++ b/spec/ngdocSpec.js @@ -293,7 +293,7 @@ describe('ngdoc', function() { describe('checkBrokenLinks', function() { - var docs; + var docs, apis = {'api': true}; beforeEach(function() { spyOn(console, 'log'); @@ -304,7 +304,7 @@ describe('ngdoc', function() { it('should log warning when a linked page does not exist', function() { docs.push(new Doc({section: 'api', id: 'with-broken.link', links: ['non-existing-link']})) - ngdoc.checkBrokenLinks(docs); + ngdoc.checkBrokenLinks(docs, apis); expect(console.log).toHaveBeenCalled(); var warningMsg = console.log.argsForCall[0][0] expect(warningMsg).toContain('WARNING:'); @@ -314,7 +314,7 @@ describe('ngdoc', function() { it('should log warning when a linked anchor does not exist', function() { docs.push(new Doc({section: 'api', id: 'with-broken.link', links: ['api/fake.id1#non-existing']})) - ngdoc.checkBrokenLinks(docs); + ngdoc.checkBrokenLinks(docs, apis); expect(console.log).toHaveBeenCalled(); var warningMsg = console.log.argsForCall[0][0] expect(warningMsg).toContain('WARNING:'); diff --git a/src/ngdoc.js b/src/ngdoc.js index 06d67c6..ce2c022 100644 --- a/src/ngdoc.js +++ b/src/ngdoc.js @@ -1252,18 +1252,21 @@ function merge(docs){ ////////////////////////////////////////////////////////// -function checkBrokenLinks(docs) { +function checkBrokenLinks(docs, apis, options) { var byFullId = Object.create(null); docs.forEach(function(doc) { byFullId[doc.section + '/' + doc.id] = doc; - if (doc.section === 'api') { + if (apis[doc.section]) { doc.anchors.push('directive', 'service', 'filter', 'function'); } }); docs.forEach(function(doc) { doc.links.forEach(function(link) { + if (options && !options.html5mode) { + link = link.substring(2); + } // convert #id to path#id if (link[0] == '#') { link = doc.section + '/' + doc.id.split('#').shift() + link; diff --git a/tasks/grunt-ngdocs.js b/tasks/grunt-ngdocs.js index e08702d..fe1bff0 100644 --- a/tasks/grunt-ngdocs.js +++ b/tasks/grunt-ngdocs.js @@ -91,6 +91,7 @@ module.exports = function(grunt) { }); ngdoc.merge(reader.docs); + ngdoc.checkBrokenLinks(reader.docs, setup.apis, options); reader.docs.forEach(function(doc){ // this hack is here because on OSX angular.module and angular.Module map to the same file.