diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 795f27f307..8fc310fbd3 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1297,11 +1297,11 @@ importers: specifier: ~0.5.19 version: 0.5.19 typedoc: - specifier: ~0.24.8 - version: 0.24.8(typescript@5.1.3) + specifier: 0.25.1 + version: 0.25.1(typescript@5.1.3) typedoc-plugin-markdown: - specifier: ~4.0.0-next.18 - version: 4.0.0-next.18(typedoc@0.24.8) + specifier: 4.0.0-next.20 + version: 4.0.0-next.20(typedoc@0.25.1) typescript: specifier: ~5.1.3 version: 5.1.3 @@ -10196,7 +10196,7 @@ packages: dependencies: foreground-child: 3.1.1 jackspeak: 2.2.1 - minimatch: 9.0.1 + minimatch: 9.0.3 minipass: 6.0.2 path-scurry: 1.9.2 dev: true @@ -11665,8 +11665,8 @@ packages: dependencies: brace-expansion: 2.0.1 - /minimatch@9.0.1: - resolution: {integrity: sha512-0jWhJpD/MdhPXwPuiRkCbfYfSKp2qnn2eOc279qI7f+osl/l+prKSrvhg157zSYvx/1nmgn2NqdT6k2Z7zSH9w==} + /minimatch@9.0.3: + resolution: {integrity: sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==} engines: {node: '>=16 || 14 >=14.17'} dependencies: brace-expansion: 2.0.1 @@ -14847,24 +14847,24 @@ packages: is-typedarray: 1.0.0 dev: false - /typedoc-plugin-markdown@4.0.0-next.18(typedoc@0.24.8): - resolution: {integrity: sha512-Qf4tUrAsZLcJ1TzCJc5NWP+ulPsQh7v1cxNCeJqeIQovnbpMOkZPQogEhZBUvMjHxABS64EQ9PkpDFJuE0IpGw==} + /typedoc-plugin-markdown@4.0.0-next.20(typedoc@0.25.1): + resolution: {integrity: sha512-mQoLUSk6KLPMv1zpcTk43h8+8aD+T65qPh99/umSsczd1yTOyZiA0h0kAlsrZrAM8SWoJEn/fZWgV3JMR3Bb4Q==} peerDependencies: typedoc: '>=0.24.0' dependencies: - typedoc: 0.24.8(typescript@5.1.3) + typedoc: 0.25.1(typescript@5.1.3) dev: true - /typedoc@0.24.8(typescript@5.1.3): - resolution: {integrity: sha512-ahJ6Cpcvxwaxfu4KtjA8qZNqS43wYt6JL27wYiIgl1vd38WW/KWX11YuAeZhuz9v+ttrutSsgK+XO1CjL1kA3w==} - engines: {node: '>= 14.14'} + /typedoc@0.25.1(typescript@5.1.3): + resolution: {integrity: sha512-c2ye3YUtGIadxN2O6YwPEXgrZcvhlZ6HlhWZ8jQRNzwLPn2ylhdGqdR8HbyDRyALP8J6lmSANILCkkIdNPFxqA==} + engines: {node: '>= 16'} hasBin: true peerDependencies: - typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x + typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x dependencies: lunr: 2.3.9 marked: 4.3.0 - minimatch: 9.0.1 + minimatch: 9.0.3 shiki: 0.14.2 typescript: 5.1.3 dev: true diff --git a/packages/tspd/package.json b/packages/tspd/package.json index c0a5afb3b9..bf6730bd80 100644 --- a/packages/tspd/package.json +++ b/packages/tspd/package.json @@ -73,8 +73,8 @@ "mocha": "~10.2.0", "source-map-support": "~0.5.19", "rimraf": "~5.0.1", - "typedoc-plugin-markdown": "~4.0.0-next.18", - "typedoc": "~0.24.8", + "typedoc-plugin-markdown": "4.0.0-next.20", + "typedoc": "0.25.1", "typescript": "~5.1.3" } } diff --git a/packages/tspd/src/ref-doc/api-docs.ts b/packages/tspd/src/ref-doc/api-docs.ts index 8e33842052..48d0a5a0ba 100644 --- a/packages/tspd/src/ref-doc/api-docs.ts +++ b/packages/tspd/src/ref-doc/api-docs.ts @@ -4,11 +4,6 @@ import { Application, DeclarationReflection, PageEvent, ReflectionKind } from "t import { PluginOptions, load } from "typedoc-plugin-markdown"; import { stringify } from "yaml"; export async function generateJsApiDocs(libraryPath: string, outputDir: string) { - const app = new Application(); - - loadRenderer(app); - load(app); - const markdownPluginOptions: Partial = { entryFileName: "index.md", propertiesFormat: "table", @@ -25,17 +20,25 @@ export async function generateJsApiDocs(libraryPath: string, outputDir: string) identifiersAsCodeBlocks: true, }; - app.bootstrap({ + const app = await Application.bootstrapWithPlugins({ + entryPoints: [joinPaths(libraryPath, "src/index.ts")], + tsconfig: joinPaths(libraryPath, "tsconfig.json"), + entryPointStrategy: "resolve", + }); + + loadRenderer(app); + load(app); + + setOptions(app, { name: "JS Api", - entryPoints: [libraryPath], - entryPointStrategy: "legacy-packages", githubPages: false, readme: "none", hideGenerator: true, disableSources: true, ...markdownPluginOptions, }); - const project = app.convert(); + + const project = await app.convert(); // if project is undefined typedoc has a problem - error logging will be supplied by typedoc. if (!project) { @@ -56,6 +59,12 @@ export async function generateJsApiDocs(libraryPath: string, outputDir: string) ); } +function setOptions(app: Application, options: any, reportErrors = true) { + for (const [key, val] of Object.entries(options)) { + app.options.setValue(key as never, val as never); + } +} + export function loadRenderer(app: Application) { app.renderer.on(PageEvent.END, (page: PageEvent) => { if (page.contents) { diff --git a/packages/website/.scripts/regen-compiler-docs.mjs b/packages/website/.scripts/regen-compiler-docs.mjs index ca08edc45c..da47d068fd 100644 --- a/packages/website/.scripts/regen-compiler-docs.mjs +++ b/packages/website/.scripts/regen-compiler-docs.mjs @@ -1,6 +1,6 @@ #!/usr/bin/env node // @ts-check -import { NodeHost, logDiagnostics } from "@typespec/compiler"; +import { NodeHost, joinPaths, logDiagnostics } from "@typespec/compiler"; import { generateJsApiDocs, resolveLibraryRefDocsBase } from "@typespec/tspd/ref-doc"; import { DocusaurusRenderer, @@ -45,6 +45,6 @@ async function generateCompilerDocs() { assert(decoratorContent, "Unexpected decorator file shouldn't be empty for compiler."); await writeFile(join(outputDir, "built-in-decorators.md"), decoratorContent); - await generateJsApiDocs(compilerPath, join(outputDir, "reference/js-api")); + await generateJsApiDocs(joinPaths(compilerPath), join(outputDir, "reference/js-api")); return diagnostics; }