feat(website): static, optional, private, inherits, extends

This commit is contained in:
iCrawl
2023-04-09 18:40:49 +02:00
parent 6412da4921
commit d1955f7c9e
3 changed files with 80 additions and 95 deletions

View File

@@ -1,60 +0,0 @@
import type {
ApiItemJSON,
DocNodeJSON,
DocCodeSpanJSON,
DocPlainTextJSON,
DocNodeContainerJSON,
DocLinkTagJSON,
} from '@discordjs/api-extractor-utils';
export function tryResolveDescription(member: ApiItemJSON) {
const { summary } = member!;
if (!summary) {
return null;
}
let retVal = '';
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;
case 'Section':
case 'Paragraph':
for (const currentNode of (node as DocNodeContainerJSON).nodes) {
recurseNodes(currentNode);
}
break;
default:
break;
}
}
for (const node of summary.nodes) {
recurseNodes(node);
}
if (retVal === '') {
return null;
}
return retVal;
}