typedoc 0.22.7 → 0.22.11
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/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/dist/lib/application.js +5 -3
- package/dist/lib/converter/converter.js +26 -9
- package/dist/lib/converter/plugins/CategoryPlugin.js +9 -10
- package/dist/lib/converter/plugins/DecoratorPlugin.js +2 -2
- package/dist/lib/converter/plugins/ImplementsPlugin.js +6 -4
- package/dist/lib/converter/plugins/TypePlugin.js +3 -3
- package/dist/lib/converter/symbols.js +5 -2
- package/dist/lib/converter/types.js +7 -7
- package/dist/lib/models/reflections/declaration.d.ts +1 -1
- package/dist/lib/models/types.d.ts +21 -1
- package/dist/lib/models/types.js +39 -0
- package/dist/lib/output/index.d.ts +1 -0
- package/dist/lib/output/plugins/JavascriptIndexPlugin.js +1 -1
- package/dist/lib/output/renderer.d.ts +38 -10
- package/dist/lib/output/renderer.js +32 -17
- package/dist/lib/output/themes/MarkedPlugin.js +2 -2
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +4 -3
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +3 -2
- package/dist/lib/output/themes/default/layouts/default.js +10 -7
- package/dist/lib/output/themes/default/partials/analytics.js +9 -13
- package/dist/lib/output/themes/default/partials/anchor-icon.d.ts +2 -0
- package/dist/lib/output/themes/default/partials/anchor-icon.js +10 -0
- package/dist/lib/output/themes/default/partials/member.js +4 -2
- package/dist/lib/output/themes/default/partials/type.js +1 -1
- package/dist/lib/serialization/schema.d.ts +1 -1
- package/dist/lib/serialization/serializers/types/reference.js +4 -0
- package/dist/lib/utils/array.d.ts +11 -0
- package/dist/lib/utils/array.js +15 -1
- package/dist/lib/utils/general.d.ts +1 -0
- package/dist/lib/utils/general.js +14 -0
- package/dist/lib/utils/highlighter.js +12 -1
- package/dist/lib/utils/hooks.d.ts +56 -0
- package/dist/lib/utils/hooks.js +102 -0
- package/dist/lib/utils/index.d.ts +2 -1
- package/dist/lib/utils/index.js +4 -2
- package/dist/lib/utils/jsx.elements.d.ts +0 -1
- package/dist/lib/utils/options/declaration.d.ts +1 -0
- package/dist/lib/utils/options/options.d.ts +2 -0
- package/dist/lib/utils/options/sources/typedoc.js +4 -0
- package/dist/lib/utils/plugins.d.ts +1 -1
- package/dist/lib/utils/plugins.js +10 -4
- package/package.json +18 -18
- package/static/main.js +2 -2
- package/static/style.css +25 -0
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export { normalizePath } from "./lib/utils/fs";
|
|
|
5
5
|
export * from "./lib/models";
|
|
6
6
|
export { Converter, Context } from "./lib/converter";
|
|
7
7
|
export { Renderer, DefaultTheme, DefaultThemeRenderContext, UrlMapping, Theme, PageEvent, RendererEvent, MarkdownEvent, } from "./lib/output";
|
|
8
|
-
export type { RenderTemplate } from "./lib/output";
|
|
9
|
-
export { ArgumentsReader, BindOption, JSX, LogLevel, Logger, Options, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, } from "./lib/utils";
|
|
8
|
+
export type { RenderTemplate, RendererHooks } from "./lib/output";
|
|
9
|
+
export { ArgumentsReader, BindOption, JSX, LogLevel, Logger, Options, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, EventHooks, } from "./lib/utils";
|
|
10
10
|
export type { OptionsReader, TypeDocOptions, TypeDocOptionMap, ValidationOptions, TypeDocOptionValues, KeyToDeclaration, DeclarationOption, DeclarationOptionBase, StringDeclarationOption, NumberDeclarationOption, BooleanDeclarationOption, ArrayDeclarationOption, MixedDeclarationOption, MapDeclarationOption, FlagsDeclarationOption, DeclarationOptionToOptionType, SortStrategy, ParameterTypeToOptionTypeMap, DocumentationEntryPoint, } from "./lib/utils";
|
|
11
11
|
export type { EventMap, EventCallback } from "./lib/utils/events";
|
|
12
12
|
export { JSONOutput, Serializer, SerializerComponent, SerializeEvent, } from "./lib/serialization";
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.TypeScript = exports.SerializeEvent = exports.SerializerComponent = exports.Serializer = exports.JSONOutput = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.BindOption = exports.ArgumentsReader = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.normalizePath = exports.resetReflectionID = exports.Event = exports.EventDispatcher = exports.Application = void 0;
|
|
13
|
+
exports.TypeScript = exports.SerializeEvent = exports.SerializerComponent = exports.Serializer = exports.JSONOutput = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.BindOption = exports.ArgumentsReader = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.normalizePath = exports.resetReflectionID = exports.Event = exports.EventDispatcher = exports.Application = void 0;
|
|
14
14
|
var application_1 = require("./lib/application");
|
|
15
15
|
Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return application_1.Application; } });
|
|
16
16
|
var events_1 = require("./lib/utils/events");
|
|
@@ -45,6 +45,7 @@ Object.defineProperty(exports, "ParameterType", { enumerable: true, get: functio
|
|
|
45
45
|
Object.defineProperty(exports, "TSConfigReader", { enumerable: true, get: function () { return utils_1.TSConfigReader; } });
|
|
46
46
|
Object.defineProperty(exports, "TypeDocReader", { enumerable: true, get: function () { return utils_1.TypeDocReader; } });
|
|
47
47
|
Object.defineProperty(exports, "EntryPointStrategy", { enumerable: true, get: function () { return utils_1.EntryPointStrategy; } });
|
|
48
|
+
Object.defineProperty(exports, "EventHooks", { enumerable: true, get: function () { return utils_1.EventHooks; } });
|
|
48
49
|
var serialization_1 = require("./lib/serialization");
|
|
49
50
|
Object.defineProperty(exports, "JSONOutput", { enumerable: true, get: function () { return serialization_1.JSONOutput; } });
|
|
50
51
|
Object.defineProperty(exports, "Serializer", { enumerable: true, get: function () { return serialization_1.Serializer; } });
|
package/dist/lib/application.js
CHANGED
|
@@ -21,6 +21,7 @@ const exports_1 = require("./validation/exports");
|
|
|
21
21
|
const assert_1 = require("assert");
|
|
22
22
|
const entry_point_1 = require("./utils/entry-point");
|
|
23
23
|
const paths_1 = require("./utils/paths");
|
|
24
|
+
const general_1 = require("./utils/general");
|
|
24
25
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
25
26
|
const packageInfo = require("../../package.json");
|
|
26
27
|
const supportedVersionMajorMinor = packageInfo.peerDependencies.typescript
|
|
@@ -79,9 +80,7 @@ let Application = Application_1 = class Application extends component_1.Childabl
|
|
|
79
80
|
this.options.setLogger(this.logger);
|
|
80
81
|
}
|
|
81
82
|
this.logger.level = this.options.getValue("logLevel");
|
|
82
|
-
const plugins =
|
|
83
|
-
? this.options.getValue("plugin")
|
|
84
|
-
: (0, index_2.discoverNpmPlugins)(this);
|
|
83
|
+
const plugins = (0, index_2.discoverPlugins)(this);
|
|
85
84
|
(0, index_2.loadPlugins)(this, plugins);
|
|
86
85
|
this.options.reset();
|
|
87
86
|
for (const [key, val] of Object.entries(options)) {
|
|
@@ -94,6 +93,9 @@ let Application = Application_1 = class Application extends component_1.Childabl
|
|
|
94
93
|
}
|
|
95
94
|
}
|
|
96
95
|
this.options.read(this.logger);
|
|
96
|
+
if ((0, general_1.hasBeenLoadedMultipleTimes)()) {
|
|
97
|
+
this.logger.warn(`TypeDoc has been loaded multiple times. This is commonly caused by plugins which have their own installation of TypeDoc. This will likely break things.`);
|
|
98
|
+
}
|
|
97
99
|
}
|
|
98
100
|
/**
|
|
99
101
|
* Return the application / root component instance.
|
|
@@ -354,6 +354,7 @@ function getSymbolForModuleLike(context, node) {
|
|
|
354
354
|
}
|
|
355
355
|
function getExports(context, node, symbol) {
|
|
356
356
|
var _a;
|
|
357
|
+
let result;
|
|
357
358
|
// The generated docs aren't great, but you really ought not be using
|
|
358
359
|
// this in the first place... so it's better than nothing.
|
|
359
360
|
const exportEq = (_a = symbol === null || symbol === void 0 ? void 0 : symbol.exports) === null || _a === void 0 ? void 0 : _a.get("export=");
|
|
@@ -361,21 +362,37 @@ function getExports(context, node, symbol) {
|
|
|
361
362
|
// JS users might also have exported types here.
|
|
362
363
|
// We need to filter for types because otherwise static methods can show up as both
|
|
363
364
|
// members of the export= class and as functions if a class is directly exported.
|
|
364
|
-
|
|
365
|
+
result = [exportEq].concat(context.checker
|
|
365
366
|
.getExportsOfModule(symbol)
|
|
366
367
|
.filter((s) => !(0, enum_1.hasAnyFlag)(s.flags, ts.SymbolFlags.Prototype | ts.SymbolFlags.Value)));
|
|
367
368
|
}
|
|
368
|
-
if (symbol) {
|
|
369
|
-
|
|
369
|
+
else if (symbol) {
|
|
370
|
+
result = context.checker
|
|
370
371
|
.getExportsOfModule(symbol)
|
|
371
372
|
.filter((s) => !(0, enum_1.hasAllFlags)(s.flags, ts.SymbolFlags.Prototype));
|
|
372
373
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
374
|
+
else {
|
|
375
|
+
// Global file with no inferred top level symbol, get all symbols declared in this file.
|
|
376
|
+
const sourceFile = node.getSourceFile();
|
|
377
|
+
result = context.checker
|
|
378
|
+
.getSymbolsInScope(node, ts.SymbolFlags.ModuleMember)
|
|
379
|
+
.filter((s) => {
|
|
380
|
+
var _a;
|
|
381
|
+
return (_a = s
|
|
382
|
+
.getDeclarations()) === null || _a === void 0 ? void 0 : _a.some((d) => d.getSourceFile() === sourceFile);
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
// Put symbols named "default" last, #1795
|
|
386
|
+
result.sort((a, b) => {
|
|
387
|
+
if (a.name === "default") {
|
|
388
|
+
return 1;
|
|
389
|
+
}
|
|
390
|
+
else if (b.name === "default") {
|
|
391
|
+
return -1;
|
|
392
|
+
}
|
|
393
|
+
return 0;
|
|
394
|
+
});
|
|
395
|
+
return result;
|
|
379
396
|
}
|
|
380
397
|
function isDirectExport(symbol, file) {
|
|
381
398
|
var _a, _b;
|
|
@@ -143,9 +143,11 @@ let CategoryPlugin = CategoryPlugin_1 = class CategoryPlugin extends components_
|
|
|
143
143
|
* @returns The category the reflection belongs to
|
|
144
144
|
*/
|
|
145
145
|
static getCategories(reflection) {
|
|
146
|
-
var _a, _b;
|
|
146
|
+
var _a, _b, _c;
|
|
147
147
|
function extractCategoryTag(comment) {
|
|
148
148
|
const categories = new Set();
|
|
149
|
+
if (!comment)
|
|
150
|
+
return categories;
|
|
149
151
|
const tags = comment.tags;
|
|
150
152
|
const commentTags = [];
|
|
151
153
|
tags.forEach((tag) => {
|
|
@@ -162,23 +164,20 @@ let CategoryPlugin = CategoryPlugin_1 = class CategoryPlugin extends components_
|
|
|
162
164
|
comment.tags = commentTags;
|
|
163
165
|
return categories;
|
|
164
166
|
}
|
|
165
|
-
|
|
167
|
+
let categories = new Set();
|
|
166
168
|
if (reflection.comment) {
|
|
167
|
-
|
|
169
|
+
categories = extractCategoryTag(reflection.comment);
|
|
168
170
|
}
|
|
169
|
-
else if (reflection
|
|
170
|
-
reflection.signatures) {
|
|
171
|
+
else if (reflection.signatures) {
|
|
171
172
|
for (const sig of reflection.signatures) {
|
|
172
|
-
for (const cat of sig.comment
|
|
173
|
-
? extractCategoryTag(sig.comment)
|
|
174
|
-
: []) {
|
|
173
|
+
for (const cat of extractCategoryTag(sig.comment)) {
|
|
175
174
|
categories.add(cat);
|
|
176
175
|
}
|
|
177
176
|
}
|
|
178
177
|
}
|
|
179
|
-
if (reflection.
|
|
180
|
-
((_a = reflection.type) === null || _a === void 0 ? void 0 : _a.type) === "reflection") {
|
|
178
|
+
if (((_a = reflection.type) === null || _a === void 0 ? void 0 : _a.type) === "reflection") {
|
|
181
179
|
(_b = reflection.type.declaration.comment) === null || _b === void 0 ? void 0 : _b.removeTags("category");
|
|
180
|
+
(_c = reflection.type.declaration.signatures) === null || _c === void 0 ? void 0 : _c.forEach((s) => { var _a; return (_a = s.comment) === null || _a === void 0 ? void 0 : _a.removeTags("category"); });
|
|
182
181
|
}
|
|
183
182
|
return categories;
|
|
184
183
|
}
|
|
@@ -82,7 +82,7 @@ let DecoratorPlugin = class DecoratorPlugin extends components_1.ConverterCompon
|
|
|
82
82
|
};
|
|
83
83
|
const type = context.checker.getTypeAtLocation(identifier);
|
|
84
84
|
if (type && type.symbol) {
|
|
85
|
-
info.type =
|
|
85
|
+
info.type = types_1.ReferenceType.createSymbolReference(context.resolveAliasedSymbol(type.symbol), context, info.name);
|
|
86
86
|
if (callExpression && callExpression.arguments) {
|
|
87
87
|
const signature = context.checker.getResolvedSignature(callExpression);
|
|
88
88
|
if (signature) {
|
|
@@ -90,7 +90,7 @@ let DecoratorPlugin = class DecoratorPlugin extends components_1.ConverterCompon
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
const usages = (_a = this.usages.get(type.symbol)) !== null && _a !== void 0 ? _a : [];
|
|
93
|
-
usages.push(
|
|
93
|
+
usages.push(types_1.ReferenceType.createResolvedReference(reflection.name, reflection, context.project));
|
|
94
94
|
this.usages.set(type.symbol, usages);
|
|
95
95
|
}
|
|
96
96
|
(_b = reflection.decorators) !== null && _b !== void 0 ? _b : (reflection.decorators = []);
|
|
@@ -63,7 +63,8 @@ let ImplementsPlugin = class ImplementsPlugin extends components_1.ConverterComp
|
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
const interfaceMemberName = interfaceReflection.name + "." + interfaceMember.name;
|
|
66
|
-
classMember.implementationOf =
|
|
66
|
+
classMember.implementationOf =
|
|
67
|
+
types_1.ReferenceType.createResolvedReference(interfaceMemberName, interfaceMember, context.project);
|
|
67
68
|
(0, reflections_1.copyComment)(classMember, interfaceMember);
|
|
68
69
|
if (interfaceMember.kindOf(index_1.ReflectionKind.Property) &&
|
|
69
70
|
classMember.kindOf(index_1.ReflectionKind.Accessor)) {
|
|
@@ -83,7 +84,8 @@ let ImplementsPlugin = class ImplementsPlugin extends components_1.ConverterComp
|
|
|
83
84
|
classMember.signatures) {
|
|
84
85
|
for (const [clsSig, intSig] of (0, array_1.zip)(classMember.signatures, interfaceMember.signatures)) {
|
|
85
86
|
if (clsSig.implementationOf) {
|
|
86
|
-
clsSig.implementationOf =
|
|
87
|
+
clsSig.implementationOf =
|
|
88
|
+
types_1.ReferenceType.createResolvedReference(clsSig.implementationOf.name, intSig, context.project);
|
|
87
89
|
}
|
|
88
90
|
(0, reflections_1.copyComment)(clsSig, intSig);
|
|
89
91
|
}
|
|
@@ -107,10 +109,10 @@ let ImplementsPlugin = class ImplementsPlugin extends components_1.ConverterComp
|
|
|
107
109
|
? "overwrites"
|
|
108
110
|
: "inheritedFrom";
|
|
109
111
|
for (const [childSig, parentSig] of (0, array_1.zip)((_d = child.signatures) !== null && _d !== void 0 ? _d : [], (_e = parentMember.signatures) !== null && _e !== void 0 ? _e : [])) {
|
|
110
|
-
childSig[key] =
|
|
112
|
+
childSig[key] = types_1.ReferenceType.createResolvedReference(`${parent.name}.${parentMember.name}`, parentSig, context.project);
|
|
111
113
|
(0, reflections_1.copyComment)(childSig, parentSig);
|
|
112
114
|
}
|
|
113
|
-
child[key] =
|
|
115
|
+
child[key] = types_1.ReferenceType.createResolvedReference(`${parent.name}.${parentMember.name}`, parentMember, context.project);
|
|
114
116
|
(0, reflections_1.copyComment)(child, parentMember);
|
|
115
117
|
}
|
|
116
118
|
}
|
|
@@ -43,14 +43,14 @@ let TypePlugin = class TypePlugin extends components_1.ConverterComponent {
|
|
|
43
43
|
if (!target.implementedBy) {
|
|
44
44
|
target.implementedBy = [];
|
|
45
45
|
}
|
|
46
|
-
target.implementedBy.push(
|
|
46
|
+
target.implementedBy.push(types_1.ReferenceType.createResolvedReference(reflection.name, reflection, context.project));
|
|
47
47
|
});
|
|
48
48
|
walk(reflection.extendedTypes, (target) => {
|
|
49
49
|
this.postpone(target);
|
|
50
50
|
if (!target.extendedBy) {
|
|
51
51
|
target.extendedBy = [];
|
|
52
52
|
}
|
|
53
|
-
target.extendedBy.push(
|
|
53
|
+
target.extendedBy.push(types_1.ReferenceType.createResolvedReference(reflection.name, reflection, context.project));
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
function walk(types, callback) {
|
|
@@ -101,7 +101,7 @@ let TypePlugin = class TypePlugin extends components_1.ConverterComponent {
|
|
|
101
101
|
push(reflection.extendedTypes);
|
|
102
102
|
}
|
|
103
103
|
push([
|
|
104
|
-
|
|
104
|
+
types_1.ReferenceType.createResolvedReference(reflection.name, reflection, context.project),
|
|
105
105
|
]);
|
|
106
106
|
hierarchy.isTarget = true;
|
|
107
107
|
if (reflection.extendedBy) {
|
|
@@ -99,7 +99,10 @@ function convertSymbol(context, symbol, exportSymbol) {
|
|
|
99
99
|
// This might be here if a namespace is declared several times.
|
|
100
100
|
flags = (0, enum_1.removeFlag)(flags, ts.SymbolFlags.ValueModule);
|
|
101
101
|
}
|
|
102
|
-
if ((0, enum_1.
|
|
102
|
+
if ((0, enum_1.hasAnyFlag)(symbol.flags, ts.SymbolFlags.Method |
|
|
103
|
+
ts.SymbolFlags.Interface |
|
|
104
|
+
ts.SymbolFlags.Class |
|
|
105
|
+
ts.SymbolFlags.Variable)) {
|
|
103
106
|
// This happens when someone declares an object with methods:
|
|
104
107
|
// { methodProperty() {} }
|
|
105
108
|
flags = (0, enum_1.removeFlag)(flags, ts.SymbolFlags.Property);
|
|
@@ -528,7 +531,7 @@ function convertAccessor(context, symbol, exportSymbol) {
|
|
|
528
531
|
function isInherited(context, symbol) {
|
|
529
532
|
var _a;
|
|
530
533
|
const parentSymbol = context.project.getSymbolFromReflection(context.scope);
|
|
531
|
-
assert(parentSymbol);
|
|
534
|
+
assert(parentSymbol, `No parent symbol found for ${symbol.name} in ${context.scope.name}`);
|
|
532
535
|
return (((_a = parentSymbol
|
|
533
536
|
.getDeclarations()) === null || _a === void 0 ? void 0 : _a.some((d) => { var _a; return (_a = symbol.getDeclarations()) === null || _a === void 0 ? void 0 : _a.some((d2) => d2.parent === d); })) === false);
|
|
534
537
|
}
|
|
@@ -167,7 +167,7 @@ const exprWithTypeArgsConverter = {
|
|
|
167
167
|
return convertType(context, context.checker.getTypeAtLocation(node));
|
|
168
168
|
}
|
|
169
169
|
const parameters = (_b = (_a = node.typeArguments) === null || _a === void 0 ? void 0 : _a.map((type) => convertType(context, type))) !== null && _b !== void 0 ? _b : [];
|
|
170
|
-
const ref =
|
|
170
|
+
const ref = models_1.ReferenceType.createSymbolReference(context.resolveAliasedSymbol(targetSymbol), context);
|
|
171
171
|
ref.typeArguments = parameters;
|
|
172
172
|
return ref;
|
|
173
173
|
},
|
|
@@ -213,12 +213,12 @@ const importType = {
|
|
|
213
213
|
const name = (_b = (_a = node.qualifier) === null || _a === void 0 ? void 0 : _a.getText()) !== null && _b !== void 0 ? _b : "__module";
|
|
214
214
|
const symbol = context.checker.getSymbolAtLocation(node);
|
|
215
215
|
assert(symbol, "Missing symbol when converting import type node");
|
|
216
|
-
return
|
|
216
|
+
return models_1.ReferenceType.createSymbolReference(context.resolveAliasedSymbol(symbol), context, name);
|
|
217
217
|
},
|
|
218
218
|
convertType(context, type) {
|
|
219
219
|
const symbol = type.getSymbol();
|
|
220
220
|
assert(symbol, "Missing symbol when converting import type"); // Should be a compiler error
|
|
221
|
-
return
|
|
221
|
+
return models_1.ReferenceType.createSymbolReference(context.resolveAliasedSymbol(symbol), context, "__module");
|
|
222
222
|
},
|
|
223
223
|
};
|
|
224
224
|
const indexedAccessConverter = {
|
|
@@ -371,12 +371,12 @@ const queryConverter = {
|
|
|
371
371
|
// on a variable typed as `any` with a name that doesn't exist.
|
|
372
372
|
return new models_1.QueryType(models_1.ReferenceType.createBrokenReference(node.exprName.getText(), context.project));
|
|
373
373
|
}
|
|
374
|
-
return new models_1.QueryType(
|
|
374
|
+
return new models_1.QueryType(models_1.ReferenceType.createSymbolReference(context.resolveAliasedSymbol(querySymbol), context, node.exprName.getText()));
|
|
375
375
|
},
|
|
376
376
|
convertType(context, type) {
|
|
377
377
|
const symbol = type.getSymbol();
|
|
378
378
|
assert(symbol, `Query type failed to get a symbol for: ${context.checker.typeToString(type)}. This is a bug.`);
|
|
379
|
-
return new models_1.QueryType(
|
|
379
|
+
return new models_1.QueryType(models_1.ReferenceType.createSymbolReference(context.resolveAliasedSymbol(symbol), context));
|
|
380
380
|
},
|
|
381
381
|
};
|
|
382
382
|
const referenceConverter = {
|
|
@@ -389,7 +389,7 @@ const referenceConverter = {
|
|
|
389
389
|
}
|
|
390
390
|
const symbol = context.expectSymbolAtLocation(node.typeName);
|
|
391
391
|
const name = node.typeName.getText();
|
|
392
|
-
const type =
|
|
392
|
+
const type = models_1.ReferenceType.createSymbolReference(context.resolveAliasedSymbol(symbol), context, name);
|
|
393
393
|
type.typeArguments = (_c = node.typeArguments) === null || _c === void 0 ? void 0 : _c.map((type) => convertType(context, type));
|
|
394
394
|
return type;
|
|
395
395
|
},
|
|
@@ -401,7 +401,7 @@ const referenceConverter = {
|
|
|
401
401
|
// created within a mapped type, `K` in: `{ [K in T]: string }`
|
|
402
402
|
return models_1.ReferenceType.createBrokenReference(context.checker.typeToString(type), context.project);
|
|
403
403
|
}
|
|
404
|
-
const ref =
|
|
404
|
+
const ref = models_1.ReferenceType.createSymbolReference(context.resolveAliasedSymbol(symbol), context);
|
|
405
405
|
ref.typeArguments = (_b = (type.aliasSymbol ? type.aliasTypeArguments : type.typeArguments)) === null || _b === void 0 ? void 0 : _b.map((ref) => convertType(context, ref));
|
|
406
406
|
return ref;
|
|
407
407
|
},
|
|
@@ -48,7 +48,7 @@ export declare class DeclarationReflection extends ContainerReflection {
|
|
|
48
48
|
/**
|
|
49
49
|
* A list of call signatures attached to this declaration.
|
|
50
50
|
*
|
|
51
|
-
* TypeDoc creates one declaration per function that may contain
|
|
51
|
+
* TypeDoc creates one declaration per function that may contain one or more
|
|
52
52
|
* signature reflections.
|
|
53
53
|
*/
|
|
54
54
|
signatures?: SignatureReflection[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type * as ts from "typescript";
|
|
2
|
+
import type { Context } from "../converter";
|
|
2
3
|
import { Reflection } from "./reflections/abstract";
|
|
3
4
|
import type { DeclarationReflection } from "./reflections/declaration";
|
|
4
5
|
import type { ProjectReflection } from "./reflections/project";
|
|
@@ -247,10 +248,29 @@ export declare class ReferenceType extends Type {
|
|
|
247
248
|
* The resolved reflection.
|
|
248
249
|
*/
|
|
249
250
|
get reflection(): Reflection | undefined;
|
|
251
|
+
/**
|
|
252
|
+
* Don't use this if at all possible. It will eventually go away since models may not
|
|
253
|
+
* retain information from the original TS objects to enable documentation generation from
|
|
254
|
+
* previously generated JSON.
|
|
255
|
+
* @internal
|
|
256
|
+
*/
|
|
250
257
|
getSymbol(): ts.Symbol | undefined;
|
|
258
|
+
/**
|
|
259
|
+
* The fully qualified name of the referenced type, relative to the file it is defined in.
|
|
260
|
+
* This will usually be the same as `name`, unless namespaces are used.
|
|
261
|
+
* Will only be set for `ReferenceType`s pointing to a symbol within `node_modules`.
|
|
262
|
+
*/
|
|
263
|
+
qualifiedName?: string;
|
|
264
|
+
/**
|
|
265
|
+
* The package that this type is referencing.
|
|
266
|
+
* Will only be set for `ReferenceType`s pointing to a symbol within `node_modules`.
|
|
267
|
+
*/
|
|
268
|
+
package?: string;
|
|
251
269
|
private _target;
|
|
252
270
|
private _project;
|
|
253
|
-
constructor(
|
|
271
|
+
private constructor();
|
|
272
|
+
static createResolvedReference(name: string, target: Reflection | number, project: ProjectReflection | null): ReferenceType;
|
|
273
|
+
static createSymbolReference(symbol: ts.Symbol, context: Context, name?: string): ReferenceType;
|
|
254
274
|
/** @internal this is used for type parameters, which don't actually point to something */
|
|
255
275
|
static createBrokenReference(name: string, project: ProjectReflection): ReferenceType;
|
|
256
276
|
toString(): string;
|
package/dist/lib/models/types.js
CHANGED
|
@@ -430,12 +430,51 @@ class ReferenceType extends Type {
|
|
|
430
430
|
this._target = resolved.id;
|
|
431
431
|
return resolved;
|
|
432
432
|
}
|
|
433
|
+
/**
|
|
434
|
+
* Don't use this if at all possible. It will eventually go away since models may not
|
|
435
|
+
* retain information from the original TS objects to enable documentation generation from
|
|
436
|
+
* previously generated JSON.
|
|
437
|
+
* @internal
|
|
438
|
+
*/
|
|
433
439
|
getSymbol() {
|
|
434
440
|
if (typeof this._target === "number") {
|
|
435
441
|
return;
|
|
436
442
|
}
|
|
437
443
|
return this._target;
|
|
438
444
|
}
|
|
445
|
+
static createResolvedReference(name, target, project) {
|
|
446
|
+
return new ReferenceType(name, target, project);
|
|
447
|
+
}
|
|
448
|
+
static createSymbolReference(symbol, context, name) {
|
|
449
|
+
var _a, _b;
|
|
450
|
+
const ref = new ReferenceType(name !== null && name !== void 0 ? name : symbol.name, symbol, context.project);
|
|
451
|
+
const symbolPath = (_b = (_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.getSourceFile().fileName.replace(/\\/g, "/");
|
|
452
|
+
if (!symbolPath)
|
|
453
|
+
return ref;
|
|
454
|
+
let startIndex = symbolPath.indexOf("node_modules/");
|
|
455
|
+
if (startIndex === -1)
|
|
456
|
+
return ref;
|
|
457
|
+
startIndex += "node_modules/".length;
|
|
458
|
+
let stopIndex = symbolPath.indexOf("/", startIndex);
|
|
459
|
+
// Scoped package, e.g. `@types/node`
|
|
460
|
+
if (symbolPath[startIndex] === "@") {
|
|
461
|
+
stopIndex = symbolPath.indexOf("/", stopIndex + 1);
|
|
462
|
+
}
|
|
463
|
+
const packageName = symbolPath.substring(startIndex, stopIndex);
|
|
464
|
+
ref.package = packageName;
|
|
465
|
+
const qualifiedName = context.checker.getFullyQualifiedName(symbol);
|
|
466
|
+
// I think this is less bad than depending on symbol.parent...
|
|
467
|
+
// https://github.com/microsoft/TypeScript/issues/38344
|
|
468
|
+
// It will break if someone names a directory with a quote in it, but so will lots
|
|
469
|
+
// of other things including other parts of TypeDoc. Until it *actually* breaks someone...
|
|
470
|
+
if (qualifiedName.startsWith('"')) {
|
|
471
|
+
ref.qualifiedName = qualifiedName.substring(qualifiedName.indexOf('".', 1) + 2);
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
ref.qualifiedName = qualifiedName;
|
|
475
|
+
}
|
|
476
|
+
return ref;
|
|
477
|
+
}
|
|
439
478
|
/** @internal this is used for type parameters, which don't actually point to something */
|
|
440
479
|
static createBrokenReference(name, project) {
|
|
441
480
|
return new ReferenceType(name, -1, project);
|
|
@@ -2,6 +2,7 @@ export { PageEvent, RendererEvent, MarkdownEvent } from "./events";
|
|
|
2
2
|
export { UrlMapping } from "./models/UrlMapping";
|
|
3
3
|
export type { RenderTemplate } from "./models/UrlMapping";
|
|
4
4
|
export { Renderer } from "./renderer";
|
|
5
|
+
export type { RendererHooks } from "./renderer";
|
|
5
6
|
export { Theme } from "./theme";
|
|
6
7
|
export { DefaultTheme } from "./themes/default/DefaultTheme";
|
|
7
8
|
export { DefaultThemeRenderContext } from "./themes/default/DefaultThemeRenderContext";
|
|
@@ -83,7 +83,7 @@ let JavascriptIndexPlugin = class JavascriptIndexPlugin extends components_1.Ren
|
|
|
83
83
|
rows,
|
|
84
84
|
index,
|
|
85
85
|
});
|
|
86
|
-
(0, utils_1.writeFileSync)(jsonFileName, `window.searchData = ${jsonData}
|
|
86
|
+
(0, utils_1.writeFileSync)(jsonFileName, `window.searchData = JSON.parse(${JSON.stringify(jsonData)});`);
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
JavascriptIndexPlugin = __decorate([
|
|
@@ -1,18 +1,35 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Holds all logic used render and output the final documentation.
|
|
3
|
-
*
|
|
4
|
-
* The {@link Renderer} class is the central controller within this namespace. When invoked it creates
|
|
5
|
-
* an instance of {@link Theme} which defines the layout of the documentation and fires a
|
|
6
|
-
* series of {@link RendererEvent} events. Instances of {@link BasePlugin} can listen to these events and
|
|
7
|
-
* alter the generated output.
|
|
8
|
-
*/
|
|
9
|
-
import type * as ts from "typescript";
|
|
10
1
|
import type { Application } from "../application";
|
|
11
2
|
import type { Theme } from "./theme";
|
|
12
3
|
import type { ProjectReflection } from "../models/reflections/project";
|
|
13
4
|
import { RendererComponent } from "./components";
|
|
14
5
|
import { ChildableComponent } from "../utils/component";
|
|
6
|
+
import { EventHooks } from "../utils";
|
|
15
7
|
import type { Theme as ShikiTheme } from "shiki";
|
|
8
|
+
import { ReferenceType } from "../models";
|
|
9
|
+
import type { JsxElement } from "../utils/jsx.elements";
|
|
10
|
+
import type { DefaultThemeRenderContext } from "./themes/default/DefaultThemeRenderContext";
|
|
11
|
+
/**
|
|
12
|
+
* Describes the hooks available to inject output in the default theme.
|
|
13
|
+
* If the available hooks don't let you put something where you'd like, please open an issue!
|
|
14
|
+
*/
|
|
15
|
+
export interface RendererHooks {
|
|
16
|
+
/**
|
|
17
|
+
* Applied immediately after the opening `<head>` tag.
|
|
18
|
+
*/
|
|
19
|
+
"head.begin": [DefaultThemeRenderContext];
|
|
20
|
+
/**
|
|
21
|
+
* Applied immediately before the closing `</head>` tag.
|
|
22
|
+
*/
|
|
23
|
+
"head.end": [DefaultThemeRenderContext];
|
|
24
|
+
/**
|
|
25
|
+
* Applied immediately after the opening `<body>` tag.
|
|
26
|
+
*/
|
|
27
|
+
"body.begin": [DefaultThemeRenderContext];
|
|
28
|
+
/**
|
|
29
|
+
* Applied immediately before the closing `</body>` tag.
|
|
30
|
+
*/
|
|
31
|
+
"body.end": [DefaultThemeRenderContext];
|
|
32
|
+
}
|
|
16
33
|
/**
|
|
17
34
|
* The renderer processes a {@link ProjectReflection} using a {@link Theme} instance and writes
|
|
18
35
|
* the emitted html documents to a output directory. You can specify which theme should be used
|
|
@@ -56,11 +73,22 @@ export declare class Renderer extends ChildableComponent<Application, RendererCo
|
|
|
56
73
|
* The theme that is used to render the documentation.
|
|
57
74
|
*/
|
|
58
75
|
theme?: Theme;
|
|
76
|
+
/**
|
|
77
|
+
* Hooks which will be called when rendering pages.
|
|
78
|
+
* Note:
|
|
79
|
+
* - Hooks added during output will be discarded at the end of rendering.
|
|
80
|
+
* - Hooks added during a page render will be discarded at the end of that page's render.
|
|
81
|
+
*
|
|
82
|
+
* See {@link RendererHooks} for a description of each available hook, and when it will be called.
|
|
83
|
+
*/
|
|
84
|
+
hooks: EventHooks<RendererHooks, JsxElement>;
|
|
59
85
|
/** @internal */
|
|
60
86
|
themeName: string;
|
|
61
87
|
/** @internal */
|
|
62
88
|
cleanOutputDir: boolean;
|
|
63
89
|
/** @internal */
|
|
90
|
+
cname: string;
|
|
91
|
+
/** @internal */
|
|
64
92
|
gaID: string;
|
|
65
93
|
/** @internal */
|
|
66
94
|
gaSite: string;
|
|
@@ -99,7 +127,7 @@ export declare class Renderer extends ChildableComponent<Application, RendererCo
|
|
|
99
127
|
* symbols so that we don't need to keep the program around forever.
|
|
100
128
|
* @internal
|
|
101
129
|
*/
|
|
102
|
-
attemptExternalResolution(
|
|
130
|
+
attemptExternalResolution(type: ReferenceType): string | undefined;
|
|
103
131
|
/**
|
|
104
132
|
* Render the given project reflection to the specified output directory.
|
|
105
133
|
*
|
|
@@ -7,6 +7,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.Renderer = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* Holds all logic used render and output the final documentation.
|
|
12
|
+
*
|
|
13
|
+
* The {@link Renderer} class is the central controller within this namespace. When invoked it creates
|
|
14
|
+
* an instance of {@link Theme} which defines the layout of the documentation and fires a
|
|
15
|
+
* series of {@link RendererEvent} events. Instances of {@link BasePlugin} can listen to these events and
|
|
16
|
+
* alter the generated output.
|
|
17
|
+
*/
|
|
10
18
|
const fs = require("fs");
|
|
11
19
|
const path = require("path");
|
|
12
20
|
const events_1 = require("./events");
|
|
@@ -52,6 +60,15 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
|
|
|
52
60
|
["default", DefaultTheme_1.DefaultTheme],
|
|
53
61
|
]);
|
|
54
62
|
this.unknownSymbolResolvers = new Map();
|
|
63
|
+
/**
|
|
64
|
+
* Hooks which will be called when rendering pages.
|
|
65
|
+
* Note:
|
|
66
|
+
* - Hooks added during output will be discarded at the end of rendering.
|
|
67
|
+
* - Hooks added during a page render will be discarded at the end of that page's render.
|
|
68
|
+
*
|
|
69
|
+
* See {@link RendererHooks} for a description of each available hook, and when it will be called.
|
|
70
|
+
*/
|
|
71
|
+
this.hooks = new utils_1.EventHooks();
|
|
55
72
|
}
|
|
56
73
|
/**
|
|
57
74
|
* Define a new theme that can be used to render output.
|
|
@@ -93,26 +110,13 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
|
|
|
93
110
|
* symbols so that we don't need to keep the program around forever.
|
|
94
111
|
* @internal
|
|
95
112
|
*/
|
|
96
|
-
attemptExternalResolution(
|
|
97
|
-
|
|
98
|
-
const symbolPath = (_b = (_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.getSourceFile().fileName.replace(/\\/g, "/");
|
|
99
|
-
if (!symbolPath) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
let startIndex = symbolPath.indexOf("node_modules/");
|
|
103
|
-
if (startIndex === -1) {
|
|
113
|
+
attemptExternalResolution(type) {
|
|
114
|
+
if (!type.qualifiedName || !type.package) {
|
|
104
115
|
return;
|
|
105
116
|
}
|
|
106
|
-
|
|
107
|
-
let stopIndex = symbolPath.indexOf("/", startIndex);
|
|
108
|
-
// Scoped package, e.g. `@types/node`
|
|
109
|
-
if (symbolPath[startIndex] === "@") {
|
|
110
|
-
stopIndex = symbolPath.indexOf("/", stopIndex + 1);
|
|
111
|
-
}
|
|
112
|
-
const packageName = symbolPath.substring(startIndex, stopIndex);
|
|
113
|
-
const resolvers = this.unknownSymbolResolvers.get(packageName);
|
|
117
|
+
const resolvers = this.unknownSymbolResolvers.get(type.package);
|
|
114
118
|
for (const resolver of resolvers || []) {
|
|
115
|
-
const resolved = resolver(
|
|
119
|
+
const resolved = resolver(type.qualifiedName);
|
|
116
120
|
if (resolved)
|
|
117
121
|
return resolved;
|
|
118
122
|
}
|
|
@@ -124,6 +128,7 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
|
|
|
124
128
|
* @param outputDirectory The path of the directory the documentation should be rendered to.
|
|
125
129
|
*/
|
|
126
130
|
async render(project, outputDirectory) {
|
|
131
|
+
const momento = this.hooks.saveMomento();
|
|
127
132
|
const start = Date.now();
|
|
128
133
|
await (0, highlighter_1.loadHighlighter)(this.lightTheme, this.darkTheme);
|
|
129
134
|
this.application.logger.verbose(`Renderer: Loading highlighter took ${Date.now() - start}ms`);
|
|
@@ -141,6 +146,7 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
|
|
|
141
146
|
this.trigger(events_1.RendererEvent.END, output);
|
|
142
147
|
}
|
|
143
148
|
this.theme = void 0;
|
|
149
|
+
this.hooks.restoreMomento(momento);
|
|
144
150
|
}
|
|
145
151
|
/**
|
|
146
152
|
* Render a single page.
|
|
@@ -149,8 +155,10 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
|
|
|
149
155
|
* @return TRUE if the page has been saved to disc, otherwise FALSE.
|
|
150
156
|
*/
|
|
151
157
|
renderDocument(page) {
|
|
158
|
+
const momento = this.hooks.saveMomento();
|
|
152
159
|
this.trigger(events_1.PageEvent.BEGIN, page);
|
|
153
160
|
if (page.isDefaultPrevented) {
|
|
161
|
+
this.hooks.restoreMomento(momento);
|
|
154
162
|
return false;
|
|
155
163
|
}
|
|
156
164
|
if (page.model instanceof models_1.Reflection) {
|
|
@@ -160,6 +168,7 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
|
|
|
160
168
|
throw new Error("Should be unreachable");
|
|
161
169
|
}
|
|
162
170
|
this.trigger(events_1.PageEvent.END, page);
|
|
171
|
+
this.hooks.restoreMomento(momento);
|
|
163
172
|
if (page.isDefaultPrevented) {
|
|
164
173
|
return false;
|
|
165
174
|
}
|
|
@@ -231,6 +240,9 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
|
|
|
231
240
|
return false;
|
|
232
241
|
}
|
|
233
242
|
}
|
|
243
|
+
if (this.cname) {
|
|
244
|
+
fs.writeFileSync(path.join(directory, "CNAME"), this.cname);
|
|
245
|
+
}
|
|
234
246
|
return true;
|
|
235
247
|
}
|
|
236
248
|
};
|
|
@@ -248,6 +260,9 @@ __decorate([
|
|
|
248
260
|
__decorate([
|
|
249
261
|
(0, utils_1.BindOption)("cleanOutputDir")
|
|
250
262
|
], Renderer.prototype, "cleanOutputDir", void 0);
|
|
263
|
+
__decorate([
|
|
264
|
+
(0, utils_1.BindOption)("cname")
|
|
265
|
+
], Renderer.prototype, "cname", void 0);
|
|
251
266
|
__decorate([
|
|
252
267
|
(0, utils_1.BindOption)("gaID")
|
|
253
268
|
], Renderer.prototype, "gaID", void 0);
|