diff --git a/src/lib/output/renderer.ts b/src/lib/output/renderer.ts index a2bf058c2..321e0139c 100644 --- a/src/lib/output/renderer.ts +++ b/src/lib/output/renderer.ts @@ -9,7 +9,6 @@ import * as Path from "path"; import * as FS from "fs-extra"; -import { Theme as ShikiTheme } from "shiki-themes"; // eslint-disable-next-line const ProgressBar = require("progress"); @@ -23,7 +22,7 @@ import { DefaultTheme } from "./themes/DefaultTheme"; import { RendererComponent } from "./components"; import { Component, ChildableComponent } from "../utils/component"; import { BindOption } from "../utils"; -import { loadHighlighter } from "../utils/highlighter"; +import { loadHighlighter, ShikiTheme } from "../utils/highlighter"; /** * The renderer processes a [[ProjectReflection]] using a [[BaseTheme]] instance and writes diff --git a/src/lib/utils/highlighter.ts b/src/lib/utils/highlighter.ts index d8f75bf5f..178046ce0 100644 --- a/src/lib/utils/highlighter.ts +++ b/src/lib/utils/highlighter.ts @@ -1,9 +1,10 @@ import { ok as assert } from "assert"; import * as shiki from "shiki"; -import { Theme as ShikiTheme } from "shiki-themes"; import { Highlighter } from "shiki/dist/highlighter"; import { unique } from "./array"; +export type ShikiTheme = Parameters[0]; + // This is needed because Shiki includes some "fake" languages // ts / js are expected by users to be equivalent to typescript / javascript diff --git a/src/lib/utils/options/declaration.ts b/src/lib/utils/options/declaration.ts index 301e8f1ff..98e068b8e 100644 --- a/src/lib/utils/options/declaration.ts +++ b/src/lib/utils/options/declaration.ts @@ -1,5 +1,5 @@ +import { ShikiTheme } from "../highlighter"; import { LogLevel } from "../loggers"; -import { Theme as ShikiTheme } from "shiki-themes"; /** * An interface describing all TypeDoc specific options. Generated from a diff --git a/src/lib/utils/options/help.ts b/src/lib/utils/options/help.ts index c13240ea4..c0e20c22e 100644 --- a/src/lib/utils/options/help.ts +++ b/src/lib/utils/options/help.ts @@ -6,6 +6,7 @@ import { DeclarationOption, } from "./declaration"; import { getSupportedLanguages } from "../highlighter"; +import { BUNDLED_THEMES } from "shiki"; export interface ParameterHelp { names: string[]; @@ -94,5 +95,11 @@ export function getOptionsHelp(options: Options): string { ...toEvenColumns(getSupportedLanguages(), 80) ); + output.push( + "", + "Supported highlighting themes:", + ...toEvenColumns(BUNDLED_THEMES, 80) + ); + return output.join("\n"); } diff --git a/src/lib/utils/options/sources/typedoc.ts b/src/lib/utils/options/sources/typedoc.ts index cb6b66e0e..325f48860 100644 --- a/src/lib/utils/options/sources/typedoc.ts +++ b/src/lib/utils/options/sources/typedoc.ts @@ -1,7 +1,7 @@ import { Options } from ".."; import { LogLevel } from "../../loggers"; import { ParameterType, ParameterHint } from "../declaration"; -import { BUNDLED_THEMES as ShikiThemes } from "shiki-themes"; +import { BUNDLED_THEMES } from "shiki"; export function addTypeDocOptions(options: Pick) { options.addDeclaration({ @@ -121,6 +121,21 @@ export function addTypeDocOptions(options: Pick) { type: ParameterType.String, defaultValue: "default", }); + options.addDeclaration({ + name: "highlightTheme", + help: "Specifies the code highlighting theme.", + type: ParameterType.String, + defaultValue: "light-plus", + validate: (value: string): void => { + if (!BUNDLED_THEMES.includes(value)) { + throw new Error( + `highlightTheme must be one of the following: ${BUNDLED_THEMES.join( + ", " + )}` + ); + } + }, + }); options.addDeclaration({ name: "name", @@ -245,20 +260,4 @@ export function addTypeDocOptions(options: Pick) { "Specify the options passed to Marked, the Markdown parser used by TypeDoc", type: ParameterType.Mixed, }); - - options.addDeclaration({ - name: "highlightTheme", - help: "Specifies the code highlighting theme.", - type: ParameterType.String, - defaultValue: "light-plus", - validate: (value: string): void => { - if (!ShikiThemes.includes(value)) { - throw new Error( - `Highlight Theme must be one of the following: ${ShikiThemes.join( - ", " - )}` - ); - } - }, - }); }