diff --git a/.eslintrc.json b/.eslintrc.json index 48411c0..8243e36 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,6 @@ { - "extends": "@uwu-codes/eslint-config/esm" + "extends": "@uwu-codes/eslint-config/esm", + "rules": { + "unicorn/switch-case-braces": "off" + } } diff --git a/package.json b/package.json index 20eaa5a..d6f3f2e 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "morgan": "^1.10.0", "oceanic.js": "1.8.1-dev.08d3811", "semver": "^7.5.1", - "typedoc": "^0.23.28" + "typedoc": "^0.24.8" }, "devDependencies": { "@swc/core": "^1.3.60", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ebe1993..657410c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -42,8 +42,8 @@ dependencies: specifier: ^7.5.1 version: 7.5.1 typedoc: - specifier: ^0.23.28 - version: 0.23.28(typescript@5.0.4) + specifier: ^0.24.8 + version: 0.24.8(typescript@5.0.4) devDependencies: '@swc/core': @@ -2307,9 +2307,9 @@ packages: brace-expansion: 1.1.11 dev: true - /minimatch@7.4.6: - resolution: {integrity: sha512-sBz8G/YjVniEz6lKPNpKxXwazJe4c19fEfV2GDMX6AjFz+MX9uDWIZW8XreVhkFW3fkIdTv/gxWr/Kks5FFAVw==} - engines: {node: '>=10'} + /minimatch@9.0.3: + resolution: {integrity: sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==} + engines: {node: '>=16 || 14 >=14.17'} dependencies: brace-expansion: 2.0.1 dev: false @@ -3058,16 +3058,16 @@ packages: is-typed-array: 1.1.10 dev: true - /typedoc@0.23.28(typescript@5.0.4): - resolution: {integrity: sha512-9x1+hZWTHEQcGoP7qFmlo4unUoVJLB0H/8vfO/7wqTnZxg4kPuji9y3uRzEu0ZKez63OJAUmiGhUrtukC6Uj3w==} + /typedoc@0.24.8(typescript@5.0.4): + resolution: {integrity: sha512-ahJ6Cpcvxwaxfu4KtjA8qZNqS43wYt6JL27wYiIgl1vd38WW/KWX11YuAeZhuz9v+ttrutSsgK+XO1CjL1kA3w==} engines: {node: '>= 14.14'} hasBin: true peerDependencies: - typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x + typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x dependencies: lunr: 2.3.9 marked: 4.3.0 - minimatch: 7.4.6 + minimatch: 9.0.3 shiki: 0.14.1 typescript: 5.0.4 dev: false diff --git a/src/docs/convertType.ts b/src/docs/convertType.ts index 9e2bae3..8118789 100644 --- a/src/docs/convertType.ts +++ b/src/docs/convertType.ts @@ -6,7 +6,7 @@ function resolveArrayType(type: JSONOutput.ArrayType, level = 1): { level: numbe export default function convertType(type: JSONOutput.SomeType): string { if ("name" in type && type.name === "default" && "id" in type && type.id !== undefined) { - type.name = getName(type.id); + type.name = getName((type as {id: number; }).id); } switch (type.type) { case "array": { @@ -51,7 +51,7 @@ export default function convertType(type: JSONOutput.SomeType): string { return `{ [${readonlyModifier ? "readonly " : ""}${nameType ? `${convertType(nameType)} in ` : ""}${parameter}${optionalModifier ? "?" : ""}: ${convertType(parameterType)}]${templateType ? ` extends ${convertType(templateType)}` : ""} }`; } - case "named-tuple-member": { + case "namedTupleMember": { const { name, isOptional, element } = type; return `${name}${isOptional ? "?" : ""}: ${convertType(element)}`; } @@ -77,6 +77,9 @@ export default function convertType(type: JSONOutput.SomeType): string { } case "reference": { + if ("name" in type && type.name === "default" && "target" in type && type.target !== undefined) { + type.name = typeof type.target === "object" ? type.target.qualifiedName : getName(type.target); + } const { name, typeArguments } = type; return `${name}${typeArguments ? `<${typeArguments.map(convertType).join(", ")}>` : ""}`; } @@ -110,7 +113,7 @@ export default function convertType(type: JSONOutput.SomeType): string { return `...${convertType(type.elementType)}`; } - case "template-literal": { + case "templateLiteral": { const { head, tail } = type; return `\`${head}${tail.map(([t, literal]) => `\${${convertType(t)}}${literal}`).join("")}\``; } @@ -133,6 +136,7 @@ export default function convertType(type: JSONOutput.SomeType): string { } default: { + console.log(`TODO Type: ${(type as { type: string; }).type}`); return `TODO: ${(type as { type: string; }).type}`; } } diff --git a/src/docs/idToName.ts b/src/docs/idToName.ts index e15142d..ca42d0e 100644 --- a/src/docs/idToName.ts +++ b/src/docs/idToName.ts @@ -7,6 +7,7 @@ export function getMap() { export function getName(id: number) { if (!nameMap.has(id)) { console.log(`Missing name for ${id}`); + console.debug(new TypeError(`Missing name for ${id}`).stack); } return nameMap.get(id) ?? `default[${id}]`; } diff --git a/src/docs/process/accessor.ts b/src/docs/process/accessor.ts index 7f0b537..3aeb422 100644 --- a/src/docs/process/accessor.ts +++ b/src/docs/process/accessor.ts @@ -7,7 +7,7 @@ export default function processAccessor(data: JSONOutput.DeclarationReflection) return; } if (data.getSignature.type && "name" in data.getSignature.type && data.getSignature.type.name === "default" && "id" in data.getSignature.type && data.getSignature.type.id !== undefined) { - data.getSignature.type.name = getName(data.getSignature.type.id); + data.getSignature.type.name = getName((data.getSignature.type as { id: number; }).id); } return { comment: data.getSignature.comment?.summary.reduce((a, b) => a + b.text, ""), diff --git a/src/docs/process/constructor.ts b/src/docs/process/constructor.ts index 73988cb..77b229e 100644 --- a/src/docs/process/constructor.ts +++ b/src/docs/process/constructor.ts @@ -16,7 +16,7 @@ export default function processConstructor(data: JSONOutput.DeclarationReflectio continue; } if (param.type && "name" in param.type && param.type.name === "default" && "id" in param.type && param.type.id !== undefined) { - param.type.name = getName(param.type.id); + param.type.name = getName((param.type as { id: number; }).id); } construct.parameters.push({ name: param.name, diff --git a/src/docs/process/function.ts b/src/docs/process/function.ts index 0f1aa34..85500af 100644 --- a/src/docs/process/function.ts +++ b/src/docs/process/function.ts @@ -21,7 +21,7 @@ export default function processFunction(data: JSONOutput.DeclarationReflection, continue; } if (param.type && "name" in param.type && param.type.name === "default" && "id" in param.type && param.type.id !== undefined) { - param.type.name = getName(param.type.id); + param.type.name = getName((param.type as { id: number; }).id); } func.parameters.push({ name: param.name, diff --git a/src/docs/process/method.ts b/src/docs/process/method.ts index ec1d270..c5fa464 100644 --- a/src/docs/process/method.ts +++ b/src/docs/process/method.ts @@ -29,7 +29,7 @@ export default function processMethod(data: JSONOutput.DeclarationReflection) { continue; } if (param.type && "name" in param.type && param.type.name === "default" && "id" in param.type && param.type.id !== undefined) { - param.type.name = getName(param.type.id); + param.type.name = getName((param.type as { id: number; }).id); } overload.parameters.push({ name: param.name, diff --git a/src/docs/process/property.ts b/src/docs/process/property.ts index e59bbcc..e1378be 100644 --- a/src/docs/process/property.ts +++ b/src/docs/process/property.ts @@ -8,7 +8,7 @@ export default function processProperty(data: JSONOutput.DeclarationReflection) return; } if (data.type && "name" in data.type && data.type.name === "default" && "id" in data.type && data.type.id !== undefined) { - data.type.name = getName(data.type.id); + data.type.name = getName((data.type as { id: number; }).id); } const prop: Property = { comment: data.comment?.summary.reduce((a, b) => a + b.text, ""), diff --git a/src/docs/run.ts b/src/docs/run.ts index 1a6b502..52bcd6a 100644 --- a/src/docs/run.ts +++ b/src/docs/run.ts @@ -28,8 +28,26 @@ export default async function run(data: JSONOutput.ProjectReflection, version: s if (data.children) { for (const child of data.children) { if (child.kind !== ReflectionKind.Module) { - throw new Error(`Expected ${ReflectionKind[ReflectionKind.Module]} (${ReflectionKind.Module}), got ${ReflectionKind[child.kind]} (${child.kind}) for ${child.name} (${child.id})`); + switch (child.kind) { + case ReflectionKind.Class: { + const clazz = processClass(child, child.name); + root.classes.push(clazz); + break; + } + + case ReflectionKind.Interface: { + const iface = processInterface(child, child.name); + root.interfaces.push(iface); + break; + } + + default: { + throw new Error(`Unexpected kind ${ReflectionKind[child.kind]} (${child.kind}) for ${child.name} (${child.id})`); + } + } + continue; } + if (!child.children) { continue; } @@ -79,11 +97,16 @@ export default async function run(data: JSONOutput.ProjectReflection, version: s } case ReflectionKind.Reference: { + if (child2.variant !== "reference") { + console.debug(`Skipping ${child2.variant} ${ReflectionKind[child2.kind]} (${child2.kind}) for ${child2.name} (${child2.id})`); + continue; + } const ref = processReference(child2 as JSONOutput.ReferenceReflection); root.references.push(ref); break; } + // I can't be bothered to handle this right now case ReflectionKind.Namespace: { console.debug(`Skipping namespace ${child2.name} (${child2.id})`); diff --git a/src/docs/saveNames.ts b/src/docs/saveNames.ts index 8786b87..fbfc387 100644 --- a/src/docs/saveNames.ts +++ b/src/docs/saveNames.ts @@ -4,7 +4,7 @@ import { type JSONOutput, ReflectionKind } from "typedoc"; export default function saveNames(project: JSONOutput.ProjectReflection) { if (project.children) { for (const child of project.children) { - if (child.kind !== ReflectionKind.Module) { + if (![ReflectionKind.Module, ReflectionKind.Class, ReflectionKind.Interface].includes(child.kind)) { throw new Error(`Expected ${ReflectionKind[ReflectionKind.Module]} (${ReflectionKind.Module}), got ${ReflectionKind[child.kind]} (${child.kind}) for ${child.name} (${child.id})`); } setName(child.id, child.name); diff --git a/src/util/util.ts b/src/util/util.ts index ce428e5..fc7463a 100644 --- a/src/util/util.ts +++ b/src/util/util.ts @@ -19,6 +19,10 @@ export interface IConfig { }; cookieSecret: string; dataDir: string; + degenerateWebhook: { + id: string; + token: string; + }; docsWebhook: { id: string; token: string;