-
Notifications
You must be signed in to change notification settings - Fork 0
/
externalConfig.js
43 lines (39 loc) · 1.41 KB
/
externalConfig.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { readdirSync } from 'fs';
import path from 'path';
import { ReflectionKind } from 'typedoc';
/** @param {import('typedoc').Application} app */
async function load(app) {
const dir = readdirSync('node_modules/eludris-api-types/dist');
const response = await fetch(
`https://next-eludris-api-types.vercel.app/api.json`,
);
/** @type {import('typedoc').JSONOutput.ContainerReflection} */
const inventory = await response.json();
const latest = inventory.children
.map((child) => child.name)
.sort()
.at(-1);
app.converter.addUnknownSymbolResolver(
(declaration, reflection, part, symbolId) => {
console.log(declaration, reflection, part, symbolId);
let filePath = path
.basename(symbolId?.fileName ?? latest)
.replace('.d.ts', '');
const versionInventory = inventory.children.find(
(child) => child.name === filePath,
);
filePath = filePath.replace(/\.|-/g, '_');
if (declaration.moduleSource !== 'eludris-api-types') {
return;
}
const name = declaration.symbolReference.path[0].path;
const declarationType = versionInventory.children.find(
(child) => child.name === name,
);
const type = ReflectionKind[declarationType.kind].toLowerCase() + 's';
console.log(type);
return `https://next-eludris-api-types.vercel.app/${type}/${filePath}.${name}.html`;
},
);
}
export { load };