Skip to content

Commit

Permalink
Bump typedoc to 0.25.1 (#2447)
Browse files Browse the repository at this point in the history
This contained breaking changes and was required to upgrade to
typescript 5.2

---------

Co-authored-by: Mike Harder <[email protected]>
  • Loading branch information
timotheeguerin and mikeharder authored Sep 20, 2023
1 parent 8e3240a commit 4309d71
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 28 deletions.
30 changes: 15 additions & 15 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/tspd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
27 changes: 18 additions & 9 deletions packages/tspd/src/ref-doc/api-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PluginOptions> = {
entryFileName: "index.md",
propertiesFormat: "table",
Expand All @@ -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) {
Expand All @@ -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<DeclarationReflection>) => {
if (page.contents) {
Expand Down
4 changes: 2 additions & 2 deletions packages/website/.scripts/regen-compiler-docs.mjs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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;
}

0 comments on commit 4309d71

Please sign in to comment.