Skip to content

Commit

Permalink
fix(docs-infra): avoid internal symbols from being referenced during …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
AndrewKushnir authored and dylhunn committed Apr 20, 2022
1 parent 47e5b05 commit 788f587
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Expand Up @@ -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;
}
Expand Down
Expand Up @@ -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>'};
Expand Down

0 comments on commit 788f587

Please sign in to comment.