From e750d58e0b188cf8932f7a0efa564d3658d20ac9 Mon Sep 17 00:00:00 2001 From: tgreyuk Date: Sat, 11 May 2024 22:00:05 +0100 Subject: [PATCH] chore(core): doc tweaks --- docs/pages/docs/customizing-output.mdx | 15 +++++++++----- docs/pages/docs/navigation.mdx | 27 +++++++++++++++----------- docs/pages/docs/typedoc-usage.mdx | 4 +++- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/docs/pages/docs/customizing-output.mdx b/docs/pages/docs/customizing-output.mdx index 3a5da4a39..2b57dc2c2 100644 --- a/docs/pages/docs/customizing-output.mdx +++ b/docs/pages/docs/customizing-output.mdx @@ -10,10 +10,15 @@ Plugins export a load function with context of the resolved application. Here is a basic plugin skeleton: -```ts filename="local-plugins/my-custom-plugin.ts" +```js filename="local-plugins/my-custom-plugin.mjs" +// @ts-check + import { MarkdownApplication } from 'typedoc-plugin-markdown'; -export function load(app: MarkdownApplication) { +/** + * @param {import('typedoc-plugin-markdown').MarkdownApplication} app + */ +export function load(app) { ... } ``` @@ -22,7 +27,7 @@ The plugin can then be consumed by adding the path to the plugin in the typedoc. ```json filename="typedoc.json" { - "plugin": ["typedoc-plugin-markdown", "./local-plugins/my-custom-plugin.js"] + "plugin": ["typedoc-plugin-markdown", "./local-plugins/my-custom-plugin.mjs"] } ``` @@ -85,14 +90,14 @@ In theory all available templates, partials and helpers can be overriden with cu This code defines a new theme called “customTheme”: ```ts -export function load(app) { +export function load(app: MarkdownApplication) { app.renderer.defineTheme('customTheme', MyMarkdownTheme); } class MyMarkdownTheme extends MarkdownTheme {} ``` -The theme can then be consumed by the theme optiond: +The theme can then be consumed by the `theme` option: ```json filename="typedoc.json" { diff --git a/docs/pages/docs/navigation.mdx b/docs/pages/docs/navigation.mdx index b57b971c9..eccf694fc 100644 --- a/docs/pages/docs/navigation.mdx +++ b/docs/pages/docs/navigation.mdx @@ -10,16 +10,21 @@ The navigation is returned as `JSON` and can be mapped to a custom structure and The model can be configured by the [`--navigationModel`](/docs/options#navigationmodel) option. -```ts filename="custom-plugin.ts" -export function load(app: MarkdownApplication) { - app.renderer.postRenderAsyncJobs.push( - async (renderer: MarkdownRendererEvent) => { - // The navigation JSON structure is available on the navigation object. - const navigation = renderer.navigation; - - // This can be parsed to something else or written straight to a file: - fs.writeFileSync('navigation.json', JSON.stringify(navigation)); - }, - ); +```ts filename="custom-plugin.mjs" +// @ts-check + +import { MarkdownApplication } from 'typedoc-plugin-markdown'; + +/** + * @param {import('typedoc-plugin-markdown').MarkdownApplication} app + */ +export function load(app) { + app.renderer.postRenderAsyncJobs.push(async (renderer) => { + // The navigation JSON structure is available on the navigation object. + const navigation = renderer.navigation; + + // This can be parsed to something else or written straight to a file: + fs.writeFileSync('navigation.json', JSON.stringify(navigation)); + }); } ``` diff --git a/docs/pages/docs/typedoc-usage.mdx b/docs/pages/docs/typedoc-usage.mdx index 2b561422b..9a67d312a 100644 --- a/docs/pages/docs/typedoc-usage.mdx +++ b/docs/pages/docs/typedoc-usage.mdx @@ -71,7 +71,9 @@ For JavaScript files, the `PluginOptions` interface can be imported to a `typedo You can use intersection types to combine the TypeDoc options with the plugin options. -```js filename="typedoc.config.js" +```js filename="typedoc.config.cjs" +// @ts-check + /** @type {import('typedoc').TypeDocOptions & import('typedoc-plugin-markdown').PluginOptions} */ module.exports = { entryPoints: ['./src/index.ts', './src/secondary-entry.ts'],