diff --git a/aio/tools/transforms/angular.io-package/index.js b/aio/tools/transforms/angular.io-package/index.js index 1834957db0..77ac13f9e1 100644 --- a/aio/tools/transforms/angular.io-package/index.js +++ b/aio/tools/transforms/angular.io-package/index.js @@ -25,7 +25,11 @@ module.exports = new Package('angular.io', [gitPackage, apiPackage, contentPacka renderDocsProcessor.extraData.versionInfo = versionInfo; }) - .config(function(checkAnchorLinksProcessor) { + .config(function(checkAnchorLinksProcessor, linkInlineTagDef) { + + // Fail the processing if there is an invalid link + linkInlineTagDef.failOnBadLink = true; + checkAnchorLinksProcessor.$enabled = true; // since we encode the HTML to JSON we need to ensure that this processor runs before that encoding happens. checkAnchorLinksProcessor.$runBefore = ['convertToJsonProcessor']; diff --git a/aio/tools/transforms/links-package/inline-tag-defs/link.js b/aio/tools/transforms/links-package/inline-tag-defs/link.js index 2b24828bad..e957a22e81 100644 --- a/aio/tools/transforms/links-package/inline-tag-defs/link.js +++ b/aio/tools/transforms/links-package/inline-tag-defs/link.js @@ -9,23 +9,29 @@ var INLINE_LINK = /(\S+)(?:\s+([\s\S]+))?/; * @param {Function} docs error message * @return {String} The html link information * - * @property {boolean} relativeLinks Whether we expect the links to be relative to the originating doc + * @property {boolean} failOnBadLink Whether to throw an error (aborting the processing) if a link is invalid. */ module.exports = function linkInlineTagDef(getLinkInfo, createDocMessage, log) { return { name: 'link', aliases: ['linkDocs'], + failOnBadLink: false, description: 'Process inline link tags (of the form {@link some/uri Some Title}), replacing them with HTML anchors', - handler: function(doc, tagName, tagDescription) { + handler(doc, tagName, tagDescription) { // Parse out the uri and title - return tagDescription.replace(INLINE_LINK, function(match, uri, title) { + return tagDescription.replace(INLINE_LINK, (match, uri, title) => { var linkInfo = getLinkInfo(uri, title, doc); if (!linkInfo.valid) { - log.warn(createDocMessage(linkInfo.error, doc)); + const message = createDocMessage(linkInfo.error, doc); + if (this.failOnBadLink) { + throw new Error(message); + } else { + log.warn(message); + } } return '' + linkInfo.title + '';