docusaurus-plugin-typedoc
Advanced tools
@@ -7,5 +7,9 @@ import { DeclarationOption } from 'typedoc'; | ||
| * | ||
| * **typescript** | ||
| * | ||
| * Set to `true` to generate a TypeScript file. Defaults to `false` (CommonJs). | ||
| * | ||
| * **pretty** | ||
| * | ||
| * Pretty format the sidebar JSON. | ||
| * Pretty format the sidebar JSON. Defaults to `false`. | ||
| * | ||
@@ -16,5 +20,5 @@ * **deprecatedItemClassName** | ||
| * | ||
| * Please see the [sidebar guide](https:/typedoc-plugin-markdown.org/plugins/docusaurus/sidebar) for additional information on sidebar setup. | ||
| * Please see the [sidebar guide](/plugins/docusaurus/guides/sidebar) for additional information on sidebar setup. | ||
| * | ||
| */ | ||
| export declare const sidebar: Partial<DeclarationOption>; |
@@ -8,5 +8,9 @@ import { ParameterType } from 'typedoc'; | ||
| * | ||
| * **typescript** | ||
| * | ||
| * Set to `true` to generate a TypeScript file. Defaults to `false` (CommonJs). | ||
| * | ||
| * **pretty** | ||
| * | ||
| * Pretty format the sidebar JSON. | ||
| * Pretty format the sidebar JSON. Defaults to `false`. | ||
| * | ||
@@ -17,3 +21,3 @@ * **deprecatedItemClassName** | ||
| * | ||
| * Please see the [sidebar guide](https:/typedoc-plugin-markdown.org/plugins/docusaurus/sidebar) for additional information on sidebar setup. | ||
| * Please see the [sidebar guide](/plugins/docusaurus/guides/sidebar) for additional information on sidebar setup. | ||
| * | ||
@@ -20,0 +24,0 @@ */ |
| export declare const DEFAULT_SIDEBAR_OPTIONS: { | ||
| autoConfiguration: boolean; | ||
| pretty: boolean; | ||
| typescript: boolean; | ||
| deprecatedItemClassName: string; | ||
| }; | ||
| export declare function getPluginOptions(context: any, opts: Record<string, any>): Record<string, any>; |
@@ -5,2 +5,3 @@ import { presets } from './presets.js'; | ||
| pretty: false, | ||
| typescript: false, | ||
| deprecatedItemClassName: 'typedoc-sidebar-item-deprecated', | ||
@@ -7,0 +8,0 @@ }; |
@@ -6,3 +6,6 @@ import * as fs from 'fs'; | ||
| if (sidebar?.autoConfiguration) { | ||
| const sidebarPath = path.resolve(outputDir, 'typedoc-sidebar.cjs'); | ||
| const sidebarFileName = sidebar.typescript | ||
| ? 'typedoc-sidebar.ts' | ||
| : 'typedoc-sidebar.cjs'; | ||
| const sidebarPath = path.resolve(outputDir, sidebarFileName); | ||
| let baseDir = path | ||
@@ -17,7 +20,18 @@ .relative(siteDir, outputDir) | ||
| const sidebarJson = getSidebar(navigation, baseDir, sidebar, numberPrefixParser); | ||
| fs.writeFileSync(sidebarPath, `// @ts-check | ||
| const sidebarContent = sidebar.typescript | ||
| ? getTypescriptSidebar(sidebarJson, sidebar) | ||
| : getJsSidebar(sidebarJson, sidebar); | ||
| fs.writeFileSync(sidebarPath, sidebarContent); | ||
| } | ||
| } | ||
| function getTypescriptSidebar(sidebarJson, sidebar) { | ||
| return `import { SidebarsConfig } from '@docusaurus/plugin-content-docs'; | ||
| const typedocSidebar: SidebarsConfig = { items: ${JSON.stringify(sidebarJson, null, sidebar.pretty ? 2 : 0)}}; | ||
| export default typedocSidebar;`; | ||
| } | ||
| function getJsSidebar(sidebarJson, sidebar) { | ||
| return `// @ts-check | ||
| /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ | ||
| const typedocSidebar = { items: ${JSON.stringify(sidebarJson, null, sidebar.pretty ? 2 : 0)}}; | ||
| module.exports = typedocSidebar.items;`); | ||
| } | ||
| module.exports = typedocSidebar.items;`; | ||
| } | ||
@@ -24,0 +38,0 @@ function getSidebar(navigation, basePath, options, numberPrefixParser) { |
@@ -6,9 +6,5 @@ /** | ||
| /** | ||
| * docusaurus.config options - should not be used if running as a docusaurus plugin. | ||
| */ | ||
| docusaurusConfigOptions: string; | ||
| /** | ||
| * Configures the autogenerated Docusaurus sidebar. | ||
| */ | ||
| sidebar: Sidebar; | ||
| sidebar?: Sidebar; | ||
| } | ||
@@ -18,3 +14,4 @@ export interface Sidebar { | ||
| pretty: boolean; | ||
| typescript: boolean; | ||
| deprecatedItemClassName: string; | ||
| } |
@@ -0,1 +1,4 @@ | ||
| /* | ||
| * THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY | ||
| */ | ||
| export {}; |
+3
-3
| { | ||
| "name": "docusaurus-plugin-typedoc", | ||
| "version": "1.2.3", | ||
| "version": "1.3.0", | ||
| "description": "A Docusaurus plugin to integrate TypeDoc ( + typedoc-plugin-markdown ) into a Docusaurus project.", | ||
@@ -22,7 +22,7 @@ "exports": { | ||
| "peerDependencies": { | ||
| "typedoc-plugin-markdown": ">=4.4.0" | ||
| "typedoc-plugin-markdown": ">=4.6.0" | ||
| }, | ||
| "scripts": { | ||
| "lint": "eslint ./src", | ||
| "prebuild": "rm -rf dist && copyfiles --up 1 ./src/**/*.cjs ./dist/", | ||
| "prebuild": "rm -rf dist && prebuild-options && copyfiles --up 1 ./src/**/*.cjs ./dist/", | ||
| "prepublishOnly": "npm run lint && npm run build", | ||
@@ -29,0 +29,0 @@ "build": "tsc", |
14707
6.2%362
7.1%