Skip to content

Commit 2bbe23b

Browse files
committed
chore: Upgrade dependencies
1 parent 1c37702 commit 2bbe23b

File tree

7 files changed

+68
-82
lines changed

7 files changed

+68
-82
lines changed

package-lock.json

Lines changed: 44 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
"handlebars": "^4.7.6",
2626
"lodash": "^4.17.20",
2727
"lunr": "^2.3.9",
28-
"marked": "^1.2.8",
28+
"marked": "^1.2.9",
2929
"minimatch": "^3.0.0",
3030
"progress": "^2.0.3",
3131
"shelljs": "^0.8.4",
32-
"shiki": "^0.2.7",
32+
"shiki": "^0.9.2",
3333
"typedoc-default-themes": "^0.12.7"
3434
},
3535
"peerDependencies": {
@@ -43,11 +43,11 @@
4343
"@types/minimatch": "3.0.3",
4444
"@types/mocha": "^8.2.0",
4545
"@types/mockery": "^1.4.29",
46-
"@types/node": "^14.14.22",
46+
"@types/node": "^14.14.25",
4747
"@types/semver": "^7.3.4",
4848
"@types/shelljs": "^0.8.8",
49-
"@typescript-eslint/eslint-plugin": "^4.14.1",
50-
"@typescript-eslint/parser": "^4.14.1",
49+
"@typescript-eslint/eslint-plugin": "^4.14.2",
50+
"@typescript-eslint/parser": "^4.14.2",
5151
"eslint": "^7.19.0",
5252
"mocha": "^8.2.1",
5353
"mockery": "^2.1.0",

src/lib/output/plugins/MarkedPlugin.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Component, ContextAwareRendererComponent } from "../components";
77
import { RendererEvent, MarkdownEvent } from "../events";
88
import { BindOption, readFile } from "../../utils";
99
import { highlight, isSupportedLanguage } from "../../utils/highlighter";
10+
import { Theme } from "shiki";
1011

1112
const customMarkedRenderer = new Marked.Renderer();
1213

@@ -58,6 +59,9 @@ export class MarkedPlugin extends ContextAwareRendererComponent {
5859
@BindOption("media")
5960
mediaSource!: string;
6061

62+
@BindOption("highlightTheme")
63+
theme!: Theme;
64+
6165
/**
6266
* The path referenced files are located in.
6367
*/
@@ -113,7 +117,7 @@ export class MarkedPlugin extends ContextAwareRendererComponent {
113117
return text;
114118
}
115119

116-
return highlight(text, lang);
120+
return highlight(text, lang, this.theme);
117121
}
118122

119123
/**

src/lib/output/renderer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import { DefaultTheme } from "./themes/DefaultTheme";
2222
import { RendererComponent } from "./components";
2323
import { Component, ChildableComponent } from "../utils/component";
2424
import { BindOption } from "../utils";
25-
import { loadHighlighter, ShikiTheme } from "../utils/highlighter";
25+
import { loadHighlighter } from "../utils/highlighter";
26+
import { Theme as ShikiTheme } from "shiki";
2627

2728
/**
2829
* The renderer processes a [[ProjectReflection]] using a [[BaseTheme]] instance and writes

src/lib/utils/highlighter.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { ok as assert } from "assert";
22
import * as shiki from "shiki";
3-
import { Highlighter } from "shiki/dist/highlighter";
43
import { unique } from "./array";
54

6-
export type ShikiTheme = Parameters<typeof import("shiki")["getTheme"]>[0];
7-
85
// This is needed because Shiki includes some "fake" languages
96
// ts / js are expected by users to be equivalent to typescript / javascript
107

@@ -22,13 +19,11 @@ const supportedLanguages = unique([
2219
...shiki.BUNDLED_LANGUAGES.map((lang) => lang.id),
2320
]).sort();
2421

25-
let highlighter: Highlighter | undefined;
22+
let highlighter: shiki.Highlighter | undefined;
2623

27-
export async function loadHighlighter(theme: ShikiTheme) {
24+
export async function loadHighlighter(theme: shiki.Theme) {
2825
if (highlighter) return;
29-
highlighter = await shiki.getHighlighter({
30-
theme,
31-
});
26+
highlighter = await shiki.getHighlighter({ theme });
3227
}
3328

3429
export function isSupportedLanguage(lang: string) {
@@ -39,7 +34,11 @@ export function getSupportedLanguages(): string[] {
3934
return supportedLanguages;
4035
}
4136

42-
export function highlight(code: string, lang: string): string {
37+
export function highlight(
38+
code: string,
39+
lang: string,
40+
theme: shiki.Theme
41+
): string {
4342
assert(highlighter, "Tried to highlight with an uninitialized highlighter");
4443
if (!isSupportedLanguage(lang)) {
4544
return code;
@@ -52,7 +51,7 @@ export function highlight(code: string, lang: string): string {
5251
lang = aliases.get(lang) ?? lang;
5352

5453
const result: string[] = [];
55-
for (const line of highlighter.codeToThemedTokens(code, lang, {
54+
for (const line of highlighter.codeToThemedTokens(code, lang, theme, {
5655
includeExplanation: false,
5756
})) {
5857
for (const token of line) {

src/lib/utils/options/declaration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ShikiTheme } from "../highlighter";
1+
import { Theme as ShikiTheme } from "shiki";
22
import { LogLevel } from "../loggers";
33

44
/**

src/test/renderer/specs/modules/functions.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ <h5>paramG: <span class="tsd-signature-type">any</span></h5>
210210
<h5>paramA: <a href="../interfaces/classes.nameinterface.html" class="tsd-signature-type" data-tsd-kind="Interface">NameInterface</a></h5>
211211
<div class="tsd-comment tsd-typography">
212212
<p>This is a <strong>parameter</strong> pointing to an interface.</p>
213-
<pre><code><span style="color: #0000FF">var</span><span style="color: #000000"> </span><span style="color: #001080">value</span><span style="color: #000000">:</span><span style="color: #267F99">BaseClass</span><span style="color: #000000"> = </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #267F99">BaseClass</span><span style="color: #000000">(</span><span style="color: #A31515">&#039;test&#039;</span><span style="color: #000000">);</span>
213+
<pre><code><span style="color: #0000FF">var</span><span style="color: #000000"> </span><span style="color: #001080">value</span><span style="color: #000000">:</span><span style="color: #267F99">BaseClass</span><span style="color: #000000"> = </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #795E26">BaseClass</span><span style="color: #000000">(</span><span style="color: #A31515">&#039;test&#039;</span><span style="color: #000000">);</span>
214214
<span style="color: #795E26">functionWithArguments</span><span style="color: #000000">(</span><span style="color: #A31515">&#039;arg&#039;</span><span style="color: #000000">, </span><span style="color: #098658">0</span><span style="color: #000000">, </span><span style="color: #001080">value</span><span style="color: #000000">);</span>
215215
</code></pre>
216216
</div>
@@ -499,7 +499,7 @@ <h5>paramG: <span class="tsd-signature-type">any</span></h5>
499499
<h5>paramA: <a href="../interfaces/classes.nameinterface.html" class="tsd-signature-type" data-tsd-kind="Interface">NameInterface</a></h5>
500500
<div class="tsd-comment tsd-typography">
501501
<p>This is a <strong>parameter</strong> pointing to an interface.</p>
502-
<pre><code><span style="color: #0000FF">var</span><span style="color: #000000"> </span><span style="color: #001080">value</span><span style="color: #000000">:</span><span style="color: #267F99">BaseClass</span><span style="color: #000000"> = </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #267F99">BaseClass</span><span style="color: #000000">(</span><span style="color: #A31515">&#039;test&#039;</span><span style="color: #000000">);</span>
502+
<pre><code><span style="color: #0000FF">var</span><span style="color: #000000"> </span><span style="color: #001080">value</span><span style="color: #000000">:</span><span style="color: #267F99">BaseClass</span><span style="color: #000000"> = </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #795E26">BaseClass</span><span style="color: #000000">(</span><span style="color: #A31515">&#039;test&#039;</span><span style="color: #000000">);</span>
503503
<span style="color: #795E26">functionWithArguments</span><span style="color: #000000">(</span><span style="color: #A31515">&#039;arg&#039;</span><span style="color: #000000">, </span><span style="color: #098658">0</span><span style="color: #000000">, </span><span style="color: #001080">value</span><span style="color: #000000">);</span>
504504
</code></pre>
505505
</div>

0 commit comments

Comments
 (0)