mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
feat: add util package for generating search indices (#8571)
This commit is contained in:
63
packages/api-extractor-utils/src/tsdoc/index.ts
Normal file
63
packages/api-extractor-utils/src/tsdoc/index.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import type { ApiModel, ApiItem } from '@microsoft/api-extractor-model';
|
||||
import {
|
||||
type DocNode,
|
||||
type DocPlainText,
|
||||
type DocLinkTag,
|
||||
type DocParagraph,
|
||||
type DocFencedCode,
|
||||
DocNodeKind,
|
||||
type DocBlock,
|
||||
type DocComment,
|
||||
type DocCodeSpan,
|
||||
type DocParamBlock,
|
||||
} from '@microsoft/tsdoc';
|
||||
import { block } from './CommentBlock';
|
||||
import { codeSpan } from './CommentCodeSpan';
|
||||
import type { AnyDocNodeJSON } from './CommentNode';
|
||||
import { node as _node } from './CommentNode';
|
||||
import { nodeContainer } from './CommentNodeContainer';
|
||||
import { fencedCode } from './FencedCodeCommentNode';
|
||||
import { linkTagNode } from './LinkTagCommentNode';
|
||||
import { paramBlock } from './ParamBlock';
|
||||
import { plainTextNode } from './PlainTextCommentNode';
|
||||
import { comment } from './RootComment';
|
||||
|
||||
export function createCommentNode(
|
||||
node: DocNode,
|
||||
model: ApiModel,
|
||||
version: string,
|
||||
parentItem?: ApiItem,
|
||||
): AnyDocNodeJSON {
|
||||
switch (node.kind) {
|
||||
case DocNodeKind.PlainText:
|
||||
return plainTextNode(node as DocPlainText);
|
||||
case DocNodeKind.LinkTag:
|
||||
return linkTagNode(node as DocLinkTag, model, version, parentItem);
|
||||
case DocNodeKind.Paragraph:
|
||||
case DocNodeKind.Section:
|
||||
return nodeContainer(node as DocParagraph, model, version, parentItem);
|
||||
case DocNodeKind.FencedCode:
|
||||
return fencedCode(node as DocFencedCode);
|
||||
case DocNodeKind.CodeSpan:
|
||||
return codeSpan(node as DocCodeSpan);
|
||||
case DocNodeKind.Block:
|
||||
return block(node as DocBlock, model, version, parentItem);
|
||||
case DocNodeKind.ParamBlock:
|
||||
return paramBlock(node as DocParamBlock, model, version, parentItem);
|
||||
case DocNodeKind.Comment:
|
||||
return comment(node as DocComment, model, version, parentItem);
|
||||
default:
|
||||
return _node(node);
|
||||
}
|
||||
}
|
||||
|
||||
export * from './CommentNode';
|
||||
export * from './CommentNodeContainer';
|
||||
export * from './CommentBlock';
|
||||
export * from './CommentBlockTag';
|
||||
export * from './CommentCodeSpan';
|
||||
export * from './FencedCodeCommentNode';
|
||||
export * from './LinkTagCommentNode';
|
||||
export * from './ParamBlock';
|
||||
export * from './PlainTextCommentNode';
|
||||
export * from './RootComment';
|
||||
Reference in New Issue
Block a user