mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(docs-infra): avoid internal symbols from being referenced during auto-linking (#45689)
This commit adds extra logic to avoid internal and privately exported symbols from being referenced during auto-linking. Currently such symbols can be used for linking, thus resulting in a non-existing link and causing the linking process to fail. PR Close #45689
This commit is contained in:
committed by
Dylan Hunn
parent
47e5b056ec
commit
788f587367
+2
-1
@@ -126,7 +126,8 @@ module.exports = function autoLinkCode(getDocFromAlias) {
|
||||
|
||||
var doc = docs[0];
|
||||
|
||||
const isInvalidDoc = doc.docType === 'member' && !keyword.includes('.');
|
||||
const isInvalidDoc =
|
||||
doc.internal || doc.privateExport || (doc.docType === 'member' && !keyword.includes('.'));
|
||||
if (isInvalidDoc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -221,6 +221,20 @@ describe('autoLinkCode post-processor', () => {
|
||||
expect(doc.renderedContent).toEqual('<code class="no-auto-link">MyClass</code>');
|
||||
});
|
||||
|
||||
it('should ignore symbols marked as internal', () => {
|
||||
aliasMap.addDoc({docType: 'class', id: 'MyClass', aliases: ['MyClass'], internal: true});
|
||||
const doc = {docType: 'test-doc', renderedContent: '<code>MyClass</code>'};
|
||||
processor.$process([doc]);
|
||||
expect(doc.renderedContent).toEqual('<code>MyClass</code>');
|
||||
});
|
||||
|
||||
it('should ignore symbols marked as privately exported (that start with `ɵ`)', () => {
|
||||
aliasMap.addDoc({docType: 'class', id: 'MyClass', aliases: ['MyClass'], privateExport: true});
|
||||
const doc = {docType: 'test-doc', renderedContent: '<code>MyClass</code>'};
|
||||
processor.$process([doc]);
|
||||
expect(doc.renderedContent).toEqual('<code>MyClass</code>');
|
||||
});
|
||||
|
||||
it('should ignore code blocks that are marked with an "ignored" language', () => {
|
||||
aliasMap.addDoc({docType: 'class', id: 'MyClass', aliases: ['MyClass'], path: 'a/b/myclass'});
|
||||
const doc = {docType: 'test-doc', renderedContent: '<code language="bash">MyClass</code>'};
|
||||
|
||||
Reference in New Issue
Block a user