From 131d0d8e8a0bcb4dd495845c7e8a1b426c87c940 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Wed, 16 May 2018 17:41:32 +0100 Subject: [PATCH] build(aio): do not try to auto-link to internal API items (#24000) This would cause dangling links since the target, being internal, would not exist in the docs. PR Close #24000 --- .../angular-base-package/post-processors/auto-link-code.js | 4 +++- .../post-processors/auto-link-code.spec.js | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.js b/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.js index fae9ba475e..92f5cf06ee 100644 --- a/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.js +++ b/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.js @@ -65,7 +65,9 @@ module.exports = function autoLinkCode(getDocFromAlias) { }; } function foundValidDoc(docs) { - return docs.length === 1 && autoLinkCodeImpl.docTypes.indexOf(docs[0].docType) !== -1; + return docs.length === 1 && + !docs[0].internal && + autoLinkCodeImpl.docTypes.indexOf(docs[0].docType) !== -1; } function createLinkNode(doc, text) { diff --git a/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.spec.js b/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.spec.js index f300487aed..c5fabf43d3 100644 --- a/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.spec.js +++ b/aio/tools/transforms/angular-base-package/post-processors/auto-link-code.spec.js @@ -79,6 +79,13 @@ describe('autoLinkCode post-processor', () => { ''); }); + it('should ignore code items that match an internal API doc', () => { + aliasMap.addDoc({ docType: 'class', id: 'MyClass', aliases: ['MyClass'], path: 'a/b/myclass', internal: true }); + const doc = { docType: 'test-doc', renderedContent: 'MyClass' }; + processor.$process([doc]); + expect(doc.renderedContent).toEqual('MyClass'); + }); + it('should insert anchors for individual text nodes within a code block', () => { aliasMap.addDoc({ docType: 'class', id: 'MyClass', aliases: ['MyClass'], path: 'a/b/myclass' }); const doc = { docType: 'test-doc', renderedContent: 'MyClassMyClass' };