feat(docgen): update typedoc

This commit is contained in:
iCrawl
2022-06-10 02:29:17 +02:00
parent 2791c86cdf
commit b3346f4b9b
21 changed files with 663 additions and 486 deletions

View File

@@ -47,7 +47,7 @@
"tslib": "^2.4.0" "tslib": "^2.4.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^16.11.38", "@types/node": "^16.11.39",
"@typescript-eslint/eslint-plugin": "^5.27.1", "@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1", "@typescript-eslint/parser": "^5.27.1",
"eslint": "^8.17.0", "eslint": "^8.17.0",

View File

@@ -54,7 +54,7 @@
"dependencies": { "dependencies": {
"@sapphire/shapeshift": "^3.1.0", "@sapphire/shapeshift": "^3.1.0",
"@sindresorhus/is": "^4.6.0", "@sindresorhus/is": "^4.6.0",
"discord-api-types": "^0.33.4", "discord-api-types": "^0.33.5",
"fast-deep-equal": "^3.1.3", "fast-deep-equal": "^3.1.3",
"ts-mixer": "^6.0.1", "ts-mixer": "^6.0.1",
"tslib": "^2.4.0" "tslib": "^2.4.0"
@@ -63,7 +63,7 @@
"@discordjs/docgen": "workspace:^", "@discordjs/docgen": "workspace:^",
"@discordjs/scripts": "workspace:^", "@discordjs/scripts": "workspace:^",
"@favware/cliff-jumper": "^1.8.3", "@favware/cliff-jumper": "^1.8.3",
"@types/node": "^16.11.38", "@types/node": "^16.11.39",
"@typescript-eslint/eslint-plugin": "^5.27.1", "@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1", "@typescript-eslint/parser": "^5.27.1",
"eslint": "^8.17.0", "eslint": "^8.17.0",

View File

@@ -51,7 +51,7 @@
"@discordjs/docgen": "workspace:^", "@discordjs/docgen": "workspace:^",
"@discordjs/scripts": "workspace:^", "@discordjs/scripts": "workspace:^",
"@favware/cliff-jumper": "^1.8.3", "@favware/cliff-jumper": "^1.8.3",
"@types/node": "^16.11.38", "@types/node": "^16.11.39",
"@typescript-eslint/eslint-plugin": "^5.27.1", "@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1", "@typescript-eslint/parser": "^5.27.1",
"eslint": "^8.17.0", "eslint": "^8.17.0",

View File

@@ -53,17 +53,17 @@
"@discordjs/rest": "workspace:^", "@discordjs/rest": "workspace:^",
"@sapphire/snowflake": "^3.2.2", "@sapphire/snowflake": "^3.2.2",
"@types/ws": "^8.5.3", "@types/ws": "^8.5.3",
"discord-api-types": "^0.33.4", "discord-api-types": "^0.33.5",
"fast-deep-equal": "^3.1.3", "fast-deep-equal": "^3.1.3",
"lodash.snakecase": "^4.1.1", "lodash.snakecase": "^4.1.1",
"tslib": "^2.4.0", "tslib": "^2.4.0",
"undici": "^5.4.0", "undici": "^5.4.0",
"ws": "^8.7.0" "ws": "^8.8.0"
}, },
"devDependencies": { "devDependencies": {
"@discordjs/docgen": "workspace:^", "@discordjs/docgen": "workspace:^",
"@favware/cliff-jumper": "^1.8.3", "@favware/cliff-jumper": "^1.8.3",
"@types/node": "^16.11.38", "@types/node": "^16.11.39",
"dtslint": "^4.2.1", "dtslint": "^4.2.1",
"eslint": "^8.17.0", "eslint": "^8.17.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
@@ -71,7 +71,7 @@
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"husky": "^8.0.1", "husky": "^8.0.1",
"is-ci": "^3.0.1", "is-ci": "^3.0.1",
"jest": "^28.1.0", "jest": "^28.1.1",
"prettier": "^2.6.2", "prettier": "^2.6.2",
"tsd": "^0.20.0", "tsd": "^0.20.0",
"tslint": "^6.1.3", "tslint": "^6.1.3",

View File

@@ -53,12 +53,12 @@
"commander": "^9.3.0", "commander": "^9.3.0",
"jsdoc-to-markdown": "^7.1.1", "jsdoc-to-markdown": "^7.1.1",
"tslib": "^2.4.0", "tslib": "^2.4.0",
"typedoc": "^0.22.17" "typedoc": "^0.23.0-beta.4"
}, },
"devDependencies": { "devDependencies": {
"@favware/cliff-jumper": "^1.8.3", "@favware/cliff-jumper": "^1.8.3",
"@types/jsdoc-to-markdown": "^7.0.3", "@types/jsdoc-to-markdown": "^7.0.3",
"@types/node": "^16.11.38", "@types/node": "^16.11.39",
"@typescript-eslint/eslint-plugin": "^5.27.1", "@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1", "@typescript-eslint/parser": "^5.27.1",
"eslint": "^8.17.0", "eslint": "^8.17.0",

View File

@@ -121,7 +121,7 @@ export class Documentation {
item = new DocumentedMember(member, this.config); item = new DocumentedMember(member, this.config);
break; break;
} }
case 'event': { case 'Event': {
item = new DocumentedEvent(member, this.config); item = new DocumentedEvent(member, this.config);
break; break;
} }

View File

@@ -80,6 +80,7 @@ export class DocumentedClass extends DocumentedItem<Class | DeclarationReflectio
public override serializer() { public override serializer() {
if (this.config.typescript) { if (this.config.typescript) {
const data = this.data as DeclarationReflection; const data = this.data as DeclarationReflection;
const signature = (data.signatures ?? [])[0] ?? data;
let meta; let meta;
const sources = data.sources?.[0]; const sources = data.sources?.[0];
@@ -87,25 +88,37 @@ export class DocumentedClass extends DocumentedItem<Class | DeclarationReflectio
meta = new DocumentedItemMeta(sources, this.config).serialize(); meta = new DocumentedItemMeta(sources, this.config).serialize();
} }
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const see = signature.comment?.blockTags?.filter((t) => t.tag === '@see').length
? signature.comment.blockTags
.filter((t) => t.tag === '@see')
.map((t) => t.content.find((c) => c.kind === 'text')?.text.trim())
: undefined;
return { return {
// @ts-expect-error // @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
name: data.name === 'default' ? parse(meta?.file ?? 'default').name : data.name, name: signature.name === 'default' ? parse(meta?.file ?? 'default').name : signature.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
description: data.comment?.shortText?.trim(), description: signature.comment?.summary.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition see,
see: data.comment?.tags?.filter((t) => t.tagName === 'see').map((t) => t.text.trim()),
extends: this.extends?.serialize(), extends: this.extends?.serialize(),
implements: this.implements?.serialize(), implements: this.implements?.serialize(),
access: access:
data.flags.isPrivate ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
data.flags.isPrivate || data.comment?.tags?.some((t) => t.tagName === 'private' || t.tagName === 'internal') signature.comment?.blockTags?.some((t) => t.tag === '@private' || t.tag === '@internal')
? 'private' ? 'private'
: undefined, : undefined,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/no-unnecessary-condition
abstract: signature.comment?.blockTags?.some((t) => t.tag === '@abstract') || undefined,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
abstract: data.comment?.tags?.some((t) => t.tagName === 'abstract'), deprecated: signature.comment?.blockTags?.some((t) => t.tag === '@deprecated')
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition ? signature.comment.blockTags
deprecated: data.comment?.tags?.some((t) => t.tagName === 'deprecated'), .find((t) => t.tag === '@deprecated')
?.content.reduce((prev, curr) => (prev += curr.text), '')
.trim() ?? true
: undefined,
construct: this.construct?.serialize(), construct: this.construct?.serialize(),
props: this.props.size ? this.props.map((p) => p.serialize()) : undefined, props: this.props.size ? this.props.map((p) => p.serialize()) : undefined,
methods: this.methods.size ? this.methods.map((m) => m.serialize()) : undefined, methods: this.methods.size ? this.methods.map((m) => m.serialize()) : undefined,

View File

@@ -9,16 +9,22 @@ export class DocumentedConstructor extends DocumentedItem<Constructor | Declarat
const data = this.data as DeclarationReflection; const data = this.data as DeclarationReflection;
const signature = (data.signatures ?? [])[0] ?? data; const signature = (data.signatures ?? [])[0] ?? data;
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const see = signature.comment?.blockTags?.filter((t) => t.tag === '@see').length
? signature.comment.blockTags
.filter((t) => t.tag === '@see')
.map((t) => t.content.find((c) => c.kind === 'text')?.text.trim())
: undefined;
return { return {
name: data.name, name: signature.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
description: signature.comment?.shortText?.trim(), description: signature.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition see,
see: signature.comment?.tags?.filter((t) => t.tagName === 'see').map((t) => t.text.trim()),
access: access:
data.flags.isPrivate || data.flags.isPrivate ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
signature.comment?.tags?.some((t) => t.tagName === 'private' || t.tagName === 'internal') signature.comment?.blockTags?.some((t) => t.tag === '@private' || t.tag === '@internal')
? 'private' ? 'private'
: undefined, : undefined,
// @ts-expect-error // @ts-expect-error

View File

@@ -16,14 +16,25 @@ export class DocumentedEvent extends DocumentedItem<Event | DeclarationReflectio
meta = new DocumentedItemMeta(sources, this.config).serialize(); meta = new DocumentedItemMeta(sources, this.config).serialize();
} }
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const see = signature.comment?.blockTags?.filter((t) => t.tag === '@see').length
? signature.comment.blockTags
.filter((t) => t.tag === '@see')
.map((t) => t.content.find((c) => c.kind === 'text')?.text.trim())
: undefined;
return { return {
name: data.name, name: signature.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
description: signature.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined,
see,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
description: signature.comment?.shortText?.trim(), deprecated: signature.comment?.blockTags?.some((t) => t.tag === '@deprecated')
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition ? signature.comment.blockTags
see: signature.comment?.tags?.filter((t) => t.tagName === 'see').map((t) => t.text.trim()), .find((t) => t.tag === '@deprecated')
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition ?.content.reduce((prev, curr) => (prev += curr.text), '')
deprecated: signature.comment?.tags?.some((t) => t.tagName === 'deprecated'), .trim() ?? true
: undefined,
// @ts-expect-error // @ts-expect-error
params: signature.parameters params: signature.parameters
? (signature as SignatureReflection).parameters?.map((p) => new DocumentedParam(p, this.config).serialize()) ? (signature as SignatureReflection).parameters?.map((p) => new DocumentedParam(p, this.config).serialize())

View File

@@ -1,4 +1,4 @@
import { basename, dirname, relative } from 'node:path'; import { basename, relative } from 'node:path';
import type { SourceReference } from 'typedoc'; import type { SourceReference } from 'typedoc';
import { DocumentedItem } from './item.js'; import { DocumentedItem } from './item.js';
import type { Meta } from '../interfaces/index.js'; import type { Meta } from '../interfaces/index.js';
@@ -11,7 +11,8 @@ export class DocumentedItemMeta extends DocumentedItem<Meta | SourceReference> {
return { return {
line: data.line, line: data.line,
file: basename(data.fileName), file: basename(data.fileName),
path: dirname(data.fileName), path: undefined,
url: data.url,
}; };
} }

View File

@@ -10,6 +10,7 @@ export class DocumentedMember extends DocumentedItem<Member | DeclarationReflect
public override serializer() { public override serializer() {
if (this.config.typescript) { if (this.config.typescript) {
const data = this.data as DeclarationReflection; const data = this.data as DeclarationReflection;
const signature = (data.signatures ?? [])[0] ?? data;
let meta; let meta;
const sources = data.sources?.[0]; const sources = data.sources?.[0];
@@ -17,28 +18,47 @@ export class DocumentedMember extends DocumentedItem<Member | DeclarationReflect
meta = new DocumentedItemMeta(sources, this.config).serialize(); meta = new DocumentedItemMeta(sources, this.config).serialize();
} }
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const see = signature.comment?.blockTags?.filter((t) => t.tag === '@see').length
? signature.comment.blockTags
.filter((t) => t.tag === '@see')
.map((t) => t.content.find((c) => c.kind === 'text')?.text.trim())
: undefined;
const base = { const base = {
name: data.name, name: signature.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
description: data.comment?.shortText?.trim(), description: signature.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition see,
see: data.comment?.tags?.filter((t) => t.tagName === 'see').map((t) => t.text.trim()),
scope: data.flags.isStatic ? 'static' : undefined, scope: data.flags.isStatic ? 'static' : undefined,
access: access:
data.flags.isPrivate ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
data.flags.isPrivate || data.comment?.tags?.some((t) => t.tagName === 'private' || t.tagName === 'internal') signature.comment?.blockTags?.some((t) => t.tag === '@private' || t.tag === '@internal')
? 'private' ? 'private'
: undefined, : undefined,
readonly: data.flags.isReadonly, readonly: data.flags.isReadonly,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
abstract: signature.comment?.blockTags?.some((t) => t.tag === '@abstract') || undefined,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
abstract: data.comment?.tags?.some((t) => t.tagName === 'abstract'), deprecated: signature.comment?.blockTags?.some((t) => t.tag === '@deprecated')
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition ? signature.comment.blockTags
deprecated: data.comment?.tags?.some((t) => t.tagName === 'deprecated'), .find((t) => t.tag === '@deprecated')
?.content.reduce((prev, curr) => (prev += curr.text), '')
.trim() ?? true
: undefined,
default: default:
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition (data.defaultValue === '...' ? undefined : data.defaultValue) ??
data.comment?.tags?.find((t) => t.tagName === 'default')?.text.trim() ?? (signature.comment?.blockTags
(data.defaultValue === '...' ? undefined : data.defaultValue), // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
type: data.type ? new DocumentedVarType({ names: [parseType(data.type)] }, this.config).serialize() : undefined, ?.find((t) => t.tag === '@default')
?.content.reduce((prev, curr) => (prev += curr.text), '')
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
.trim() ||
undefined),
type: signature.type
? new DocumentedVarType({ names: [parseType(signature.type)] }, this.config).serialize()
: undefined,
meta, meta,
}; };
@@ -50,28 +70,47 @@ export class DocumentedMember extends DocumentedItem<Member | DeclarationReflect
throw new Error("Can't parse accessor without getter."); throw new Error("Can't parse accessor without getter.");
} }
if (!hasSetter) base.readonly = true; if (!hasSetter) {
base.readonly = true;
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const see = getter.comment?.blockTags?.filter((t) => t.tag === '@see').length
? getter.comment.blockTags
.filter((t) => t.tag === '@see')
.map((t) => t.content.find((c) => c.kind === 'text')?.text.trim())
: undefined;
return { return {
...base, ...base,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
description: getter.comment?.shortText?.trim(), description: getter.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition see,
see: getter.comment?.tags?.filter((t) => t.tagName === 'see').map((t) => t.text.trim()),
access: access:
getter.flags.isPrivate || data.flags.isPrivate ||
getter.comment?.tags.some((t) => t.tagName === 'private' || t.tagName === 'internal') // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
getter.comment?.blockTags?.some((t) => t.tag === '@private' || t.tag === '@internal')
? 'private' ? 'private'
: undefined, : undefined,
readonly: base.readonly || !hasSetter, readonly: base.readonly || !hasSetter,
abstract: getter.comment?.tags.some((t) => t.tagName === 'abstract'), // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
deprecated: getter.comment?.tags.some((t) => t.tagName === 'deprecated'), abstract: getter.comment?.blockTags?.some((t) => t.tag === '@abstract') || undefined,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
deprecated: getter.comment?.blockTags?.some((t) => t.tag === '@deprecated')
? getter.comment.blockTags
.find((t) => t.tag === '@deprecated')
?.content.reduce((prev, curr) => (prev += curr.text), '')
.trim() ?? true
: undefined,
default: default:
base.default ?? base.default ??
getter.comment?.tags.find((t) => t.tagName === 'default')?.text.trim() ?? (getter.comment?.blockTags
// @ts-expect-error // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
getter.defaultValue, ?.find((t) => t.tag === '@default')
?.content.reduce((prev, curr) => (prev += curr.text), '')
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
.trim() ||
undefined),
type: getter.type ? parseType(getter.type) : undefined, type: getter.type ? parseType(getter.type) : undefined,
}; };
} }
@@ -99,20 +138,3 @@ export class DocumentedMember extends DocumentedItem<Member | DeclarationReflect
}; };
} }
} }
/*
{ id: 'Client#rest',
longname: 'Client#rest',
name: 'rest',
scope: 'instance',
kind: 'member',
description: 'The REST manager of the client',
memberof: 'Client',
type: { names: [ 'RESTManager' ] },
access: 'private',
meta:
{ lineno: 32,
filename: 'Client.js',
path: 'src/client' },
order: 11 }
*/

View File

@@ -18,27 +18,44 @@ export class DocumentedMethod extends DocumentedItem<Method | DeclarationReflect
meta = new DocumentedItemMeta(sources, this.config).serialize(); meta = new DocumentedItemMeta(sources, this.config).serialize();
} }
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const see = signature.comment?.blockTags?.filter((t) => t.tag === '@see').length
? signature.comment.blockTags
.filter((t) => t.tag === '@see')
.map((t) => t.content.find((c) => c.kind === 'text')?.text.trim())
: undefined;
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const examples = signature.comment?.blockTags?.filter((t) => t.tag === '@example').length
? signature.comment.blockTags
.filter((t) => t.tag === '@example')
.map((t) => t.content.reduce((prev, curr) => (prev += curr.text), '').trim())
: undefined;
return { return {
name: data.name, name: signature.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
description: signature.comment?.shortText?.trim(), description: signature.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition see,
see: signature.comment?.tags?.filter((t) => t.tagName === 'see').map((t) => t.text.trim()),
scope: data.flags.isStatic ? 'static' : undefined, scope: data.flags.isStatic ? 'static' : undefined,
access: access:
data.flags.isPrivate || data.flags.isPrivate ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
signature.comment?.tags?.some((t) => t.tagName === 'private' || t.tagName === 'internal') signature.comment?.blockTags?.some((t) => t.tag === '@private' || t.tag === '@internal')
? 'private' ? 'private'
: undefined, : undefined,
examples,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
abstract: signature.comment?.blockTags?.some((t) => t.tag === '@abstract') || undefined,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
examples: signature.comment?.tags?.filter((t) => t.tagName === 'example').map((t) => t.text.trim()), deprecated: signature.comment?.blockTags?.some((t) => t.tag === '@deprecated')
? signature.comment.blockTags
.find((t) => t.tag === '@deprecated')
?.content.reduce((prev, curr) => (prev += curr.text), '')
.trim() ?? true
: undefined,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
abstract: signature.comment?.tags?.some((t) => t.tagName === 'abstract'), // emits: signature.comment?.blockTags?.filter((t) => t.tag === '@emits').map((t) => t.content),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
deprecated: signature.comment?.tags?.some((t) => t.tagName === 'deprecated'),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
emits: signature.comment?.tags?.filter((t) => t.tagName === 'emits').map((t) => t.text.trim()),
// @ts-expect-error // @ts-expect-error
params: signature.parameters params: signature.parameters
? (signature as SignatureReflection).parameters?.map((p) => new DocumentedParam(p, this.config).serialize()) ? (signature as SignatureReflection).parameters?.map((p) => new DocumentedParam(p, this.config).serialize())
@@ -46,12 +63,27 @@ export class DocumentedMethod extends DocumentedItem<Method | DeclarationReflect
returns: signature.type returns: signature.type
? [ ? [
new DocumentedVarType( new DocumentedVarType(
{ names: [parseType(signature.type)], description: signature.comment?.returns?.trim() }, {
names: [parseType(signature.type)],
description:
signature.comment?.blockTags
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
?.find((t) => t.tag === '@returns')
?.content.reduce((prev, curr) => (prev += curr.text), '')
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
.trim() || undefined,
},
this.config, this.config,
).serialize(), ).serialize(),
] ]
: undefined, : undefined,
returnsDescription: signature.comment?.returns?.trim(), returnsDescription:
signature.comment?.blockTags
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
?.find((t) => t.tag === '@returns')
?.content.reduce((prev, curr) => (prev += curr.text), '')
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
.trim() || undefined,
meta, meta,
}; };
} }

View File

@@ -11,13 +11,18 @@ export class DocumentedParam extends DocumentedItem<Param | ParameterReflection>
return { return {
name: data.name, name: data.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
description: data.comment?.shortText?.trim() ?? data.comment?.text.trim(), description: data.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined,
optional: data.flags.isOptional || typeof data.defaultValue != 'undefined', optional: data.flags.isOptional || typeof data.defaultValue != 'undefined',
default: default:
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition (data.defaultValue === '...' ? undefined : data.defaultValue) ??
data.comment?.tags?.find((t) => t.tagName === 'default')?.text.trim() ?? (data.comment?.blockTags
(data.defaultValue === '...' ? undefined : data.defaultValue), // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
?.find((t) => t.tag === '@default')
?.content.reduce((prev, curr) => (prev += curr.text), '')
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
.trim() ||
undefined),
variable: data.flags.isRest, variable: data.flags.isRest,
type: data.type ? new DocumentedVarType({ names: [parseType(data.type)] }, this.config).serialize() : undefined, type: data.type ? new DocumentedVarType({ names: [parseType(data.type)] }, this.config).serialize() : undefined,
}; };

View File

@@ -1,4 +1,4 @@
import type { DeclarationReflection } from 'typedoc'; import type { DeclarationReflection, LiteralType } from 'typedoc';
import { DocumentedItemMeta } from './item-meta.js'; import { DocumentedItemMeta } from './item-meta.js';
import { DocumentedItem } from './item.js'; import { DocumentedItem } from './item.js';
import { DocumentedParam } from './param.js'; import { DocumentedParam } from './param.js';
@@ -11,6 +11,7 @@ export class DocumentedTypeDef extends DocumentedItem<Typedef | DeclarationRefle
public override serializer() { public override serializer() {
if (this.config.typescript) { if (this.config.typescript) {
const data = this.data as DeclarationReflection; const data = this.data as DeclarationReflection;
const signature = (data.signatures ?? [])[0] ?? data;
let meta; let meta;
const sources = data.sources?.[0]; const sources = data.sources?.[0];
@@ -18,20 +19,34 @@ export class DocumentedTypeDef extends DocumentedItem<Typedef | DeclarationRefle
meta = new DocumentedItemMeta(sources, this.config).serialize(); meta = new DocumentedItemMeta(sources, this.config).serialize();
} }
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const see = signature.comment?.blockTags?.filter((t) => t.tag === '@see').length
? signature.comment.blockTags
.filter((t) => t.tag === '@see')
.map((t) => t.content.find((c) => c.kind === 'text')?.text.trim())
: undefined;
const baseReturn = { const baseReturn = {
name: data.name, name: signature.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
description: data.comment?.shortText?.trim(), description: signature.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition see,
see: data.comment?.tags?.filter((t) => t.tagName === 'see').map((t) => t.text.trim()),
access: access:
data.flags.isPrivate ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
data.flags.isPrivate || data.comment?.tags?.some((t) => t.tagName === 'private' || t.tagName === 'internal') signature.comment?.blockTags?.some((t) => t.tag === '@private' || t.tag === '@internal')
? 'private' ? 'private'
: undefined, : undefined,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
deprecated: data.comment?.tags?.some((t) => t.tagName === 'deprecated'), deprecated: signature.comment?.blockTags?.some((t) => t.tag === '@deprecated')
type: data.type ? new DocumentedVarType({ names: [parseType(data.type)] }, this.config).serialize() : undefined, ? signature.comment.blockTags
.find((t) => t.tag === '@deprecated')
?.content.reduce((prev, curr) => (prev += curr.text), '')
.trim() ?? true
: undefined,
type: signature.type
? new DocumentedVarType({ names: [parseType(signature.type)] }, this.config).serialize()
: undefined,
meta, meta,
}; };
@@ -46,8 +61,13 @@ export class DocumentedTypeDef extends DocumentedItem<Typedef | DeclarationRefle
props: data.children?.length props: data.children?.length
? data.children.map((child) => ({ ? data.children.map((child) => ({
name: child.name, name: child.name,
description: child.comment?.shortText.trim(), description:
type: typeof child.defaultValue == 'undefined' ? undefined : [[[child.defaultValue]]], child.comment?.summary
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
?.reduce((prev, curr) => (prev += curr.text), '')
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
.trim() || undefined,
type: [[[(child.type as LiteralType | undefined)?.value]]],
})) }))
: undefined, : undefined,
}; };
@@ -59,13 +79,25 @@ export class DocumentedTypeDef extends DocumentedItem<Typedef | DeclarationRefle
if (children && children.length > 0) { if (children && children.length > 0) {
const props = children.map((child) => ({ const props = children.map((child) => ({
name: child.name, name: child.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition description:
description: child.comment?.shortText?.trim() ?? child.signatures?.[0]?.comment?.shortText?.trim(), child.comment?.summary
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
?.reduce((prev, curr) => (prev += curr.text), '')
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
.trim() ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
child.signatures?.[0]?.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() ||
undefined,
optional: child.flags.isOptional || typeof child.defaultValue != 'undefined', optional: child.flags.isOptional || typeof child.defaultValue != 'undefined',
default: default:
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition (child.defaultValue === '...' ? undefined : child.defaultValue) ??
child.comment?.tags?.find((t) => t.tagName === 'default')?.text.trim() ?? (child.comment?.blockTags
(child.defaultValue === '...' ? undefined : child.defaultValue), // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
?.find((t) => t.tag === '@default')
?.content.reduce((prev, curr) => (prev += curr.text), '')
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
.trim() ||
undefined),
type: child.type type: child.type
? new DocumentedVarType({ names: [parseType(child.type)] }, this.config).serialize() ? new DocumentedVarType({ names: [parseType(child.type)] }, this.config).serialize()
: child.kindString === 'Method' : child.kindString === 'Method'
@@ -77,6 +109,11 @@ export class DocumentedTypeDef extends DocumentedItem<Typedef | DeclarationRefle
declaration: child, declaration: child,
}), }),
], ],
description: child.signatures?.[0]?.comment?.blockTags
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
?.find((t) => t.tag === '@returns')
?.content.reduce((prev, curr) => (prev += curr.text), '')
.trim(),
}, },
this.config, this.config,
).serialize() ).serialize()
@@ -94,42 +131,74 @@ export class DocumentedTypeDef extends DocumentedItem<Typedef | DeclarationRefle
const params = sig?.parameters?.map((param) => ({ const params = sig?.parameters?.map((param) => ({
name: param.name, name: param.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
description: param.comment?.shortText?.trim(), description: param.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined,
optional: param.flags.isOptional || typeof param.defaultValue != 'undefined', optional: param.flags.isOptional || typeof param.defaultValue != 'undefined',
default: default:
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition (param.defaultValue === '...' ? undefined : param.defaultValue) ??
param.comment?.tags?.find((t) => t.tagName === 'default')?.text.trim() ?? (param.comment?.blockTags
(param.defaultValue === '...' ? undefined : param.defaultValue), // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
?.find((t) => t.tag === '@default')
?.content.reduce((prev, curr) => (prev += curr.text), '')
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
.trim() ||
undefined),
type: param.type type: param.type
? new DocumentedVarType({ names: [parseType(param.type)] }, this.config).serialize() ? new DocumentedVarType({ names: [parseType(param.type)] }, this.config).serialize()
: undefined, : undefined,
})); }));
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const see = sig?.comment?.blockTags?.filter((t) => t.tag === '@see').length
? sig.comment.blockTags
.filter((t) => t.tag === '@see')
.map((t) => t.content.find((c) => c.kind === 'text')?.text.trim())
: undefined;
return { return {
...baseReturn, ...baseReturn,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
description: sig?.comment?.shortText?.trim(), description: sig?.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition see,
see: sig?.comment?.tags?.filter((t) => t.tagName === 'see').map((t) => t.text.trim()),
access: access:
sig?.flags.isPrivate || sig?.flags.isPrivate ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
sig?.comment?.tags?.some((t) => t.tagName === 'private' || t.tagName === 'internal') sig?.comment?.blockTags?.some((t) => t.tag === '@private' || t.tag === '@internal')
? 'private' ? 'private'
: undefined, : undefined,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
deprecated: sig?.comment?.tags?.some((t) => t.tagName === 'deprecated'), deprecated: sig?.comment?.blockTags?.some((t) => t.tag === '@deprecated')
? sig.comment.blockTags
.find((t) => t.tag === '@deprecated')
?.content.reduce((prev, curr) => (prev += curr.text), '')
.trim() ?? true
: undefined,
params, params,
returns: sig?.type returns: sig?.type
? [ ? [
new DocumentedVarType( new DocumentedVarType(
{ names: [parseType(sig.type)], description: sig.comment?.returns?.trim() }, {
names: [parseType(sig.type)],
description:
sig.comment?.blockTags
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
?.find((t) => t.tag === '@returns')
?.content.reduce((prev, curr) => (prev += curr.text), '')
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
.trim() || undefined,
},
this.config, this.config,
).serialize(), ).serialize(),
] ]
: undefined, : undefined,
returnsDescription: sig?.comment?.returns?.trim(), returnsDescription:
sig?.comment?.blockTags
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
?.find((t) => t.tag === '@returns')
?.content.reduce((prev, curr) => (prev += curr.text), '')
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
.trim() || undefined,
meta,
}; };
} }
} }

View File

@@ -60,7 +60,7 @@
"@discordjs/docgen": "workspace:^", "@discordjs/docgen": "workspace:^",
"@discordjs/scripts": "workspace:^", "@discordjs/scripts": "workspace:^",
"@favware/cliff-jumper": "^1.8.3", "@favware/cliff-jumper": "^1.8.3",
"@types/node": "^16.11.38", "@types/node": "^16.11.39",
"@types/supertest": "^2.0.12", "@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^5.27.1", "@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1", "@typescript-eslint/parser": "^5.27.1",

View File

@@ -53,7 +53,7 @@
"@discordjs/collection": "workspace:^", "@discordjs/collection": "workspace:^",
"@sapphire/async-queue": "^1.3.1", "@sapphire/async-queue": "^1.3.1",
"@sapphire/snowflake": "^3.2.2", "@sapphire/snowflake": "^3.2.2",
"discord-api-types": "^0.33.4", "discord-api-types": "^0.33.5",
"tslib": "^2.4.0", "tslib": "^2.4.0",
"undici": "^5.4.0" "undici": "^5.4.0"
}, },

View File

@@ -46,7 +46,7 @@
"tslib": "^2.4.0" "tslib": "^2.4.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^16.11.38", "@types/node": "^16.11.39",
"@typescript-eslint/eslint-plugin": "^5.27.1", "@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1", "@typescript-eslint/parser": "^5.27.1",
"eslint": "^8.17.0", "eslint": "^8.17.0",

View File

@@ -52,11 +52,11 @@
"homepage": "https://discord.js.org", "homepage": "https://discord.js.org",
"dependencies": { "dependencies": {
"@types/ws": "^8.5.3", "@types/ws": "^8.5.3",
"discord-api-types": "^0.33.4", "discord-api-types": "^0.33.5",
"prism-media": "^1.3.2", "prism-media": "^1.3.2",
"tiny-typed-emitter": "^2.1.0", "tiny-typed-emitter": "^2.1.0",
"tslib": "^2.4.0", "tslib": "^2.4.0",
"ws": "^8.7.0" "ws": "^8.8.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.18.2", "@babel/core": "^7.18.2",
@@ -66,7 +66,7 @@
"@discordjs/scripts": "workspace:^", "@discordjs/scripts": "workspace:^",
"@favware/cliff-jumper": "^1.8.3", "@favware/cliff-jumper": "^1.8.3",
"@types/jest": "^28.1.1", "@types/jest": "^28.1.1",
"@types/node": "^16.11.38", "@types/node": "^16.11.39",
"@typescript-eslint/eslint-plugin": "^5.27.1", "@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1", "@typescript-eslint/parser": "^5.27.1",
"eslint": "^8.17.0", "eslint": "^8.17.0",
@@ -74,9 +74,9 @@
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^2.7.1", "eslint-import-resolver-typescript": "^2.7.1",
"eslint-plugin-import": "^2.26.0", "eslint-plugin-import": "^2.26.0",
"jest": "^28.1.0", "jest": "^28.1.1",
"jest-websocket-mock": "^2.3.0", "jest-websocket-mock": "^2.3.0",
"mock-socket": "^9.1.4", "mock-socket": "^9.1.5",
"prettier": "^2.6.2", "prettier": "^2.6.2",
"tsup": "^6.1.0", "tsup": "^6.1.0",
"tweetnacl": "^1.0.3", "tweetnacl": "^1.0.3",

View File

@@ -1,7 +1,7 @@
import type { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v10'; import type { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v10';
/** /**
* Methods that are provided by the @discordjs/voice library to implementations of * Methods that are provided by the \@discordjs/voice library to implementations of
* Discord gateway DiscordGatewayAdapters. * Discord gateway DiscordGatewayAdapters.
*/ */
export interface DiscordGatewayAdapterLibraryMethods { export interface DiscordGatewayAdapterLibraryMethods {
@@ -36,7 +36,7 @@ export interface DiscordGatewayAdapterImplementerMethods {
*/ */
sendPayload: (payload: any) => boolean; sendPayload: (payload: any) => boolean;
/** /**
* This will be called by @discordjs/voice when the adapter can safely be destroyed as it will no * This will be called by \@discordjs/voice when the adapter can safely be destroyed as it will no
* longer be used. * longer be used.
*/ */
destroy: () => void; destroy: () => void;

View File

@@ -62,7 +62,7 @@
"@testing-library/jest-dom": "^5.16.4", "@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0", "@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^14.2.0", "@testing-library/user-event": "^14.2.0",
"@types/node": "^16.11.38", "@types/node": "^16.11.39",
"@types/react": "^18.0.12", "@types/react": "^18.0.12",
"@types/react-dom": "^18.0.5", "@types/react-dom": "^18.0.5",
"@typescript-eslint/eslint-plugin": "^5.27.1", "@typescript-eslint/eslint-plugin": "^5.27.1",
@@ -79,7 +79,7 @@
"eslint-plugin-import": "^2.26.0", "eslint-plugin-import": "^2.26.0",
"eslint-plugin-react": "^7.30.0", "eslint-plugin-react": "^7.30.0",
"eslint-plugin-react-hooks": "^4.5.0", "eslint-plugin-react-hooks": "^4.5.0",
"happy-dom": "^5.0.0", "happy-dom": "^5.2.0",
"msw": "^0.42.1", "msw": "^0.42.1",
"prettier": "^2.6.2", "prettier": "^2.6.2",
"typedoc": "^0.22.17", "typedoc": "^0.22.17",

716
yarn.lock

File diff suppressed because it is too large Load Diff