docusaurus-plugin-typedoc
Advanced tools
@@ -11,10 +11,14 @@ import { DeclarationOption } from 'typedoc'; | ||
| /** | ||
| * **sidebar.autoConfiguration** | ||
| * **autoConfiguration** | ||
| * | ||
| * Set to `false` to disable sidebar generation. Defaults to `true`. | ||
| * | ||
| * **sidebar.pretty** | ||
| * **pretty** | ||
| * | ||
| * Pretty format the sidebar JSON. | ||
| * | ||
| * **deprecatedItemClassName** | ||
| * | ||
| * The class name to apply to deprecated items in the sidebar. Defaults to `"typedoc-sidebar-item-deprecated"`. | ||
| * | ||
| * Please see the [sidebar guide](https:/typedoc-plugin-markdown.org/plugins/docusaurus/sidebar) for additional information on sidebar setup. | ||
@@ -21,0 +25,0 @@ * |
@@ -16,10 +16,14 @@ import { ParameterType } from 'typedoc'; | ||
| /** | ||
| * **sidebar.autoConfiguration** | ||
| * **autoConfiguration** | ||
| * | ||
| * Set to `false` to disable sidebar generation. Defaults to `true`. | ||
| * | ||
| * **sidebar.pretty** | ||
| * **pretty** | ||
| * | ||
| * Pretty format the sidebar JSON. | ||
| * | ||
| * **deprecatedItemClassName** | ||
| * | ||
| * The class name to apply to deprecated items in the sidebar. Defaults to `"typedoc-sidebar-item-deprecated"`. | ||
| * | ||
| * Please see the [sidebar guide](https:/typedoc-plugin-markdown.org/plugins/docusaurus/sidebar) for additional information on sidebar setup. | ||
@@ -32,2 +36,11 @@ * | ||
| defaultValue: DEFAULT_SIDEBAR_OPTIONS, | ||
| validate(value) { | ||
| if (typeof value !== 'object') { | ||
| console.warn('[typedoc-plugin-markdown] Sidebar must be an object.'); | ||
| } | ||
| const invalidKeys = Object.keys(value).filter((key) => !Object.keys(DEFAULT_SIDEBAR_OPTIONS).includes(key)); | ||
| if (invalidKeys.length > 0) { | ||
| console.warn(`[typedoc-plugin-markdown] Invalid keys in sidebar options: ${invalidKeys.join(', ')}`); | ||
| } | ||
| }, | ||
| }; |
| export declare const DEFAULT_SIDEBAR_OPTIONS: { | ||
| autoConfiguration: boolean; | ||
| pretty: 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, | ||
| deprecatedItemClassName: 'typedoc-sidebar-item-deprecated', | ||
| }; | ||
@@ -7,0 +8,0 @@ const DEFAULT_PLUGIN_OPTIONS = { |
@@ -49,3 +49,3 @@ import * as fs from 'fs'; | ||
| } | ||
| const sidebarJson = getSidebar(output.navigation, baseDir, numberPrefixParser); | ||
| const sidebarJson = getSidebar(output.navigation, baseDir, sidebar, numberPrefixParser); | ||
| fs.writeFileSync(sidebarPath, `// @ts-check | ||
@@ -52,0 +52,0 @@ /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ |
@@ -17,2 +17,3 @@ /** | ||
| pretty: boolean; | ||
| deprecatedItemClassName: string; | ||
| } |
| import { NavigationItem } from 'typedoc-plugin-markdown'; | ||
| export declare function getSidebar(navigation: NavigationItem[], basePath: string, numberPrefixParser?: any): any; | ||
| import { Sidebar } from '../types/options.js'; | ||
| export declare function getSidebar(navigation: NavigationItem[], basePath: string, options: Sidebar, numberPrefixParser?: any): any; |
@@ -1,7 +0,7 @@ | ||
| export function getSidebar(navigation, basePath, numberPrefixParser) { | ||
| export function getSidebar(navigation, basePath, options, numberPrefixParser) { | ||
| return navigation | ||
| .map((navigationItem) => getNavigationItem(navigationItem, basePath, numberPrefixParser)) | ||
| .map((navigationItem) => getNavigationItem(navigationItem, basePath, options, numberPrefixParser)) | ||
| .filter((navItem) => Boolean(navItem)); | ||
| } | ||
| function getNavigationItem(navigationItem, basePath, numberPrefixParser) { | ||
| function getNavigationItem(navigationItem, basePath, options, numberPrefixParser) { | ||
| const navigationItemPath = navigationItem.path || navigationItem.url; | ||
@@ -28,4 +28,4 @@ const parsedUrl = numberPrefixParser === false | ||
| type: 'category', | ||
| label: getNavigationLabel(navigationItem), | ||
| items: getSidebar(navigationItem.children, basePath, numberPrefixParser), | ||
| label: navigationItem.title, | ||
| items: getSidebar(navigationItem.children, basePath, options, numberPrefixParser), | ||
| ...(id && { | ||
@@ -43,16 +43,8 @@ link: { | ||
| id, | ||
| label: getNavigationLabel(navigationItem), | ||
| label: navigationItem.title, | ||
| ...(navigationItem.isDeprecated && { | ||
| className: options.deprecatedItemClassName, | ||
| }), | ||
| } | ||
| : null; | ||
| } | ||
| function getNavigationLabel(navigationItem) { | ||
| return navigationItem.isDeprecated | ||
| ? strikethrough(navigationItem.title) | ||
| : navigationItem.title; | ||
| } | ||
| function strikethrough(label) { | ||
| return label | ||
| .split('') | ||
| .map((char) => char + '\u0336') | ||
| .join(''); | ||
| } |
+1
-1
| { | ||
| "name": "docusaurus-plugin-typedoc", | ||
| "version": "1.2.0", | ||
| "version": "1.2.1", | ||
| "description": "A Docusaurus plugin to integrate TypeDoc ( + typedoc-plugin-markdown ) into a Docusaurus project.", | ||
@@ -5,0 +5,0 @@ "exports": { |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
15010
5.32%373
3.61%