fix: extract text from link tags for descriptions (#8739)

This commit is contained in:
Suneet Tipirneni
2022-10-12 05:37:07 -04:00
committed by GitHub
parent 5ffabb119f
commit 49b91315f7

View File

@@ -4,6 +4,7 @@ import type {
DocCodeSpanJSON,
DocPlainTextJSON,
DocNodeContainerJSON,
DocLinkTagJSON,
} from '@discordjs/api-extractor-utils';
export function tryResolveDescription(member: ApiItemJSON) {
@@ -15,11 +16,23 @@ export function tryResolveDescription(member: ApiItemJSON) {
let retVal = '';
function recurseNodes(node: DocNodeJSON) {
function recurseNodes(node: DocNodeJSON, emitMarkdownLinks = false) {
switch (node.kind) {
case 'CodeSpan':
retVal += (node as DocCodeSpanJSON).code;
break;
case 'LinkTag': {
const { text, urlDestination } = node as DocLinkTagJSON;
if (text && urlDestination && emitMarkdownLinks) {
retVal += `[${text}](${urlDestination})`;
} else {
retVal += text ?? urlDestination ?? '';
}
break;
}
case 'PlainText':
retVal += (node as DocPlainTextJSON).text;
break;