aboutsummaryrefslogtreecommitdiff
path: root/scripts/apidoc.ts
blob: 921859e7a779dd929a8576ec3be2aec65514f32e (plain)
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
import { resolve } from 'path';
import {
  writeApiPagesIndex,
  writeApiSearchIndex,
} from './apidoc/apiDocsWriter';
import { processModuleMethods } from './apidoc/moduleMethods';
import { initMarkdownRenderer } from './apidoc/signature';
import type { PageIndex } from './apidoc/utils';
import { newTypeDocApp, patchProject, pathOutputDir } from './apidoc/utils';

const pathOutputJson = resolve(pathOutputDir, 'typedoc.json');

async function build(): Promise<void> {
  await initMarkdownRenderer();

  const app = newTypeDocApp();

  app.bootstrap({
    entryPoints: ['src/index.ts'],
    pretty: true,
    cleanOutputDir: true,
  });

  const project = app.convert();

  if (!project) {
    throw new Error('Failed to convert project');
  }

  // Useful for manually analyzing the content
  await app.generateJson(project, pathOutputJson);

  patchProject(project);

  const modulesPages: PageIndex = [];
  modulesPages.push(...processModuleMethods(project));
  writeApiPagesIndex(modulesPages);

  writeApiSearchIndex(project);
}

build().catch(console.error);