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"
},
"devDependencies": {
"@types/node": "^16.11.38",
"@types/node": "^16.11.39",
"@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1",
"eslint": "^8.17.0",

View File

@@ -54,7 +54,7 @@
"dependencies": {
"@sapphire/shapeshift": "^3.1.0",
"@sindresorhus/is": "^4.6.0",
"discord-api-types": "^0.33.4",
"discord-api-types": "^0.33.5",
"fast-deep-equal": "^3.1.3",
"ts-mixer": "^6.0.1",
"tslib": "^2.4.0"
@@ -63,7 +63,7 @@
"@discordjs/docgen": "workspace:^",
"@discordjs/scripts": "workspace:^",
"@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/parser": "^5.27.1",
"eslint": "^8.17.0",

View File

@@ -51,7 +51,7 @@
"@discordjs/docgen": "workspace:^",
"@discordjs/scripts": "workspace:^",
"@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/parser": "^5.27.1",
"eslint": "^8.17.0",

View File

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

View File

@@ -53,12 +53,12 @@
"commander": "^9.3.0",
"jsdoc-to-markdown": "^7.1.1",
"tslib": "^2.4.0",
"typedoc": "^0.22.17"
"typedoc": "^0.23.0-beta.4"
},
"devDependencies": {
"@favware/cliff-jumper": "^1.8.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/parser": "^5.27.1",
"eslint": "^8.17.0",

View File

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

View File

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

View File

@@ -16,14 +16,25 @@ export class DocumentedEvent extends DocumentedItem<Event | DeclarationReflectio
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 {
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
description: signature.comment?.shortText?.trim(),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
see: signature.comment?.tags?.filter((t) => t.tagName === 'see').map((t) => t.text.trim()),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
deprecated: signature.comment?.tags?.some((t) => t.tagName === 'deprecated'),
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,
// @ts-expect-error
params: signature.parameters
? (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 { DocumentedItem } from './item.js';
import type { Meta } from '../interfaces/index.js';
@@ -11,7 +11,8 @@ export class DocumentedItemMeta extends DocumentedItem<Meta | SourceReference> {
return {
line: data.line,
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() {
if (this.config.typescript) {
const data = this.data as DeclarationReflection;
const signature = (data.signatures ?? [])[0] ?? data;
let meta;
const sources = data.sources?.[0];
@@ -17,28 +18,47 @@ export class DocumentedMember extends DocumentedItem<Member | DeclarationReflect
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 = {
name: data.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
description: data.comment?.shortText?.trim(),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
see: data.comment?.tags?.filter((t) => t.tagName === 'see').map((t) => t.text.trim()),
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,
scope: data.flags.isStatic ? 'static' : undefined,
access:
data.flags.isPrivate ||
// 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'
: undefined,
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
abstract: data.comment?.tags?.some((t) => t.tagName === 'abstract'),
// 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')
? signature.comment.blockTags
.find((t) => t.tag === '@deprecated')
?.content.reduce((prev, curr) => (prev += curr.text), '')
.trim() ?? true
: undefined,
default:
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
data.comment?.tags?.find((t) => t.tagName === 'default')?.text.trim() ??
(data.defaultValue === '...' ? undefined : data.defaultValue),
type: data.type ? new DocumentedVarType({ names: [parseType(data.type)] }, this.config).serialize() : undefined,
(data.defaultValue === '...' ? undefined : data.defaultValue) ??
(signature.comment?.blockTags
// 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: signature.type
? new DocumentedVarType({ names: [parseType(signature.type)] }, this.config).serialize()
: undefined,
meta,
};
@@ -50,28 +70,47 @@ export class DocumentedMember extends DocumentedItem<Member | DeclarationReflect
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 {
...base,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
description: getter.comment?.shortText?.trim(),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
see: getter.comment?.tags?.filter((t) => t.tagName === 'see').map((t) => t.text.trim()),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
description: getter.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined,
see,
access:
getter.flags.isPrivate ||
getter.comment?.tags.some((t) => t.tagName === 'private' || t.tagName === 'internal')
data.flags.isPrivate ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
getter.comment?.blockTags?.some((t) => t.tag === '@private' || t.tag === '@internal')
? 'private'
: undefined,
readonly: base.readonly || !hasSetter,
abstract: getter.comment?.tags.some((t) => t.tagName === 'abstract'),
deprecated: getter.comment?.tags.some((t) => t.tagName === 'deprecated'),
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
abstract: getter.comment?.blockTags?.some((t) => t.tag === '@abstract') || undefined,
// 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:
base.default ??
getter.comment?.tags.find((t) => t.tagName === 'default')?.text.trim() ??
// @ts-expect-error
getter.defaultValue,
(getter.comment?.blockTags
// 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: 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();
}
// 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 {
name: data.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
description: signature.comment?.shortText?.trim(),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
see: signature.comment?.tags?.filter((t) => t.tagName === 'see').map((t) => t.text.trim()),
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,
scope: data.flags.isStatic ? 'static' : undefined,
access:
data.flags.isPrivate ||
// 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'
: 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
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
abstract: signature.comment?.tags?.some((t) => t.tagName === 'abstract'),
// 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()),
// emits: signature.comment?.blockTags?.filter((t) => t.tag === '@emits').map((t) => t.content),
// @ts-expect-error
params: signature.parameters
? (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
? [
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,
).serialize(),
]
: 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,
};
}

View File

@@ -11,13 +11,18 @@ export class DocumentedParam extends DocumentedItem<Param | ParameterReflection>
return {
name: data.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
description: data.comment?.shortText?.trim() ?? data.comment?.text.trim(),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
description: data.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined,
optional: data.flags.isOptional || typeof data.defaultValue != 'undefined',
default:
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
data.comment?.tags?.find((t) => t.tagName === 'default')?.text.trim() ??
(data.defaultValue === '...' ? undefined : data.defaultValue),
(data.defaultValue === '...' ? undefined : data.defaultValue) ??
(data.comment?.blockTags
// 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,
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 { DocumentedItem } from './item.js';
import { DocumentedParam } from './param.js';
@@ -11,6 +11,7 @@ export class DocumentedTypeDef extends DocumentedItem<Typedef | DeclarationRefle
public override serializer() {
if (this.config.typescript) {
const data = this.data as DeclarationReflection;
const signature = (data.signatures ?? [])[0] ?? data;
let meta;
const sources = data.sources?.[0];
@@ -18,20 +19,34 @@ export class DocumentedTypeDef extends DocumentedItem<Typedef | DeclarationRefle
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 = {
name: data.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
description: data.comment?.shortText?.trim(),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
see: data.comment?.tags?.filter((t) => t.tagName === 'see').map((t) => t.text.trim()),
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,
access:
data.flags.isPrivate ||
// 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'
: undefined,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
deprecated: data.comment?.tags?.some((t) => t.tagName === 'deprecated'),
type: data.type ? new DocumentedVarType({ names: [parseType(data.type)] }, this.config).serialize() : undefined,
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,
type: signature.type
? new DocumentedVarType({ names: [parseType(signature.type)] }, this.config).serialize()
: undefined,
meta,
};
@@ -46,8 +61,13 @@ export class DocumentedTypeDef extends DocumentedItem<Typedef | DeclarationRefle
props: data.children?.length
? data.children.map((child) => ({
name: child.name,
description: child.comment?.shortText.trim(),
type: typeof child.defaultValue == 'undefined' ? undefined : [[[child.defaultValue]]],
description:
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,
};
@@ -59,13 +79,25 @@ export class DocumentedTypeDef extends DocumentedItem<Typedef | DeclarationRefle
if (children && children.length > 0) {
const props = children.map((child) => ({
name: child.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
description: child.comment?.shortText?.trim() ?? child.signatures?.[0]?.comment?.shortText?.trim(),
description:
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',
default:
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
child.comment?.tags?.find((t) => t.tagName === 'default')?.text.trim() ??
(child.defaultValue === '...' ? undefined : child.defaultValue),
(child.defaultValue === '...' ? undefined : child.defaultValue) ??
(child.comment?.blockTags
// 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
? new DocumentedVarType({ names: [parseType(child.type)] }, this.config).serialize()
: child.kindString === 'Method'
@@ -77,6 +109,11 @@ export class DocumentedTypeDef extends DocumentedItem<Typedef | DeclarationRefle
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,
).serialize()
@@ -94,42 +131,74 @@ export class DocumentedTypeDef extends DocumentedItem<Typedef | DeclarationRefle
const params = sig?.parameters?.map((param) => ({
name: param.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
description: param.comment?.shortText?.trim(),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
description: param.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined,
optional: param.flags.isOptional || typeof param.defaultValue != 'undefined',
default:
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
param.comment?.tags?.find((t) => t.tagName === 'default')?.text.trim() ??
(param.defaultValue === '...' ? undefined : param.defaultValue),
(param.defaultValue === '...' ? undefined : param.defaultValue) ??
(param.comment?.blockTags
// 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
? new DocumentedVarType({ names: [parseType(param.type)] }, this.config).serialize()
: 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 {
...baseReturn,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
description: sig?.comment?.shortText?.trim(),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
see: sig?.comment?.tags?.filter((t) => t.tagName === 'see').map((t) => t.text.trim()),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing
description: sig?.comment?.summary?.reduce((prev, curr) => (prev += curr.text), '').trim() || undefined,
see,
access:
sig?.flags.isPrivate ||
// 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'
: undefined,
// 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,
returns: sig?.type
? [
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,
).serialize(),
]
: 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/scripts": "workspace:^",
"@favware/cliff-jumper": "^1.8.3",
"@types/node": "^16.11.38",
"@types/node": "^16.11.39",
"@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1",

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
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.
*/
export interface DiscordGatewayAdapterLibraryMethods {
@@ -36,7 +36,7 @@ export interface DiscordGatewayAdapterImplementerMethods {
*/
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.
*/
destroy: () => void;

View File

@@ -62,7 +62,7 @@
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.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-dom": "^18.0.5",
"@typescript-eslint/eslint-plugin": "^5.27.1",
@@ -79,7 +79,7 @@
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-react": "^7.30.0",
"eslint-plugin-react-hooks": "^4.5.0",
"happy-dom": "^5.0.0",
"happy-dom": "^5.2.0",
"msw": "^0.42.1",
"prettier": "^2.6.2",
"typedoc": "^0.22.17",

716
yarn.lock

File diff suppressed because it is too large Load Diff