typedoc 0.27.5 → 0.27.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/application.js +0 -4
- package/dist/lib/converter/comments/declarationReference.d.ts +2 -1
- package/dist/lib/converter/comments/declarationReference.js +9 -0
- package/dist/lib/converter/comments/linkResolver.js +20 -5
- package/dist/lib/converter/converter.d.ts +3 -0
- package/dist/lib/converter/converter.js +3 -1
- package/dist/lib/converter/plugins/IncludePlugin.d.ts +2 -1
- package/dist/lib/converter/plugins/PackagePlugin.js +3 -0
- package/dist/lib/converter/symbols.js +1 -1
- package/dist/lib/converter/types.js +16 -3
- package/dist/lib/converter/utils/nodes.d.ts +1 -0
- package/dist/lib/converter/utils/nodes.js +4 -0
- package/dist/lib/internationalization/locales/en.cjs +1 -0
- package/dist/lib/internationalization/locales/en.d.cts +1 -0
- package/dist/lib/output/renderer.d.ts +1 -0
- package/dist/lib/output/renderer.js +10 -2
- package/dist/lib/utils/array.d.ts +1 -0
- package/dist/lib/utils/array.js +15 -0
- package/dist/lib/utils/highlighter.d.ts +1 -1
- package/dist/lib/utils/highlighter.js +6 -4
- package/dist/lib/utils/options/declaration.d.ts +1 -0
- package/dist/lib/utils/options/defaults.d.ts +1 -0
- package/dist/lib/utils/options/defaults.js +1 -0
- package/dist/lib/utils/options/options.d.ts +0 -8
- package/dist/lib/utils/options/options.js +0 -18
- package/dist/lib/utils/options/readers/typedoc.d.ts +0 -3
- package/dist/lib/utils/options/readers/typedoc.js +2 -3
- package/dist/lib/utils/options/sources/typedoc.js +6 -0
- package/package.json +1 -1
package/dist/lib/application.js
CHANGED
|
@@ -317,9 +317,6 @@ let Application = (() => {
|
|
|
317
317
|
*/
|
|
318
318
|
async convert() {
|
|
319
319
|
const start = Date.now();
|
|
320
|
-
// We freeze here rather than in the Converter class since TypeDoc's tests reuse the Application
|
|
321
|
-
// with a few different settings.
|
|
322
|
-
this.options.freeze();
|
|
323
320
|
this.logger.verbose(`Using TypeScript ${this.getTypeScriptVersion()} from ${this.getTypeScriptPath()}`);
|
|
324
321
|
if (this.entryPointStrategy === EntryPointStrategy.Merge) {
|
|
325
322
|
return this._merge();
|
|
@@ -356,7 +353,6 @@ let Application = (() => {
|
|
|
356
353
|
return project;
|
|
357
354
|
}
|
|
358
355
|
convertAndWatch(success) {
|
|
359
|
-
this.options.freeze();
|
|
360
356
|
if (!this.options.getValue("preserveWatchOutput") &&
|
|
361
357
|
this.logger instanceof ConsoleLogger) {
|
|
362
358
|
ts.sys.clearScreen?.();
|
|
@@ -27,7 +27,8 @@ export interface ComponentPath {
|
|
|
27
27
|
* How to resolve the `path`
|
|
28
28
|
* - `.` - Navigate via `exports` of symbol
|
|
29
29
|
* - `#` - Navigate via `members` of symbol
|
|
30
|
-
* - `~` - Navigate via `locals` of symbol
|
|
30
|
+
* - `~` - Navigate via `locals` of symbol (note: TypeDoc does not support
|
|
31
|
+
* locals, see the declaration reference docs)
|
|
31
32
|
*/
|
|
32
33
|
navigation: "." | "#" | "~";
|
|
33
34
|
path: string;
|
|
@@ -300,6 +300,7 @@ export function parseDeclarationReference(source, pos, end) {
|
|
|
300
300
|
let moduleSource;
|
|
301
301
|
let symbolReference;
|
|
302
302
|
let resolutionStart = "local";
|
|
303
|
+
let topLevelLocalReference = false;
|
|
303
304
|
const moduleSourceOrSymbolRef = parseModuleSource(source, pos, end);
|
|
304
305
|
if (moduleSourceOrSymbolRef) {
|
|
305
306
|
if (moduleSourceOrSymbolRef[1] < end &&
|
|
@@ -308,6 +309,11 @@ export function parseDeclarationReference(source, pos, end) {
|
|
|
308
309
|
pos = moduleSourceOrSymbolRef[1] + 1;
|
|
309
310
|
resolutionStart = "global";
|
|
310
311
|
moduleSource = moduleSourceOrSymbolRef[0];
|
|
312
|
+
// We might be referencing a local of a module
|
|
313
|
+
if (source[pos] === "~") {
|
|
314
|
+
topLevelLocalReference = true;
|
|
315
|
+
pos++;
|
|
316
|
+
}
|
|
311
317
|
}
|
|
312
318
|
}
|
|
313
319
|
else if (source[pos] === "!") {
|
|
@@ -317,6 +323,9 @@ export function parseDeclarationReference(source, pos, end) {
|
|
|
317
323
|
const ref = parseSymbolReference(source, pos, end);
|
|
318
324
|
if (ref) {
|
|
319
325
|
symbolReference = ref[0];
|
|
326
|
+
if (topLevelLocalReference && symbolReference.path?.length) {
|
|
327
|
+
symbolReference.path[0].navigation = "~";
|
|
328
|
+
}
|
|
320
329
|
pos = ref[1];
|
|
321
330
|
}
|
|
322
331
|
if (!moduleSource && !symbolReference)
|
|
@@ -2,6 +2,7 @@ import ts from "typescript";
|
|
|
2
2
|
import { DeclarationReflection, Reflection, ReflectionKind, ReflectionSymbolId, } from "../../models/index.js";
|
|
3
3
|
import { parseDeclarationReference, } from "./declarationReference.js";
|
|
4
4
|
import { resolveDeclarationReference } from "./declarationReferenceResolver.js";
|
|
5
|
+
import { maxElementByScore } from "../../utils/array.js";
|
|
5
6
|
const urlPrefix = /^(http|ftp)s?:\/\//;
|
|
6
7
|
export function resolveLinks(comment, reflection, externalResolver, options) {
|
|
7
8
|
comment.summary = resolvePartLinks(reflection, comment.summary, externalResolver, options);
|
|
@@ -48,11 +49,25 @@ function resolveLinkTag(reflection, part, externalResolver, options) {
|
|
|
48
49
|
const tsTargets = reflection.project.getReflectionsFromSymbolId(part.target);
|
|
49
50
|
if (tsTargets.length) {
|
|
50
51
|
// Find the target most likely to have a real url in the generated documentation
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
// 1. A direct export (class, interface, variable)
|
|
53
|
+
// 2. A property of a direct export (class/interface property)
|
|
54
|
+
// 3. A property of a type of an export (property on type alias)
|
|
55
|
+
// 4. Whatever the first symbol found was
|
|
56
|
+
target = maxElementByScore(tsTargets, (r) => {
|
|
57
|
+
if (r.kindOf(ReflectionKind.SomeExport)) {
|
|
58
|
+
return 4;
|
|
59
|
+
}
|
|
60
|
+
if (r.kindOf(ReflectionKind.SomeMember) &&
|
|
61
|
+
r.parent?.kindOf(ReflectionKind.SomeExport)) {
|
|
62
|
+
return 3;
|
|
63
|
+
}
|
|
64
|
+
if (r.kindOf(ReflectionKind.SomeMember) &&
|
|
65
|
+
r.parent?.kindOf(ReflectionKind.TypeLiteral) &&
|
|
66
|
+
r.parent.parent?.kindOf(ReflectionKind.TypeAlias | ReflectionKind.Variable)) {
|
|
67
|
+
return 2;
|
|
68
|
+
}
|
|
69
|
+
return 1;
|
|
70
|
+
});
|
|
56
71
|
pos = end;
|
|
57
72
|
defaultDisplayText =
|
|
58
73
|
part.tsLinkText ||
|
|
@@ -10,6 +10,7 @@ import type { CommentStyle, ValidationOptions } from "../utils/options/declarati
|
|
|
10
10
|
import { type ExternalSymbolResolver, type ExternalResolveResult } from "./comments/linkResolver.js";
|
|
11
11
|
import { type DeclarationReference } from "./comments/declarationReference.js";
|
|
12
12
|
import type { FileRegistry } from "../models/FileRegistry.js";
|
|
13
|
+
import { IncludePlugin } from "./plugins/IncludePlugin.js";
|
|
13
14
|
export interface ConverterEvents {
|
|
14
15
|
begin: [Context];
|
|
15
16
|
end: [Context];
|
|
@@ -144,6 +145,8 @@ export declare class Converter extends AbstractComponent<Application, ConverterE
|
|
|
144
145
|
* @event
|
|
145
146
|
*/
|
|
146
147
|
static readonly EVENT_RESOLVE_END: "resolveEnd";
|
|
148
|
+
/** @internal @hidden */
|
|
149
|
+
includePlugin: IncludePlugin;
|
|
147
150
|
constructor(owner: Application);
|
|
148
151
|
/**
|
|
149
152
|
* Compile the given source files and create a project reflection for them.
|
|
@@ -255,6 +255,8 @@ let Converter = (() => {
|
|
|
255
255
|
* @event
|
|
256
256
|
*/
|
|
257
257
|
static EVENT_RESOLVE_END = ConverterEvents.RESOLVE_END;
|
|
258
|
+
/** @internal @hidden */
|
|
259
|
+
includePlugin;
|
|
258
260
|
constructor(owner) {
|
|
259
261
|
super(owner);
|
|
260
262
|
const userConfiguredSymbolResolver = (ref, refl, _part, symbolId) => {
|
|
@@ -294,7 +296,7 @@ let Converter = (() => {
|
|
|
294
296
|
new PackagePlugin(this);
|
|
295
297
|
new SourcePlugin(this);
|
|
296
298
|
new TypePlugin(this);
|
|
297
|
-
new IncludePlugin(this);
|
|
299
|
+
this.includePlugin = new IncludePlugin(this);
|
|
298
300
|
new MergeModuleWithPlugin(this);
|
|
299
301
|
}
|
|
300
302
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConverterComponent } from "../components.js";
|
|
2
|
+
import type { CommentDisplayPart, Reflection } from "../../models/index.js";
|
|
2
3
|
import type { Converter } from "../converter.js";
|
|
3
4
|
/**
|
|
4
5
|
* Handles `@include` and `@includeCode` within comments/documents.
|
|
@@ -7,5 +8,5 @@ export declare class IncludePlugin extends ConverterComponent {
|
|
|
7
8
|
get logger(): import("../../utils/loggers.js").Logger;
|
|
8
9
|
constructor(owner: Converter);
|
|
9
10
|
private onCreate;
|
|
10
|
-
|
|
11
|
+
checkIncludeTagsParts(refl: Reflection, relative: string, parts: CommentDisplayPart[], included?: string[]): void;
|
|
11
12
|
}
|
|
@@ -155,6 +155,9 @@ let PackagePlugin = (() => {
|
|
|
155
155
|
if (this.readmeFile && this.readmeContents) {
|
|
156
156
|
const { content } = this.application.converter.parseRawComment(new MinimalSourceFile(this.readmeContents, this.readmeFile), project.files);
|
|
157
157
|
project.readme = content;
|
|
158
|
+
// This isn't ideal, but seems better than figuring out the readme
|
|
159
|
+
// path over in the include plugin...
|
|
160
|
+
this.owner.includePlugin.checkIncludeTagsParts(project, Path.dirname(this.readmeFile), content);
|
|
158
161
|
}
|
|
159
162
|
if (this.packageJson) {
|
|
160
163
|
project.packageName = this.packageJson.name;
|
|
@@ -501,7 +501,7 @@ function createAlias(target, context, symbol, exportSymbol) {
|
|
|
501
501
|
if (context.converter.excludeReferences)
|
|
502
502
|
return;
|
|
503
503
|
// We already have this. Create a reference.
|
|
504
|
-
const ref = new ReferenceReflection(exportSymbol?.name ?? symbol.name, target, context.scope);
|
|
504
|
+
const ref = new ReferenceReflection(exportSymbol?.name ?? symbol.name, target.isReference() ? target.getTargetReflection() : target, context.scope);
|
|
505
505
|
context.postReflectionCreation(ref, symbol, exportSymbol);
|
|
506
506
|
context.finalizeDeclarationReflection(ref);
|
|
507
507
|
}
|
|
@@ -7,7 +7,7 @@ import { ConverterEvents } from "./converter-events.js";
|
|
|
7
7
|
import { convertIndexSignatures } from "./factories/index-signature.js";
|
|
8
8
|
import { convertParameterNodes, convertTypeParameterNodes, createSignature, } from "./factories/signature.js";
|
|
9
9
|
import { convertSymbol } from "./symbols.js";
|
|
10
|
-
import { isObjectType } from "./utils/nodes.js";
|
|
10
|
+
import { isObjectType, isTypeReference } from "./utils/nodes.js";
|
|
11
11
|
import { removeUndefined } from "./utils/reflections.js";
|
|
12
12
|
const converters = new Map();
|
|
13
13
|
export function loadConverters() {
|
|
@@ -490,9 +490,22 @@ const referenceConverter = {
|
|
|
490
490
|
];
|
|
491
491
|
}
|
|
492
492
|
else {
|
|
493
|
-
|
|
493
|
+
// Default type arguments are filled with a reference to the default
|
|
494
|
+
// type. As TS doesn't support specifying earlier defaults, we know
|
|
495
|
+
// that this will only filter out type arguments which aren't specified
|
|
496
|
+
// by the user.
|
|
497
|
+
let ignoredArgs;
|
|
498
|
+
if (isTypeReference(type)) {
|
|
499
|
+
ignoredArgs = type.target.typeParameters
|
|
500
|
+
?.map((p) => p.getDefault())
|
|
501
|
+
.filter((x) => !!x);
|
|
502
|
+
}
|
|
503
|
+
const args = type.aliasSymbol
|
|
494
504
|
? type.aliasTypeArguments
|
|
495
|
-
: type.typeArguments
|
|
505
|
+
: type.typeArguments;
|
|
506
|
+
ref.typeArguments = args
|
|
507
|
+
?.filter((ref) => !ignoredArgs?.includes(ref))
|
|
508
|
+
.map((ref) => convertType(context, ref));
|
|
496
509
|
}
|
|
497
510
|
return ref;
|
|
498
511
|
},
|
|
@@ -4,3 +4,4 @@ export declare function isNamedNode(node: unknown): node is {
|
|
|
4
4
|
};
|
|
5
5
|
export declare function getHeritageTypes(declarations: readonly (ts.ClassDeclaration | ts.InterfaceDeclaration)[], kind: ts.SyntaxKind.ImplementsKeyword | ts.SyntaxKind.ExtendsKeyword): ts.ExpressionWithTypeArguments[];
|
|
6
6
|
export declare function isObjectType(type: ts.Type): type is ts.ObjectType;
|
|
7
|
+
export declare function isTypeReference(type: ts.Type): type is ts.TypeReference;
|
|
@@ -20,3 +20,7 @@ export function getHeritageTypes(declarations, kind) {
|
|
|
20
20
|
export function isObjectType(type) {
|
|
21
21
|
return typeof type.objectFlags === "number";
|
|
22
22
|
}
|
|
23
|
+
export function isTypeReference(type) {
|
|
24
|
+
return (isObjectType(type) &&
|
|
25
|
+
(type.objectFlags & ts.ObjectFlags.Reference) !== 0);
|
|
26
|
+
}
|
|
@@ -160,6 +160,7 @@ module.exports = {
|
|
|
160
160
|
help_lightHighlightTheme: "Specify the code highlighting theme in light mode",
|
|
161
161
|
help_darkHighlightTheme: "Specify the code highlighting theme in dark mode",
|
|
162
162
|
help_highlightLanguages: "Specify the languages which will be loaded to highlight code when rendering",
|
|
163
|
+
help_ignoredHighlightLanguages: "Specify languages which will be accepted as valid highlight languages, but will not be highlighted at runtime",
|
|
163
164
|
help_typePrintWidth: "Width at which to wrap code to a new line when rendering a type",
|
|
164
165
|
help_customCss: "Path to a custom CSS file to for the theme to import",
|
|
165
166
|
help_customJs: "Path to a custom JS file to import",
|
|
@@ -147,6 +147,7 @@ declare const _default: {
|
|
|
147
147
|
readonly help_lightHighlightTheme: "Specify the code highlighting theme in light mode";
|
|
148
148
|
readonly help_darkHighlightTheme: "Specify the code highlighting theme in dark mode";
|
|
149
149
|
readonly help_highlightLanguages: "Specify the languages which will be loaded to highlight code when rendering";
|
|
150
|
+
readonly help_ignoredHighlightLanguages: "Specify languages which will be accepted as valid highlight languages, but will not be highlighted at runtime";
|
|
150
151
|
readonly help_typePrintWidth: "Width at which to wrap code to a new line when rendering a type";
|
|
151
152
|
readonly help_customCss: "Path to a custom CSS file to for the theme to import";
|
|
152
153
|
readonly help_customJs: "Path to a custom JS file to import";
|
|
@@ -171,6 +171,7 @@ export declare class Renderer extends AbstractComponent<Application, RendererEve
|
|
|
171
171
|
private accessor lightTheme;
|
|
172
172
|
private accessor darkTheme;
|
|
173
173
|
private accessor highlightLanguages;
|
|
174
|
+
private accessor ignoredHighlightLanguages;
|
|
174
175
|
private accessor pretty;
|
|
175
176
|
renderStartTime: number;
|
|
176
177
|
markedPlugin: MarkedPlugin;
|
|
@@ -108,6 +108,9 @@ let Renderer = (() => {
|
|
|
108
108
|
let _highlightLanguages_decorators;
|
|
109
109
|
let _highlightLanguages_initializers = [];
|
|
110
110
|
let _highlightLanguages_extraInitializers = [];
|
|
111
|
+
let _ignoredHighlightLanguages_decorators;
|
|
112
|
+
let _ignoredHighlightLanguages_initializers = [];
|
|
113
|
+
let _ignoredHighlightLanguages_extraInitializers = [];
|
|
111
114
|
let _pretty_decorators;
|
|
112
115
|
let _pretty_initializers = [];
|
|
113
116
|
let _pretty_extraInitializers = [];
|
|
@@ -122,6 +125,7 @@ let Renderer = (() => {
|
|
|
122
125
|
_lightTheme_decorators = [Option("lightHighlightTheme")];
|
|
123
126
|
_darkTheme_decorators = [Option("darkHighlightTheme")];
|
|
124
127
|
_highlightLanguages_decorators = [Option("highlightLanguages")];
|
|
128
|
+
_ignoredHighlightLanguages_decorators = [Option("ignoredHighlightLanguages")];
|
|
125
129
|
_pretty_decorators = [Option("pretty")];
|
|
126
130
|
__esDecorate(this, null, _themeName_decorators, { kind: "accessor", name: "themeName", static: false, private: false, access: { has: obj => "themeName" in obj, get: obj => obj.themeName, set: (obj, value) => { obj.themeName = value; } }, metadata: _metadata }, _themeName_initializers, _themeName_extraInitializers);
|
|
127
131
|
__esDecorate(this, null, _cleanOutputDir_decorators, { kind: "accessor", name: "cleanOutputDir", static: false, private: false, access: { has: obj => "cleanOutputDir" in obj, get: obj => obj.cleanOutputDir, set: (obj, value) => { obj.cleanOutputDir = value; } }, metadata: _metadata }, _cleanOutputDir_initializers, _cleanOutputDir_extraInitializers);
|
|
@@ -131,6 +135,7 @@ let Renderer = (() => {
|
|
|
131
135
|
__esDecorate(this, null, _lightTheme_decorators, { kind: "accessor", name: "lightTheme", static: false, private: false, access: { has: obj => "lightTheme" in obj, get: obj => obj.lightTheme, set: (obj, value) => { obj.lightTheme = value; } }, metadata: _metadata }, _lightTheme_initializers, _lightTheme_extraInitializers);
|
|
132
136
|
__esDecorate(this, null, _darkTheme_decorators, { kind: "accessor", name: "darkTheme", static: false, private: false, access: { has: obj => "darkTheme" in obj, get: obj => obj.darkTheme, set: (obj, value) => { obj.darkTheme = value; } }, metadata: _metadata }, _darkTheme_initializers, _darkTheme_extraInitializers);
|
|
133
137
|
__esDecorate(this, null, _highlightLanguages_decorators, { kind: "accessor", name: "highlightLanguages", static: false, private: false, access: { has: obj => "highlightLanguages" in obj, get: obj => obj.highlightLanguages, set: (obj, value) => { obj.highlightLanguages = value; } }, metadata: _metadata }, _highlightLanguages_initializers, _highlightLanguages_extraInitializers);
|
|
138
|
+
__esDecorate(this, null, _ignoredHighlightLanguages_decorators, { kind: "accessor", name: "ignoredHighlightLanguages", static: false, private: false, access: { has: obj => "ignoredHighlightLanguages" in obj, get: obj => obj.ignoredHighlightLanguages, set: (obj, value) => { obj.ignoredHighlightLanguages = value; } }, metadata: _metadata }, _ignoredHighlightLanguages_initializers, _ignoredHighlightLanguages_extraInitializers);
|
|
134
139
|
__esDecorate(this, null, _pretty_decorators, { kind: "accessor", name: "pretty", static: false, private: false, access: { has: obj => "pretty" in obj, get: obj => obj.pretty, set: (obj, value) => { obj.pretty = value; } }, metadata: _metadata }, _pretty_initializers, _pretty_extraInitializers);
|
|
135
140
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
136
141
|
}
|
|
@@ -206,7 +211,10 @@ let Renderer = (() => {
|
|
|
206
211
|
#highlightLanguages_accessor_storage = (__runInitializers(this, _darkTheme_extraInitializers), __runInitializers(this, _highlightLanguages_initializers, void 0));
|
|
207
212
|
get highlightLanguages() { return this.#highlightLanguages_accessor_storage; }
|
|
208
213
|
set highlightLanguages(value) { this.#highlightLanguages_accessor_storage = value; }
|
|
209
|
-
#
|
|
214
|
+
#ignoredHighlightLanguages_accessor_storage = (__runInitializers(this, _highlightLanguages_extraInitializers), __runInitializers(this, _ignoredHighlightLanguages_initializers, void 0));
|
|
215
|
+
get ignoredHighlightLanguages() { return this.#ignoredHighlightLanguages_accessor_storage; }
|
|
216
|
+
set ignoredHighlightLanguages(value) { this.#ignoredHighlightLanguages_accessor_storage = value; }
|
|
217
|
+
#pretty_accessor_storage = (__runInitializers(this, _ignoredHighlightLanguages_extraInitializers), __runInitializers(this, _pretty_initializers, void 0));
|
|
210
218
|
get pretty() { return this.#pretty_accessor_storage; }
|
|
211
219
|
set pretty(value) { this.#pretty_accessor_storage = value; }
|
|
212
220
|
renderStartTime = (__runInitializers(this, _pretty_extraInitializers), -1);
|
|
@@ -272,7 +280,7 @@ let Renderer = (() => {
|
|
|
272
280
|
async loadHighlighter() {
|
|
273
281
|
await loadHighlighter(this.lightTheme, this.darkTheme,
|
|
274
282
|
// Checked in option validation
|
|
275
|
-
this.highlightLanguages);
|
|
283
|
+
this.highlightLanguages, this.ignoredHighlightLanguages);
|
|
276
284
|
}
|
|
277
285
|
/**
|
|
278
286
|
* Render a single page.
|
|
@@ -54,3 +54,4 @@ export declare function filter<T>(array: readonly T[] | undefined, predicate: (v
|
|
|
54
54
|
export declare function aggregate<T>(arr: T[], fn: (item: T) => number): number;
|
|
55
55
|
export declare function aggregateWithJoiner<T>(arr: T[], fn: (item: T) => number, joiner: string): number;
|
|
56
56
|
export declare function joinArray<T>(arr: readonly T[] | undefined, joiner: string, mapper: (item: T) => string): string;
|
|
57
|
+
export declare function maxElementByScore<T>(arr: readonly T[], score: (a: T) => number): T | undefined;
|
package/dist/lib/utils/array.js
CHANGED
|
@@ -141,3 +141,18 @@ export function joinArray(arr, joiner, mapper) {
|
|
|
141
141
|
}
|
|
142
142
|
return "";
|
|
143
143
|
}
|
|
144
|
+
export function maxElementByScore(arr, score) {
|
|
145
|
+
if (arr.length === 0) {
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
let largest = arr[0];
|
|
149
|
+
let largestScore = score(arr[0]);
|
|
150
|
+
for (let i = 1; i < arr.length; ++i) {
|
|
151
|
+
const itemScore = score(arr[i]);
|
|
152
|
+
if (itemScore > largestScore) {
|
|
153
|
+
largest = arr[i];
|
|
154
|
+
largestScore = itemScore;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return largest;
|
|
158
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as shiki from "@gerrit0/mini-shiki";
|
|
2
|
-
export declare function loadHighlighter(lightTheme: shiki.BundledTheme, darkTheme: shiki.BundledTheme, langs: shiki.BundledLanguage[]): Promise<void>;
|
|
2
|
+
export declare function loadHighlighter(lightTheme: shiki.BundledTheme, darkTheme: shiki.BundledTheme, langs: shiki.BundledLanguage[], ignoredLangs: string[] | undefined): Promise<void>;
|
|
3
3
|
export declare function isSupportedLanguage(lang: string): boolean;
|
|
4
4
|
export declare function getSupportedLanguages(): string[];
|
|
5
5
|
export declare function getSupportedThemes(): string[];
|
|
@@ -92,9 +92,11 @@ class DoubleHighlighter {
|
|
|
92
92
|
}
|
|
93
93
|
let shikiEngine;
|
|
94
94
|
let highlighter;
|
|
95
|
-
|
|
95
|
+
let ignoredLanguages;
|
|
96
|
+
export async function loadHighlighter(lightTheme, darkTheme, langs, ignoredLangs) {
|
|
96
97
|
if (highlighter)
|
|
97
98
|
return;
|
|
99
|
+
ignoredLanguages = ignoredLangs;
|
|
98
100
|
if (!shikiEngine) {
|
|
99
101
|
await shiki.loadBuiltinWasm();
|
|
100
102
|
shikiEngine = await shiki.createOnigurumaEngine();
|
|
@@ -107,7 +109,7 @@ export async function loadHighlighter(lightTheme, darkTheme, langs) {
|
|
|
107
109
|
highlighter = new DoubleHighlighter(hl, lightTheme, darkTheme);
|
|
108
110
|
}
|
|
109
111
|
export function isSupportedLanguage(lang) {
|
|
110
|
-
return getSupportedLanguages().includes(lang);
|
|
112
|
+
return ignoredLanguages?.includes(lang) || getSupportedLanguages().includes(lang);
|
|
111
113
|
}
|
|
112
114
|
export function getSupportedLanguages() {
|
|
113
115
|
return supportedLanguages;
|
|
@@ -116,11 +118,11 @@ export function getSupportedThemes() {
|
|
|
116
118
|
return supportedThemes;
|
|
117
119
|
}
|
|
118
120
|
export function isLoadedLanguage(lang) {
|
|
119
|
-
return plaintextLanguages.includes(lang) || (highlighter?.supports(lang)
|
|
121
|
+
return (plaintextLanguages.includes(lang) || ignoredLanguages?.includes(lang) || highlighter?.supports(lang) || false);
|
|
120
122
|
}
|
|
121
123
|
export function highlight(code, lang) {
|
|
122
124
|
assert(highlighter, "Tried to highlight with an uninitialized highlighter");
|
|
123
|
-
if (plaintextLanguages.includes(lang)) {
|
|
125
|
+
if (plaintextLanguages.includes(lang) || ignoredLanguages?.includes(lang)) {
|
|
124
126
|
return JSX.renderElement(JSX.createElement(JSX.Fragment, null, code));
|
|
125
127
|
}
|
|
126
128
|
return highlighter.highlight(code, aliases.get(lang) ?? lang);
|
|
@@ -105,6 +105,7 @@ export interface TypeDocOptionMap {
|
|
|
105
105
|
lightHighlightTheme: ShikiTheme;
|
|
106
106
|
darkHighlightTheme: ShikiTheme;
|
|
107
107
|
highlightLanguages: string[];
|
|
108
|
+
ignoredHighlightLanguages: string[];
|
|
108
109
|
typePrintWidth: number;
|
|
109
110
|
customCss: string;
|
|
110
111
|
customJs: string;
|
|
@@ -13,6 +13,7 @@ export declare const modifierTags: readonly `@${string}`[];
|
|
|
13
13
|
export declare const cascadedModifierTags: readonly `@${string}`[];
|
|
14
14
|
export declare const notRenderedTags: readonly `@${string}`[];
|
|
15
15
|
export declare const highlightLanguages: readonly BundledLanguage[];
|
|
16
|
+
export declare const ignoredHighlightLanguages: readonly string[];
|
|
16
17
|
export declare const sort: readonly string[];
|
|
17
18
|
export declare const kindSortOrder: readonly EnumKeys<typeof ReflectionKind>[];
|
|
18
19
|
export declare const requiredToBeDocumented: readonly EnumKeys<typeof ReflectionKind>[];
|
|
@@ -82,14 +82,6 @@ export declare class Options {
|
|
|
82
82
|
* Clones the options, intended for use in packages mode.
|
|
83
83
|
*/
|
|
84
84
|
copyForPackage(packageDir: string): Options;
|
|
85
|
-
/**
|
|
86
|
-
* Marks the options as readonly, enables caching when fetching options, which improves performance.
|
|
87
|
-
*/
|
|
88
|
-
freeze(): void;
|
|
89
|
-
/**
|
|
90
|
-
* Checks if the options object has been frozen, preventing future changes to option values.
|
|
91
|
-
*/
|
|
92
|
-
isFrozen(): boolean;
|
|
93
85
|
/**
|
|
94
86
|
* Take a snapshot of option values now, used in tests only.
|
|
95
87
|
* @internal
|
|
@@ -60,18 +60,6 @@ export class Options {
|
|
|
60
60
|
}
|
|
61
61
|
return options;
|
|
62
62
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Marks the options as readonly, enables caching when fetching options, which improves performance.
|
|
65
|
-
*/
|
|
66
|
-
freeze() {
|
|
67
|
-
Object.freeze(this._values);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Checks if the options object has been frozen, preventing future changes to option values.
|
|
71
|
-
*/
|
|
72
|
-
isFrozen() {
|
|
73
|
-
return Object.isFrozen(this._values);
|
|
74
|
-
}
|
|
75
63
|
/**
|
|
76
64
|
* Take a snapshot of option values now, used in tests only.
|
|
77
65
|
* @internal
|
|
@@ -168,9 +156,6 @@ export class Options {
|
|
|
168
156
|
return this._values[declaration.name];
|
|
169
157
|
}
|
|
170
158
|
setValue(name, value, configPath) {
|
|
171
|
-
if (this.isFrozen()) {
|
|
172
|
-
throw new Error(`Tried to modify an option (${name}) value after options have been frozen.`);
|
|
173
|
-
}
|
|
174
159
|
const declaration = this.getDeclaration(name);
|
|
175
160
|
if (!declaration) {
|
|
176
161
|
const nearNames = this.getSimilarOptions(name);
|
|
@@ -234,9 +219,6 @@ export class Options {
|
|
|
234
219
|
* Sets the compiler options that will be used to get a TS program.
|
|
235
220
|
*/
|
|
236
221
|
setCompilerOptions(fileNames, options, projectReferences) {
|
|
237
|
-
if (this.isFrozen()) {
|
|
238
|
-
throw new Error("Tried to modify compiler options after options have been frozen.");
|
|
239
|
-
}
|
|
240
222
|
// We do this here instead of in the tsconfig reader so that API consumers which
|
|
241
223
|
// supply a program to `Converter.convert` instead of letting TypeDoc create one
|
|
242
224
|
// can just set the compiler options, and not need to know about this mapping.
|
|
@@ -3,9 +3,6 @@ import type { Logger } from "../../loggers.js";
|
|
|
3
3
|
import type { Options } from "../options.js";
|
|
4
4
|
/**
|
|
5
5
|
* Obtains option values from typedoc.json
|
|
6
|
-
*
|
|
7
|
-
* Changes need to happen here at some point. I think we should follow ESLint's new config
|
|
8
|
-
* system eventually: https://eslint.org/blog/2022/08/new-config-system-part-1/
|
|
9
6
|
*/
|
|
10
7
|
export declare class TypeDocReader implements OptionsReader {
|
|
11
8
|
/**
|
|
@@ -8,10 +8,9 @@ import { createRequire } from "module";
|
|
|
8
8
|
import { pathToFileURL } from "url";
|
|
9
9
|
/**
|
|
10
10
|
* Obtains option values from typedoc.json
|
|
11
|
-
*
|
|
12
|
-
* Changes need to happen here at some point. I think we should follow ESLint's new config
|
|
13
|
-
* system eventually: https://eslint.org/blog/2022/08/new-config-system-part-1/
|
|
14
11
|
*/
|
|
12
|
+
// Changes need to happen here at some point. I think we should follow ESLint's new config
|
|
13
|
+
// system eventually: https://eslint.org/blog/2022/08/new-config-system-part-1/
|
|
15
14
|
export class TypeDocReader {
|
|
16
15
|
/**
|
|
17
16
|
* Should run before the tsconfig reader so that it can specify a tsconfig file to read.
|
|
@@ -305,6 +305,12 @@ export function addTypeDocOptions(options) {
|
|
|
305
305
|
}
|
|
306
306
|
},
|
|
307
307
|
});
|
|
308
|
+
options.addDeclaration({
|
|
309
|
+
name: "ignoredHighlightLanguages",
|
|
310
|
+
help: (i18n) => i18n.help_ignoredHighlightLanguages(),
|
|
311
|
+
type: ParameterType.Array,
|
|
312
|
+
defaultValue: OptionDefaults.ignoredHighlightLanguages,
|
|
313
|
+
});
|
|
308
314
|
options.addDeclaration({
|
|
309
315
|
name: "typePrintWidth",
|
|
310
316
|
help: (i18n) => i18n.help_typePrintWidth(),
|