build(docs-infra): Ensures that only member docs are linked (#36316)
This commit ensures that `member` docs are only linked if the linking text contains `.`. PR Close #36316
This commit is contained in:
parent
4fb034aeec
commit
aebd5f9af6
|
@ -90,6 +90,12 @@ module.exports = function autoLinkCode(getDocFromAlias) {
|
|||
}
|
||||
|
||||
var doc = docs[0];
|
||||
|
||||
const isInvalidDoc = doc.docType === 'member' && !keyword.includes('.');
|
||||
if (isInvalidDoc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (doc.path === '') {
|
||||
var message = `
|
||||
autoLinkCode: Doc path is empty for "${doc.id}" - link will not be generated for "${keyword}".
|
||||
|
|
|
@ -135,6 +135,16 @@ describe('autoLinkCode post-processor', () => {
|
|||
expect(doc.renderedContent).toEqual('<code>MyClass</code>');
|
||||
});
|
||||
|
||||
it('should ignore documents when the `docType` is set to `member` and the keyword doesn\'t include `.`',
|
||||
() => {
|
||||
aliasMap.addDoc({docType: 'class', id: 'MyClass', aliases: ['MyClass'], path: 'a/b/myclass'});
|
||||
aliasMap.addDoc(
|
||||
{docType: 'member', id: 'MyEnum', aliases: ['MyEnum'], path: 'a/b/c'});
|
||||
const doc = {docType: 'test-doc', renderedContent: '<code>MyClass</code>'};
|
||||
processor.$process([doc]);
|
||||
expect(doc.renderedContent).toEqual('<code><a href="a/b/myclass" class="code-anchor">MyClass</a></code>');
|
||||
});
|
||||
|
||||
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 = {
|
||||
|
|
Loading…
Reference in New Issue