feat(docgen): typescript support

This commit is contained in:
iCrawl
2022-06-08 17:26:54 +02:00
parent 1afae909d7
commit 3279b40912
42 changed files with 962 additions and 328 deletions

View File

@@ -19,7 +19,7 @@ dist/
typings/
docs/**/*
!docs/index.yml
!docs/index.json
!docs/README.md
!docs/examples/
!docs/examples/*.md

View File

@@ -0,0 +1 @@
[{ "name": "General", "files": [{ "name": "Welcome", "id": "welcome", "path": "../../README.md" }] }]

View File

@@ -1,5 +0,0 @@
- name: General
files:
- name: Welcome
id: welcome
path: ../../README.md

View File

@@ -6,7 +6,7 @@
"build": "tsup",
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && ts-docgen -i docs/typedoc-out.json -c docs/index.yml -o docs/docs.json",
"docs": "docgen -i src/index.ts -c docs/index.json -o docs/docs.json --typescript",
"prepublishOnly": "yarn build && yarn lint && yarn test",
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/builders/*'",
"release": "cliff-jumper"
@@ -60,6 +60,7 @@
"tslib": "^2.4.0"
},
"devDependencies": {
"@discordjs/docgen": "workspace:^",
"@discordjs/scripts": "workspace:^",
"@favware/cliff-jumper": "^1.8.3",
"@types/node": "^16.11.38",
@@ -71,7 +72,6 @@
"eslint-plugin-import": "^2.26.0",
"prettier": "^2.6.2",
"tsup": "^6.1.0",
"typedoc": "^0.22.17",
"typescript": "^4.7.3"
},
"engines": {

View File

@@ -18,7 +18,7 @@ pids
dist/
typings/
docs/**/*
!docs/index.yml
!docs/index.json
!docs/README.md
# Miscellaneous

View File

@@ -0,0 +1 @@
[{ "name": "General", "files": [{ "name": "Welcome", "id": "welcome", "path": "../../README.md" }] }]

View File

@@ -1,5 +0,0 @@
- name: General
files:
- name: Welcome
id: welcome
path: ../../README.md

View File

@@ -6,7 +6,7 @@
"build": "tsup",
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && ts-docgen -i docs/typedoc-out.json -c docs/index.yml -o docs/docs.json",
"docs": "docgen -i src/index.ts -c docs/index.json -o docs/docs.json --typescript",
"prepublishOnly": "yarn build && yarn lint && yarn test",
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/collection/*'",
"release": "cliff-jumper"
@@ -48,6 +48,7 @@
},
"homepage": "https://discord.js.org",
"devDependencies": {
"@discordjs/docgen": "workspace:^",
"@discordjs/scripts": "workspace:^",
"@favware/cliff-jumper": "^1.8.3",
"@types/node": "^16.11.38",
@@ -59,7 +60,6 @@
"eslint-plugin-import": "^2.26.0",
"prettier": "^2.6.2",
"tsup": "^6.1.0",
"typedoc": "^0.22.17",
"typescript": "^4.7.3"
},
"engines": {

View File

@@ -49,10 +49,11 @@
},
"homepage": "https://discord.js.org",
"dependencies": {
"@discordjs/collection": "workspace:^",
"@discordjs/collection": "^0.7.0",
"commander": "^9.3.0",
"jsdoc-to-markdown": "^7.1.1",
"tslib": "^2.4.0"
"tslib": "^2.4.0",
"typedoc": "^0.22.17"
},
"devDependencies": {
"@favware/cliff-jumper": "^1.8.3",

View File

@@ -1,5 +1,6 @@
import { join } from 'node:path';
import { dirname, join } from 'node:path';
import { Collection } from '@discordjs/collection';
import type { DeclarationReflection } from 'typedoc';
import type { ChildTypes, Class, Config, CustomDocs, RootTypes } from './interfaces/index.js';
import { DocumentedClass } from './types/class.js';
import { DocumentedConstructor } from './types/constructor.js';
@@ -23,11 +24,44 @@ export class Documentation {
public readonly externals = new Collection<string, DocumentedExternal>();
public constructor(
data: RootTypes[],
data: RootTypes[] | DeclarationReflection[],
private readonly config: Config,
private readonly custom?: Record<string, CustomDocs>,
) {
let items = data;
if (config.typescript) {
const items = data as DeclarationReflection[];
for (const item of items) {
switch (item.kindString) {
case 'Class': {
this.classes.set(item.name, new DocumentedClass(item, config));
if (item.children) {
this.parse(item.children, item.name);
}
break;
}
case 'Function': {
this.functions.set(item.name, new DocumentedMethod(item, config));
break;
}
case 'Interface':
case 'Type alias':
case 'Enumeration':
this.typedefs.set(item.name, new DocumentedTypeDef(item, config));
if (item.children) {
this.parse(item.children, item.name);
}
break;
default:
break;
}
}
} else {
let items = data as RootTypes[];
for (const item of items) {
switch (item.kind) {
case 'class': {
@@ -64,9 +98,71 @@ export class Documentation {
this.parse(items as ChildTypes[]);
}
}
public parse(items: ChildTypes[]) {
for (const member of items) {
public parse(items: ChildTypes[] | DeclarationReflection[], memberOf = '') {
if (this.config.typescript) {
const it = items as DeclarationReflection[];
for (const member of it) {
let item: DocumentedMethod | DocumentedConstructor | DocumentedMember | DocumentedEvent | null = null;
switch (member.kindString) {
case 'Constructor': {
item = new DocumentedConstructor(member, this.config);
break;
}
case 'Method': {
item = new DocumentedMethod(member, this.config);
break;
}
case 'Property': {
item = new DocumentedMember(member, this.config);
break;
}
case 'event': {
item = new DocumentedEvent(member, this.config);
break;
}
default: {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
console.warn(`- Unknown documentation kind "${member.kindString}" - \n${JSON.stringify(member)}\n`);
}
}
const parent = this.classes.get(memberOf) ?? this.interfaces.get(memberOf);
if (parent) {
if (item) {
parent.add(item);
} else {
console.warn(
`- Documentation item could not be constructed for "${member.name}" - \n${JSON.stringify(member)}\n`,
);
}
continue;
}
const info = [];
const name = (member.name || item?.data.name) ?? 'UNKNOWN';
const meta =
member.kindString === 'constructor'
? null
: {
file: member.sources?.[0]?.fileName,
line: member.sources?.[0]?.line,
path: dirname(member.sources?.[0]?.fileName ?? ''),
};
if (memberOf) info.push(`member of "${memberOf}"`);
if (meta) info.push(`${join(meta.path, meta.file ?? '')}${meta.line ? `:${meta.line}` : ''}`);
console.warn(`- "${name}"${info.length ? ` (${info.join(', ')})` : ''} has no accessible parent.`);
if (!name && !info.length) console.warn('Raw object:', member);
}
} else {
const it = items as ChildTypes[];
for (const member of it) {
let item: DocumentedMethod | DocumentedConstructor | DocumentedMember | DocumentedEvent | null = null;
switch (member.kind) {
@@ -107,19 +203,22 @@ export class Documentation {
const info = [];
const name = (member.name || item?.data.name) ?? 'UNKNOWN';
const memberof = member.memberof ?? item?.data.memberof;
// @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unnecessary-condition
const memberof = member.memberof ?? item?.data?.memberof;
const meta =
member.kind === 'constructor'
? null
: { file: member.meta.filename, line: member.meta.lineno, path: member.meta.path };
if (memberof) info.push(`member of "${memberof}"`);
if (memberof) info.push(`member of "${memberof as string}"`);
if (meta) info.push(`${join(meta.path, meta.file)}${meta.line ? `:${meta.line}` : ''}`);
console.warn(`- "${name}"${info.length ? ` (${info.join(', ')})` : ''} has no accessible parent.`);
if (!name && !info.length) console.warn('Raw object:', member);
}
}
}
public serialize() {
return {

View File

@@ -3,6 +3,7 @@ import { readFileSync, writeFileSync } from 'node:fs';
import { join, basename, extname, dirname, relative } from 'node:path';
import { createCommand } from 'commander';
import jsdoc2md from 'jsdoc-to-markdown';
import { Application, DeclarationReflection, TSConfigReader } from 'typedoc';
import { Documentation } from './documentation.js';
import type { ChildTypes, CustomDocs, RootTypes } from './interfaces/index.js';
import packageFile from '../package.json';
@@ -12,6 +13,7 @@ interface CLIOptions {
custom: string;
root: string;
output: string;
typescript: boolean;
}
interface CustomFiles {
@@ -30,14 +32,29 @@ const command = createCommand()
.option('-i, --input <string...>', 'Source directories to parse JSDocs in')
.option('-c, --custom <string>', 'Custom docs definition file to use')
.option('-r, --root [string]', 'Root directory of the project', '.')
.option('-o, --output <string>', 'Path to output file');
.option('-o, --output <string>', 'Path to output file')
.option('--typescript', '', false);
const program = command.parse(process.argv);
const options = program.opts<CLIOptions>();
let data: (RootTypes & ChildTypes)[] | DeclarationReflection[] = [];
if (options.typescript) {
console.log('Parsing Typescript in source files...');
const app = new Application();
app.options.addReader(new TSConfigReader());
app.bootstrap({ entryPoints: options.input });
const project = app.convert();
if (project) {
// @ts-expect-error
data = app.serializer.toObject(project).children!;
console.log(`${data.length} items parsed.`);
}
} else {
console.log('Parsing JSDocs in source files...');
const data = jsdoc2md.getTemplateDataSync({ files: options.input }) as (RootTypes & ChildTypes)[];
data = jsdoc2md.getTemplateDataSync({ files: options.input }) as (RootTypes & ChildTypes)[];
console.log(`${data.length} JSDoc items parsed.`);
}
const custom: Record<string, CustomDocs> = {};
if (options.custom) {

View File

@@ -1,3 +1,7 @@
export interface Config {
input: string[];
custom: string;
root: string;
output: string;
typescript: boolean;
}

View File

@@ -1,4 +1,6 @@
import { parse } from 'node:path';
import { Collection } from '@discordjs/collection';
import type { DeclarationReflection } from 'typedoc';
import { DocumentedConstructor } from './constructor.js';
import { DocumentedEvent } from './event.js';
import { DocumentedItemMeta } from './item-meta.js';
@@ -7,8 +9,9 @@ import { DocumentedMember } from './member.js';
import { DocumentedMethod } from './method.js';
import { DocumentedVarType } from './var-type.js';
import type { Class, Config } from '../interfaces/index.js';
import { parseType } from '../util/parseType.js';
export class DocumentedClass extends DocumentedItem<Class> {
export class DocumentedClass extends DocumentedItem<Class | DeclarationReflection> {
public readonly props = new Collection<string, DocumentedMember>();
public readonly methods = new Collection<string, DocumentedMethod>();
@@ -21,15 +24,29 @@ export class DocumentedClass extends DocumentedItem<Class> {
public implements: DocumentedVarType | null = null;
public constructor(data: Class, config: Config) {
public constructor(data: Class | DeclarationReflection, config: Config) {
super(data, config);
if (data.augments) {
this.extends = new DocumentedVarType({ names: data.augments }, this.config);
if (config.typescript) {
const d = data as DeclarationReflection;
const extended = d.extendedTypes?.[0];
if (extended) {
this.extends = new DocumentedVarType({ names: [parseType(extended)] }, this.config);
}
if (data.implements) {
this.implements = new DocumentedVarType({ names: data.implements }, this.config);
const implemented = d.implementedTypes?.[0];
if (implemented) {
this.implements = new DocumentedVarType({ names: [parseType(implemented)] }, this.config);
}
} else {
const d = data as Class;
if (d.augments) {
this.extends = new DocumentedVarType({ names: d.augments }, this.config);
}
if (d.implements) {
this.implements = new DocumentedVarType({ names: d.implements }, this.config);
}
}
}
@@ -38,7 +55,9 @@ export class DocumentedClass extends DocumentedItem<Class> {
if (this.construct) throw new Error(`Doc ${this.data.name} already has constructor`);
this.construct = item;
} else if (item instanceof DocumentedMethod) {
const prefix = item.data.scope === 'static' ? 's-' : '';
// @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const prefix = item.data.scope === 'static' || item.data.flags?.isStatic ? 's-' : '';
if (this.methods.has(prefix + item.data.name)) {
throw new Error(`Doc ${this.data.name} already has method ${item.data.name}`);
}
@@ -57,20 +76,57 @@ export class DocumentedClass extends DocumentedItem<Class> {
}
public override serializer() {
if (this.config.typescript) {
const data = this.data as DeclarationReflection;
let meta;
const sources = data.sources?.[0];
if (sources) {
meta = new DocumentedItemMeta(sources, this.config).serialize();
}
return {
name: this.data.name,
description: this.data.description,
see: this.data.see,
// @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()),
extends: this.extends?.serialize(),
implements: this.implements?.serialize(),
access: this.data.access,
abstract: this.data.virtual,
deprecated: this.data.deprecated,
access:
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
data.flags.isPrivate || data.comment?.tags?.some((t) => t.tagName === 'private' || t.tagName === 'internal')
? 'private'
: 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'),
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,
events: this.events.size ? this.events.map((e) => e.serialize()) : undefined,
meta: new DocumentedItemMeta(this.data.meta, this.config).serialize(),
meta,
};
}
const data = this.data as Class;
return {
name: data.name,
description: data.description,
see: data.see,
extends: this.extends?.serialize(),
implements: this.implements?.serialize(),
access: data.access,
abstract: data.virtual,
deprecated: data.deprecated,
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,
events: this.events.size ? this.events.map((e) => e.serialize()) : undefined,
meta: new DocumentedItemMeta(data.meta, this.config).serialize(),
};
}
}

View File

@@ -1,17 +1,40 @@
import type { DeclarationReflection, SignatureReflection } from 'typedoc';
import { DocumentedItem } from './item.js';
import { DocumentedParam } from './param.js';
import type { Constructor } from '../interfaces/index.js';
export class DocumentedConstructor extends DocumentedItem<Constructor> {
export class DocumentedConstructor extends DocumentedItem<Constructor | DeclarationReflection> {
public override serializer() {
if (this.config.typescript) {
const data = this.data as DeclarationReflection;
const signature = (data.signatures ?? [])[0] ?? data;
return {
name: this.data.name,
description: this.data.description,
see: this.data.see,
access: this.data.access,
params: this.data.params?.length
? this.data.params.map((p) => new DocumentedParam(p, this.config).serialize())
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()),
access:
data.flags.isPrivate ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
signature.comment?.tags?.some((t) => t.tagName === 'private' || t.tagName === 'internal')
? 'private'
: undefined,
// @ts-expect-error
params: signature.parameters
? (signature as SignatureReflection).parameters?.map((p) => new DocumentedParam(p, this.config))
: undefined,
};
}
const data = this.data as Constructor;
return {
name: data.name,
description: data.description,
see: data.see,
access: data.access,
params: data.params?.length ? data.params.map((p) => new DocumentedParam(p, this.config).serialize()) : undefined,
};
}
}

View File

@@ -1,19 +1,45 @@
import type { DeclarationReflection, SignatureReflection } from 'typedoc';
import { DocumentedItemMeta } from './item-meta.js';
import { DocumentedItem } from './item.js';
import { DocumentedParam } from './param.js';
import type { Event } from '../interfaces/index.js';
export class DocumentedEvent extends DocumentedItem<Event> {
export class DocumentedEvent extends DocumentedItem<Event | DeclarationReflection> {
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];
if (sources) {
meta = new DocumentedItemMeta(sources, this.config).serialize();
}
return {
name: this.data.name,
description: this.data.description,
see: this.data.see,
deprecated: this.data.deprecated,
params: this.data.params?.length
? this.data.params.map((p) => new DocumentedParam(p, this.config).serialize())
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()),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
deprecated: signature.comment?.tags?.some((t) => t.tagName === 'deprecated'),
// @ts-expect-error
params: signature.parameters
? (signature as SignatureReflection).parameters?.map((p) => new DocumentedParam(p, this.config))
: undefined,
meta: new DocumentedItemMeta(this.data.meta, this.config).serialize(),
meta,
};
}
const data = this.data as Event;
return {
name: data.name,
description: data.description,
see: data.see,
deprecated: data.deprecated,
params: data.params?.length ? data.params.map((p) => new DocumentedParam(p, this.config).serialize()) : undefined,
meta: new DocumentedItemMeta(data.meta, this.config).serialize(),
};
}
}

View File

@@ -1,13 +1,25 @@
import { relative } from 'node:path';
import { basename, dirname, relative } from 'node:path';
import type { SourceReference } from 'typedoc';
import { DocumentedItem } from './item.js';
import type { Meta } from '../interfaces/index.js';
export class DocumentedItemMeta extends DocumentedItem<Meta> {
export class DocumentedItemMeta extends DocumentedItem<Meta | SourceReference> {
public override serializer() {
if (this.config.typescript) {
const data = this.data as SourceReference;
return {
line: this.data.lineno,
file: this.data.filename,
path: relative(this.config.root, this.data.path).replace(/\\/g, '/'),
line: data.line,
file: basename(data.fileName),
path: dirname(data.fileName),
};
}
const data = this.data as Meta;
return {
line: data.lineno,
file: data.filename,
path: relative(this.config.root, data.path).replace(/\\/g, '/'),
};
}
}

View File

@@ -1,9 +1,10 @@
import type { DeclarationReflection } from 'typedoc';
import type { Config, Item } from '../interfaces/index.js';
export class DocumentedItem<T = Item> {
export class DocumentedItem<T = Item | DeclarationReflection> {
public constructor(public readonly data: T, public readonly config: Config) {}
public serialize() {
public serialize(): unknown {
try {
return this.serializer();
} catch (err) {

View File

@@ -1,27 +1,101 @@
import type { DeclarationReflection } from 'typedoc';
import { DocumentedItemMeta } from './item-meta.js';
import { DocumentedItem } from './item.js';
import { DocumentedParam } from './param.js';
import { DocumentedVarType } from './var-type.js';
import type { Member } from '../interfaces/index.js';
import { parseType } from '../util/parseType.js';
export class DocumentedMember extends DocumentedItem<Member> {
export class DocumentedMember extends DocumentedItem<Member | DeclarationReflection> {
public override serializer() {
return {
name: this.data.name,
description: this.data.description,
see: this.data.see,
scope: this.data.scope,
access: this.data.access,
readonly: this.data.readonly,
nullable: this.data.nullable,
abstract: this.data.virtual,
deprecated: this.data.deprecated,
default: this.data.default,
type: new DocumentedVarType(this.data.type, this.config).serialize(),
props: this.data.properties?.length
? this.data.properties.map((p) => new DocumentedParam(p, this.config).serialize())
if (this.config.typescript) {
const data = this.data as DeclarationReflection;
let meta;
const sources = data.sources?.[0];
if (sources) {
meta = new DocumentedItemMeta(sources, this.config).serialize();
}
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()),
scope: data.flags.isStatic ? 'static' : undefined,
access:
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
data.flags.isPrivate || data.comment?.tags?.some((t) => t.tagName === 'private' || t.tagName === 'internal')
? 'private'
: undefined,
meta: new DocumentedItemMeta(this.data.meta, this.config).serialize(),
readonly: data.flags.isReadonly,
// 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'),
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,
meta,
};
if (data.kindString === 'Accessor') {
const getter = data.getSignature;
const hasSetter = data.setSignature;
if (!getter) {
throw new Error("Can't parse accessor without getter.");
}
if (!hasSetter) base.readonly = true;
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()),
access:
getter.flags.isPrivate ||
getter.comment?.tags.some((t) => t.tagName === 'private' || t.tagName === '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
default:
base.default ??
getter.comment?.tags.find((t) => t.tagName === 'default')?.text.trim() ??
// @ts-expect-error
getter.defaultValue,
type: getter.type ? parseType(getter.type) : undefined,
};
}
return base;
}
const data = this.data as Member;
return {
name: data.name,
description: data.description,
see: data.see,
scope: data.scope,
access: data.access,
readonly: data.readonly,
nullable: data.nullable,
abstract: data.virtual,
deprecated: data.deprecated,
default: data.default,
type: new DocumentedVarType(data.type, this.config).serialize(),
props: data.properties?.length
? data.properties.map((p) => new DocumentedParam(p, this.config).serialize())
: undefined,
meta: new DocumentedItemMeta(data.meta, this.config).serialize(),
};
}
}

View File

@@ -1,39 +1,86 @@
import type { DeclarationReflection, SignatureReflection } from 'typedoc';
import { DocumentedItemMeta } from './item-meta.js';
import { DocumentedItem } from './item.js';
import { DocumentedParam } from './param.js';
import { DocumentedVarType } from './var-type.js';
import type { Method } from '../interfaces/index.js';
import { parseType } from '../util/parseType.js';
export class DocumentedMethod extends DocumentedItem<Method> {
export class DocumentedMethod extends DocumentedItem<Method | DeclarationReflection> {
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];
if (sources) {
meta = new DocumentedItemMeta(sources, this.config).serialize();
}
return {
name: this.data.name,
description: this.data.description,
see: this.data.see,
scope: this.data.scope,
access: this.data.access,
inherits: this.data.inherits,
inherited: this.data.inherited,
implements: this.data.implements,
examples: this.data.examples,
abstract: this.data.virtual && !this.data.inherited,
deprecated: this.data.deprecated,
emits: this.data.fires,
throws: this.data.exceptions,
params: this.data.params?.length
? this.data.params.map((p) => new DocumentedParam(p, this.config).serialize())
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()),
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')
? 'private'
: undefined,
async: this.data.async,
generator: this.data.generator,
returns: this.data.returns?.length
? this.data.returns.map((p) =>
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
examples: signature.comment?.tags?.filter((t) => t.tagName === 'example').map((t) => t.text.trim()),
// 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()),
// @ts-expect-error
params: signature.parameters
? (signature as SignatureReflection).parameters?.map((p) => new DocumentedParam(p, this.config))
: undefined,
returns: signature.type
? new DocumentedVarType(
{ names: [parseType(signature.type)], description: signature.comment?.returns?.trim() },
this.config,
).serialize()
: undefined,
returnsDescription: signature.comment?.returns?.trim(),
meta,
};
}
const data = this.data as Method;
return {
name: data.name,
description: data.description,
see: data.see,
scope: data.scope,
access: data.access,
inherits: data.inherits,
inherited: data.inherited,
implements: data.implements,
examples: data.examples,
abstract: data.virtual && !data.inherited,
deprecated: data.deprecated,
emits: data.fires,
throws: data.exceptions,
params: data.params?.length ? data.params.map((p) => new DocumentedParam(p, this.config).serialize()) : undefined,
async: data.async,
generator: data.generator,
returns: data.returns?.length
? data.returns.map((p) =>
new DocumentedVarType(
{ names: p.type.names, description: p.description, nullable: p.nullable },
this.config,
).serialize(),
)
: undefined,
meta: new DocumentedItemMeta(this.data.meta, this.config).serialize(),
meta: new DocumentedItemMeta(data.meta, this.config).serialize(),
};
}
}

View File

@@ -1,17 +1,37 @@
import type { ParameterReflection } from 'typedoc';
import { DocumentedItem } from './item.js';
import { DocumentedVarType } from './var-type.js';
import type { Param } from '../interfaces/index.js';
import { parseType } from '../util/parseType.js';
export class DocumentedParam extends DocumentedItem<Param> {
export class DocumentedParam extends DocumentedItem<Param | ParameterReflection> {
public override serializer() {
if (this.config.typescript) {
const data = this.data as ParameterReflection;
return {
name: this.data.name,
description: this.data.description,
optional: this.data.optional,
default: this.data.defaultvalue,
variable: this.data.variable,
nullable: this.data.nullable,
type: new DocumentedVarType(this.data.type, this.config).serialize(),
name: data.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
description: data.comment?.shortText?.trim() ?? data.comment?.text.trim(),
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),
type: data.type ? new DocumentedVarType({ names: [parseType(data.type)] }, this.config).serialize() : undefined,
variable: data.flags.isRest,
};
}
const data = this.data as Param;
return {
name: data.name,
description: data.description,
optional: data.optional,
default: data.defaultvalue,
variable: data.variable,
nullable: data.nullable,
type: new DocumentedVarType(data.type, this.config).serialize(),
};
}
}

View File

@@ -1,28 +1,156 @@
import type { DeclarationReflection } from 'typedoc';
import { DocumentedItemMeta } from './item-meta.js';
import { DocumentedItem } from './item.js';
import { DocumentedParam } from './param.js';
import { DocumentedVarType } from './var-type.js';
import type { Typedef } from '../interfaces/index.js';
import { parseType } from '../util/parseType.js';
import { isReflectionType } from '../util/types.js';
export class DocumentedTypeDef extends DocumentedItem<Typedef> {
export class DocumentedTypeDef extends DocumentedItem<Typedef | DeclarationReflection> {
public override serializer() {
if (this.config.typescript) {
const data = this.data as DeclarationReflection;
let meta;
const sources = data.sources?.[0];
if (sources) {
meta = new DocumentedItemMeta(sources, this.config).serialize();
}
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()),
access:
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
data.flags.isPrivate || data.comment?.tags?.some((t) => t.tagName === 'private' || t.tagName === '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,
meta,
};
let typeDef: DeclarationReflection | undefined;
if (isReflectionType(data.type)) {
typeDef = data.type.declaration;
} else if (data.kindString === 'Interface') {
typeDef = data;
} else if (data.kindString === 'Enumeration') {
return {
name: this.data.name,
description: this.data.description,
see: this.data.see,
access: this.data.access,
deprecated: this.data.deprecated,
type: new DocumentedVarType(this.data.type, this.config).serialize(),
props: this.data.properties?.length
? this.data.properties.map((p) => new DocumentedParam(p, this.config).serialize())
...baseReturn,
props: data.children?.length
? data.children.map((child) => ({
name: child.name,
description: child.comment?.shortText.trim(),
type: typeof child.defaultValue == 'undefined' ? undefined : [[[child.defaultValue]]],
}))
: undefined,
params: this.data.params?.length
? this.data.params.map((p) => new DocumentedParam(p, this.config).serialize())
};
}
if (typeDef) {
const { children, signatures } = typeDef;
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(),
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),
type: child.type
? new DocumentedVarType({ names: [parseType(child.type)] }, this.config).serialize()
: child.kindString === 'Method'
? new DocumentedVarType(
{
names: [
parseType({
type: 'reflection',
declaration: child,
}),
],
},
this.config,
).serialize()
: undefined,
returns: this.data.returns?.length
? this.data.returns.map((p) => new DocumentedVarType(p, this.config).serialize())
}));
return {
...baseReturn,
props,
};
}
if (signatures && signatures.length > 0) {
const sig = signatures[0];
const params = sig?.parameters?.map((param) => ({
name: param.name,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
description: param.comment?.shortText?.trim(),
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),
type: param.type
? new DocumentedVarType({ names: [parseType(param.type)] }, this.config).serialize()
: undefined,
meta: new DocumentedItemMeta(this.data.meta, this.config).serialize(),
}));
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()),
access:
sig?.flags.isPrivate ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
sig?.comment?.tags?.some((t) => t.tagName === 'private' || t.tagName === 'internal')
? 'private'
: undefined,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
deprecated: sig?.comment?.tags?.some((t) => t.tagName === 'deprecated'),
params,
returns: sig?.type
? new DocumentedVarType(
{ names: [parseType(sig.type)], description: sig.comment?.returns?.trim() },
this.config,
).serialize()
: undefined,
returnsDescription: sig?.comment?.returns?.trim(),
};
}
}
return baseReturn;
}
const data = this.data as Typedef;
return {
name: data.name,
description: data.description,
see: data.see,
access: data.access,
deprecated: data.deprecated,
type: new DocumentedVarType(data.type, this.config).serialize(),
props: data.properties?.length
? data.properties.map((p) => new DocumentedParam(p, this.config).serialize())
: undefined,
params: data.params?.length ? data.params.map((p) => new DocumentedParam(p, this.config).serialize()) : undefined,
returns: data.returns?.length
? data.returns.map((p) => new DocumentedVarType(p, this.config).serialize())
: undefined,
meta: new DocumentedItemMeta(data.meta, this.config).serialize(),
};
}
}

View File

@@ -1,47 +1,36 @@
import { DocumentedItem } from './item.js';
import type { VarType } from '../interfaces/index.js';
import { parseType } from '../util/parseType.js';
import { splitVarName } from '../util/splitVarName.js';
export class DocumentedVarType extends DocumentedItem<VarType> {
public override serializer() {
const names = this.data.names?.map((name) => this.splitVarName(name));
if (this.config.typescript) {
const data = this.data;
const names = data.names?.map((name) => splitVarName(parseType(name)));
if (!this.data.description && !this.data.nullable) {
if (!data.description && !data.nullable) {
return names;
}
return {
types: names,
description: this.data.description,
nullable: this.data.nullable,
description: data.description,
nullable: data.nullable,
};
}
private splitVarName(str: string) {
const res: string[][] = [];
let currGroup: string[] = [];
let currStr = '';
const data = this.data;
const names = data.names?.map((name) => splitVarName(name));
const isASymbol = (char: string) => '-!$%^&*()_+|~=`{}[]:;<>?, '.includes(char);
for (const char of str) {
const currentlyInASymbolSection = isASymbol(currStr[0]!);
const charIsASymbol = isASymbol(char);
if (currStr.length && currentlyInASymbolSection !== charIsASymbol) {
currGroup.push(currStr);
currStr = char;
if (!charIsASymbol) {
res.push(currGroup);
currGroup = [];
if (!data.description && !data.nullable) {
return names;
}
} else {
currStr += char;
}
}
currGroup.push(currStr);
res.push(currGroup);
return res;
return {
types: names,
description: data.description,
nullable: data.nullable,
};
}
}

View File

@@ -0,0 +1,112 @@
import type { JSONOutput } from 'typedoc';
import {
isArrayType,
isConditionalType,
isIndexedAccessType,
isIntersectionType,
isPredicateType,
isReferenceType,
isReflectionType,
isLiteralType,
isTupleType,
isTypeOperatorType,
isUnionType,
isQueryType,
isInferredType,
isIntrinsicType,
isUnknownType,
} from './types';
export function parseType(t: JSONOutput.SomeType | JSONOutput.Type | string): string {
if (typeof t === 'string') {
return t;
}
if (isArrayType(t)) {
return `Array<${parseType(t.elementType)}>`;
}
if (isConditionalType(t)) {
const { checkType, extendsType, trueType, falseType } = t;
return `${parseType(checkType)} extends ${parseType(extendsType)} ? ${parseType(trueType)} : ${parseType(
falseType,
)}`;
}
if (isIndexedAccessType(t)) {
return `${parseType(t.objectType)}[${parseType(t.indexType)}]`;
}
if (isIntersectionType(t)) {
return t.types.map(parseType).join(' & ');
}
if (isPredicateType(t)) {
return (t.asserts ? 'asserts ' : '') + t.name + (t.targetType ? ` is ${parseType(t.targetType)}` : '');
}
if (isReferenceType(t)) {
return t.name + (t.typeArguments ? `<${t.typeArguments.map(parseType).join(', ')}>` : '');
}
if (isReflectionType(t)) {
const obj: Record<string, any> = {};
const { children, signatures } = t.declaration!;
// This is run when we're parsing interface-like declaration
if (children && children.length > 0) {
for (const child of children) {
const { type } = child;
if (type) {
obj[child.name] = parseType(type);
}
}
return `{\n${Object.entries(obj)
.map(([key, value]) => `${key}: ${value as string}`)
.join(',\n')}\n}`;
}
// This is run if we're parsing a function type
if (signatures && signatures.length > 0) {
const s = signatures[0];
const params = s?.parameters?.map((p) => `${p.name}: ${p.type ? parseType(p.type) : 'unknown'}`);
return `(${params?.join(', ') ?? '...args: unknown[]'}) => ${s?.type ? parseType(s.type) : 'unknown'}`;
}
return '{}';
}
if (isLiteralType(t)) {
if (typeof t.value == 'string') {
return `'${t.value}'`;
}
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
return `${t.value}`;
}
if (isTupleType(t)) {
return `[${(t.elements ?? []).map(parseType).join(', ')}]`;
}
if (isTypeOperatorType(t)) {
return `${t.operator} ${parseType(t.target)}`;
}
if (isUnionType(t)) {
return t.types
.map(parseType)
.filter((s) => Boolean(s) && s.trim().length > 0)
.join(' | ');
}
if (isQueryType(t)) {
return `(typeof ${parseType(t.queryType)})`;
}
if (isInferredType(t) || isIntrinsicType(t) || isUnknownType(t)) {
return t.name;
}
return 'unknown';
}

View File

@@ -0,0 +1,28 @@
export function splitVarName(str: string) {
const res: string[][] = [];
let currGroup: string[] = [];
let currStr = '';
const isASymbol = (char: string) => '-!$%^&*()_+|~=`{}[]:;<>?, '.includes(char);
for (const char of str) {
const currentlyInASymbolSection = isASymbol(currStr[0]!);
const charIsASymbol = isASymbol(char);
if (currStr.length && currentlyInASymbolSection !== charIsASymbol) {
currGroup.push(currStr);
currStr = char;
if (!charIsASymbol) {
res.push(currGroup);
currGroup = [];
}
} else {
currStr += char;
}
}
currGroup.push(currStr);
res.push(currGroup);
return res;
}

View File

@@ -0,0 +1,67 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import type { JSONOutput } from 'typedoc';
interface QueryType {
type: 'query';
queryType: JSONOutput.SomeType;
}
export function isArrayType(value: any): value is JSONOutput.ArrayType {
return typeof value == 'object' && value.type === 'array';
}
export function isConditionalType(value: any): value is JSONOutput.ConditionalType {
return typeof value == 'object' && value.type === 'conditional';
}
export function isIndexedAccessType(value: any): value is JSONOutput.IndexedAccessType {
return typeof value == 'object' && value.type === 'indexedAccess';
}
export function isInferredType(value: any): value is JSONOutput.InferredType {
return typeof value == 'object' && value.type === 'inferred';
}
export function isIntersectionType(value: any): value is JSONOutput.IntersectionType {
return typeof value == 'object' && value.type === 'intersection';
}
export function isIntrinsicType(value: any): value is JSONOutput.IntrinsicType {
return typeof value == 'object' && value.type === 'intrinsic';
}
export function isPredicateType(value: any): value is JSONOutput.PredicateType {
return typeof value == 'object' && value.type === 'predicate';
}
export function isReferenceType(value: any): value is JSONOutput.ReferenceType {
return typeof value == 'object' && value.type === 'reference';
}
export function isReflectionType(value: any): value is JSONOutput.ReflectionType {
return typeof value == 'object' && value.type === 'reflection';
}
export function isLiteralType(value: any): value is JSONOutput.LiteralType {
return typeof value == 'object' && value.type === 'literal';
}
export function isTupleType(value: any): value is JSONOutput.TupleType {
return typeof value == 'object' && value.type === 'tuple';
}
export function isTypeOperatorType(value: any): value is JSONOutput.TypeOperatorType {
return typeof value == 'object' && value.type === 'typeOperator';
}
export function isUnionType(value: any): value is JSONOutput.UnionType {
return typeof value == 'object' && value.type === 'union';
}
export function isUnknownType(value: any): value is JSONOutput.UnknownType {
return typeof value == 'object' && value.type === 'unknown';
}
export function isQueryType(value: any): value is QueryType {
return typeof value == 'object' && value.type === 'query';
}

View File

@@ -18,7 +18,7 @@ pids
dist/
typings/
docs/**/*
!docs/index.yml
!docs/index.json
!docs/README.md
# Miscellaneous

View File

@@ -0,0 +1 @@
[{ "name": "General", "files": [{ "name": "Welcome", "id": "welcome", "path": "../../README.md" }] }]

View File

@@ -1,5 +0,0 @@
- name: General
files:
- name: Welcome
id: welcome
path: ../../README.md

View File

@@ -6,7 +6,7 @@
"build": "tsup && tsc --emitDeclarationOnly --incremental",
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && ts-docgen -i docs/typedoc-out.json -c docs/index.yml -o docs/docs.json",
"docs": "docgen -i src/index.ts -c docs/index.json -o docs/docs.json --typescript",
"prepublishOnly": "yarn build && yarn lint && yarn test",
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/proxy/*'",
"release": "cliff-jumper"
@@ -57,6 +57,7 @@
"undici": "^5.4.0"
},
"devDependencies": {
"@discordjs/docgen": "workspace:^",
"@discordjs/scripts": "workspace:^",
"@favware/cliff-jumper": "^1.8.3",
"@types/node": "^16.11.38",
@@ -70,7 +71,6 @@
"prettier": "^2.6.2",
"supertest": "^6.2.3",
"tsup": "^6.1.0",
"typedoc": "^0.22.17",
"typescript": "^4.7.3"
},
"engines": {

View File

@@ -18,7 +18,7 @@ pids
dist/
typings/
docs/**/*
!docs/index.yml
!docs/index.json
!docs/README.md
# Miscellaneous

View File

@@ -0,0 +1 @@
[{ "name": "General", "files": [{ "name": "Welcome", "id": "welcome", "path": "../../README.md" }] }]

View File

@@ -1,5 +0,0 @@
- name: General
files:
- name: Welcome
id: welcome
path: ../../README.md

View File

@@ -6,7 +6,7 @@
"build": "tsup && tsc --emitDeclarationOnly --incremental",
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && ts-docgen -i docs/typedoc-out.json -c docs/index.yml -o docs/docs.json",
"docs": "docgen -i src/index.ts -c docs/index.json -o docs/docs.json --typescript",
"prepublishOnly": "yarn build && yarn lint && yarn test",
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/rest/*'",
"release": "cliff-jumper"
@@ -58,6 +58,7 @@
"undici": "^5.4.0"
},
"devDependencies": {
"@discordjs/docgen": "workspace:^",
"@discordjs/scripts": "workspace:^",
"@favware/cliff-jumper": "^1.8.3",
"@typescript-eslint/eslint-plugin": "^5.27.1",
@@ -68,7 +69,6 @@
"eslint-plugin-import": "^2.26.0",
"prettier": "^2.6.2",
"tsup": "^6.1.0",
"typedoc": "^0.22.17",
"typescript": "^4.7.3"
},
"engines": {

View File

@@ -8,9 +8,6 @@
"lint": "prettier --check . && eslint src --ext mjs,js,ts",
"format": "prettier --write . && eslint src --ext mjs,js,ts --fix"
},
"bin": {
"ts-docgen": "./dist/docs.js"
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
@@ -45,7 +42,6 @@
},
"homepage": "https://discord.js.org",
"dependencies": {
"@discordjs/ts-docgen": "^0.4.1",
"commander": "^9.3.0",
"tslib": "^2.4.0"
},

View File

@@ -1,25 +0,0 @@
#!/usr/bin/env node
import { runGenerator } from '@discordjs/ts-docgen';
import { createCommand } from 'commander';
import packageFile from '../package.json';
interface CLIOptions {
input: string;
custom: string;
output: string;
}
const command = createCommand()
.version(packageFile.version)
.option('-i, --input <string>', 'Path to an existing TypeDoc JSON output file')
.option('-c, --custom <string>', 'Custom docs definition file to use')
.option('-o, --output <string>', 'Path to output file');
const program = command.parse(process.argv);
const options = program.opts<CLIOptions>();
runGenerator({
existingOutput: options.input,
custom: options.custom,
output: options.output,
});

View File

@@ -0,0 +1 @@
export {};

View File

@@ -1,6 +1,5 @@
import { createTsupConfig } from '../../tsup.config';
export default createTsupConfig({
entry: ['src/docs.ts'],
minify: true,
});

View File

@@ -14,8 +14,9 @@ pids
# Dist
dist/
typings/
docs/**/*
!docs/index.yml
!docs/index.json
!docs/README.md
# Miscellaneous

View File

@@ -0,0 +1 @@
[{ "name": "General", "files": [{ "name": "Welcome", "id": "welcome", "path": "../../README.md" }] }]

View File

@@ -1,5 +0,0 @@
- name: General
files:
- name: Welcome
id: welcome
path: ../../README.md

View File

@@ -7,7 +7,7 @@
"test": "jest --pass-with-no-tests --collect-coverage",
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && ts-docgen -i docs/typedoc-out.json -c docs/index.yml -o docs/docs.json",
"docs": "docgen -i src/index.ts -c docs/index.json -o docs/docs.json --typescript",
"prepublishOnly": "yarn build && yarn lint && yarn test",
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/voice/*'",
"release": "cliff-jumper"
@@ -62,6 +62,7 @@
"@babel/core": "^7.18.2",
"@babel/preset-env": "^7.18.2",
"@babel/preset-typescript": "^7.17.12",
"@discordjs/docgen": "workspace:^",
"@discordjs/scripts": "workspace:^",
"@favware/cliff-jumper": "^1.8.3",
"@types/jest": "^28.1.1",
@@ -78,7 +79,6 @@
"prettier": "^2.6.2",
"tsup": "^6.1.0",
"tweetnacl": "^1.0.3",
"typedoc": "^0.22.17",
"typescript": "^4.7.3"
},
"engines": {

View File

@@ -1608,6 +1608,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@discordjs/builders@workspace:packages/builders"
dependencies:
"@discordjs/docgen": "workspace:^"
"@discordjs/scripts": "workspace:^"
"@favware/cliff-jumper": ^1.8.3
"@sapphire/shapeshift": ^3.1.0
@@ -1625,15 +1626,22 @@ __metadata:
ts-mixer: ^6.0.1
tslib: ^2.4.0
tsup: ^6.1.0
typedoc: ^0.22.17
typescript: ^4.7.3
languageName: unknown
linkType: soft
"@discordjs/collection@npm:^0.7.0":
version: 0.7.0
resolution: "@discordjs/collection@npm:0.7.0"
checksum: 141aa35a5433bacba3617b533557b4948388c7b59cdaecee51ccd721c1b9242e50d95bdef53ee2491535a017095f5072ace3c3e9e594193f67a1c5a8a4b7db93
languageName: node
linkType: hard
"@discordjs/collection@workspace:^, @discordjs/collection@workspace:packages/collection":
version: 0.0.0-use.local
resolution: "@discordjs/collection@workspace:packages/collection"
dependencies:
"@discordjs/docgen": "workspace:^"
"@discordjs/scripts": "workspace:^"
"@favware/cliff-jumper": ^1.8.3
"@types/node": ^16.11.38
@@ -1645,7 +1653,6 @@ __metadata:
eslint-plugin-import: ^2.26.0
prettier: ^2.6.2
tsup: ^6.1.0
typedoc: ^0.22.17
typescript: ^4.7.3
languageName: unknown
linkType: soft
@@ -1671,7 +1678,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@discordjs/docgen@workspace:packages/docgen"
dependencies:
"@discordjs/collection": "workspace:^"
"@discordjs/collection": ^0.7.0
"@favware/cliff-jumper": ^1.8.3
"@types/jsdoc-to-markdown": ^7.0.3
"@types/node": ^16.11.38
@@ -1686,6 +1693,7 @@ __metadata:
prettier: ^2.6.2
tslib: ^2.4.0
tsup: ^6.1.0
typedoc: ^0.22.17
typescript: ^4.7.3
bin:
docgen: ./dist/index.js
@@ -1696,6 +1704,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@discordjs/proxy@workspace:packages/proxy"
dependencies:
"@discordjs/docgen": "workspace:^"
"@discordjs/rest": "workspace:^"
"@discordjs/scripts": "workspace:^"
"@favware/cliff-jumper": ^1.8.3
@@ -1711,7 +1720,6 @@ __metadata:
supertest: ^6.2.3
tslib: ^2.4.0
tsup: ^6.1.0
typedoc: ^0.22.17
typescript: ^4.7.3
undici: ^5.4.0
languageName: unknown
@@ -1722,6 +1730,7 @@ __metadata:
resolution: "@discordjs/rest@workspace:packages/rest"
dependencies:
"@discordjs/collection": "workspace:^"
"@discordjs/docgen": "workspace:^"
"@discordjs/scripts": "workspace:^"
"@favware/cliff-jumper": ^1.8.3
"@sapphire/async-queue": ^1.3.1
@@ -1736,7 +1745,6 @@ __metadata:
prettier: ^2.6.2
tslib: ^2.4.0
tsup: ^6.1.0
typedoc: ^0.22.17
typescript: ^4.7.3
undici: ^5.4.0
languageName: unknown
@@ -1746,7 +1754,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "@discordjs/scripts@workspace:packages/scripts"
dependencies:
"@discordjs/ts-docgen": ^0.4.1
"@types/node": ^16.11.38
"@typescript-eslint/eslint-plugin": ^5.27.1
"@typescript-eslint/parser": ^5.27.1
@@ -1759,21 +1766,9 @@ __metadata:
tslib: ^2.4.0
tsup: ^6.1.0
typescript: ^4.7.3
bin:
ts-docgen: ./dist/docs.js
languageName: unknown
linkType: soft
"@discordjs/ts-docgen@npm:^0.4.1":
version: 0.4.1
resolution: "@discordjs/ts-docgen@npm:0.4.1"
dependencies:
js-yaml: ^4.1.0
typedoc: ^0.22.15
checksum: fbb8c7041812ae0130043451501b73d732a05afaec01136f3c877dae08d7fe9bb913c9763b60010b28bbc50c0043354ae01f5bc2626e1a24a767cb337a29a9a9
languageName: node
linkType: hard
"@discordjs/voice@workspace:packages/voice":
version: 0.0.0-use.local
resolution: "@discordjs/voice@workspace:packages/voice"
@@ -1781,6 +1776,7 @@ __metadata:
"@babel/core": ^7.18.2
"@babel/preset-env": ^7.18.2
"@babel/preset-typescript": ^7.17.12
"@discordjs/docgen": "workspace:^"
"@discordjs/scripts": "workspace:^"
"@favware/cliff-jumper": ^1.8.3
"@types/jest": ^28.1.1
@@ -1802,7 +1798,6 @@ __metadata:
tslib: ^2.4.0
tsup: ^6.1.0
tweetnacl: ^1.0.3
typedoc: ^0.22.17
typescript: ^4.7.3
ws: ^8.7.0
languageName: unknown
@@ -6027,7 +6022,7 @@ dts-critic@latest:
languageName: node
linkType: hard
"glob@npm:^7.1.1, glob@npm:^7.1.3, glob@npm:^7.1.4, glob@npm:^7.2.0":
"glob@npm:^7.1.1, glob@npm:^7.1.3, glob@npm:^7.1.4":
version: 7.2.0
resolution: "glob@npm:7.2.0"
dependencies:
@@ -10609,23 +10604,6 @@ dts-critic@latest:
languageName: node
linkType: hard
"typedoc@npm:^0.22.15":
version: 0.22.15
resolution: "typedoc@npm:0.22.15"
dependencies:
glob: ^7.2.0
lunr: ^2.3.9
marked: ^4.0.12
minimatch: ^5.0.1
shiki: ^0.10.1
peerDependencies:
typescript: 4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x || 4.6.x
bin:
typedoc: bin/typedoc
checksum: 3f5f1cb9288bf811f42df59750c7062a026a23257b38dfe227515a30007a28e3d8139187949fcd19300fd6b2ef76bcdc4cf54549100bff3e000e61bb19958fb2
languageName: node
linkType: hard
"typedoc@npm:^0.22.17":
version: 0.22.17
resolution: "typedoc@npm:0.22.17"