Skip to content

Commit a3a1b33

Browse files
committed
docs: update api generation
1 parent fe1fbf8 commit a3a1b33

File tree

4 files changed

+45
-52
lines changed

4 files changed

+45
-52
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
"p-series": "^3.0.0",
3535
"prettier": "^2.8.8",
3636
"semver": "^7.5.4",
37-
"typedoc": "^0.24.8",
38-
"typedoc-plugin-markdown": "^3.15.4",
37+
"typedoc": "^0.25.3",
38+
"typedoc-plugin-markdown": "^3.17.1",
3939
"typescript": "~5.1.6",
4040
"yorkie": "^2.0.0"
4141
},
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
const { createTypeDocApp } = require('./typedoc-markdown')
2-
const path = require('path')
1+
import path from 'node:path'
2+
import { createTypeDocApp } from './typedoc-markdown.mjs'
3+
4+
const __dirname = path.dirname(new URL(import.meta.url).pathname)
35

46
createTypeDocApp({
57
name: 'API Documentation',
68
tsconfig: path.resolve(__dirname, './typedoc.tsconfig.json'),
79
// entryPointStrategy: 'packages',
10+
categorizeByGroup: true,
811
githubPages: false,
9-
plugin: ['typedoc-plugin-markdown'],
1012
disableSources: true,
13+
plugin: ['typedoc-plugin-markdown'],
1114
entryPoints: [path.resolve(__dirname, '../router/src/index.ts')],
12-
}).build()
15+
}).then(app => app.build())

packages/docs/typedoc-markdown.js renamed to packages/docs/typedoc-markdown.mjs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const _fs = require('fs')
2-
const path = require('path')
3-
const TypeDoc = require('typedoc')
4-
const { PageEvent } = TypeDoc
1+
// @ts-check
2+
import fs from 'node:fs/promises'
3+
import path from 'node:path'
4+
import { Application, TSConfigReader, PageEvent } from 'typedoc'
55

6-
const fs = _fs.promises
6+
const __dirname = path.dirname(new URL(import.meta.url).pathname)
77

88
const DEFAULT_OPTIONS = {
99
// disableOutputCheck: true,
@@ -12,33 +12,36 @@ const DEFAULT_OPTIONS = {
1212
readme: 'none',
1313
out: path.resolve(__dirname, './api'),
1414
entryDocument: 'index.md',
15-
preserveAnchorCasing: true,
1615
hideBreadcrumbs: false,
1716
hideInPageTOC: true,
17+
preserveAnchorCasing: true,
1818
}
1919

2020
/**
2121
*
2222
* @param {Partial<import('typedoc').TypeDocOptions>} config
2323
*/
24-
exports.createTypeDocApp = function createTypeDocApp(config = {}) {
24+
export async function createTypeDocApp(config = {}) {
2525
const options = {
2626
...DEFAULT_OPTIONS,
2727
...config,
2828
}
2929

30-
const app = new TypeDoc.Application()
30+
const app = await Application.bootstrapWithPlugins(options)
3131

3232
// If you want TypeDoc to load tsconfig.json / typedoc.json files
33-
app.options.addReader(new TypeDoc.TSConfigReader())
33+
app.options.addReader(new TSConfigReader())
3434

3535
app.renderer.on(
3636
PageEvent.END,
3737
/**
3838
*
39-
* @param {import('typedoc/dist/lib/output/events').PageEvent} page
39+
* @param {import('typedoc').PageEvent} page
4040
*/
4141
page => {
42+
if (!page.contents) {
43+
return
44+
}
4245
page.contents = prependYAML(page.contents, {
4346
// TODO: figure out a way to point to the source files?
4447
editLink: false,
@@ -47,7 +50,6 @@ exports.createTypeDocApp = function createTypeDocApp(config = {}) {
4750
)
4851

4952
async function serve() {
50-
await app.bootstrapWithPlugins(options)
5153
app.convertAndWatch(handleProject)
5254
}
5355

@@ -58,14 +60,13 @@ exports.createTypeDocApp = function createTypeDocApp(config = {}) {
5860
) {
5961
await fs.rm(options.out, { recursive: true })
6062
}
61-
await app.bootstrapWithPlugins(options)
62-
const project = app.convert()
63+
const project = await app.convert()
6364
return handleProject(project)
6465
}
6566

6667
/**
6768
*
68-
* @param {import('typedoc').ProjectReflection} project
69+
* @param {import('typedoc').ProjectReflection | undefined} project
6970
*/
7071
async function handleProject(project) {
7172
if (project) {
@@ -84,13 +85,6 @@ exports.createTypeDocApp = function createTypeDocApp(config = {}) {
8485
return {
8586
build,
8687
serve,
87-
/**
88-
*
89-
* @param {'build' | 'serve'} command
90-
*/
91-
setTargetMode(command) {
92-
targetMode = command
93-
},
9488
}
9589
}
9690

@@ -102,6 +96,7 @@ async function exists(path) {
10296
return false
10397
}
10498
}
99+
105100
/**
106101
* @typedef {Record<string, string | number | boolean>} FrontMatterVars
107102
*/

pnpm-lock.yaml

Lines changed: 20 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)