typedoc 0.24.0-beta.7 → 0.24.0
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 +4 -0
- package/dist/index.js +17 -1
- package/dist/lib/converter/comments/discovery.js +1 -1
- package/dist/lib/converter/comments/index.d.ts +2 -1
- package/dist/lib/converter/comments/parser.js +32 -2
- package/dist/lib/converter/context.js +2 -2
- package/dist/lib/converter/converter.d.ts +6 -4
- package/dist/lib/converter/converter.js +9 -5
- package/dist/lib/converter/plugins/PackagePlugin.js +3 -1
- package/dist/lib/converter/symbols.js +9 -4
- package/dist/lib/converter/types.js +2 -2
- package/dist/lib/models/comments/comment.d.ts +2 -2
- package/dist/lib/models/comments/comment.js +26 -6
- package/dist/lib/models/reflections/declaration.d.ts +1 -1
- package/dist/lib/models/reflections/project.d.ts +0 -6
- package/dist/lib/models/reflections/project.js +0 -16
- package/dist/lib/models/types.js +2 -31
- package/dist/lib/output/components.d.ts +3 -3
- package/dist/lib/output/components.js +1 -5
- package/dist/lib/output/events.d.ts +22 -10
- package/dist/lib/output/events.js +14 -6
- package/dist/lib/output/plugins/JavascriptIndexPlugin.js +1 -3
- package/dist/lib/output/renderer.d.ts +12 -4
- package/dist/lib/output/renderer.js +3 -3
- package/dist/lib/output/theme.d.ts +2 -2
- package/dist/lib/output/themes/MarkedPlugin.d.ts +2 -2
- package/dist/lib/output/themes/MarkedPlugin.js +15 -12
- package/dist/lib/output/themes/default/DefaultTheme.d.ts +5 -5
- package/dist/lib/output/themes/default/DefaultTheme.js +58 -11
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +15 -13
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +9 -59
- package/dist/lib/output/themes/default/layouts/default.d.ts +2 -1
- package/dist/lib/output/themes/default/layouts/default.js +18 -12
- package/dist/lib/output/themes/default/partials/anchor-icon.d.ts +1 -1
- package/dist/lib/output/themes/default/partials/anchor-icon.js +5 -1
- package/dist/lib/output/themes/default/partials/footer.js +1 -1
- package/dist/lib/output/themes/default/partials/member.d.ts +1 -1
- package/dist/lib/output/themes/default/partials/member.js +22 -14
- package/dist/lib/output/themes/default/partials/members.group.js +3 -3
- package/dist/lib/output/themes/default/partials/navigation.d.ts +4 -3
- package/dist/lib/output/themes/default/partials/navigation.js +71 -74
- package/dist/lib/output/themes/default/partials/toolbar.js +2 -1
- package/dist/lib/serialization/schema.d.ts +1 -0
- package/dist/lib/serialization/schema.js +1 -0
- package/dist/lib/serialization/serializer.d.ts +1 -1
- package/dist/lib/utils/entry-point.d.ts +3 -3
- package/dist/lib/utils/entry-point.js +4 -4
- package/dist/lib/utils/fs.d.ts +5 -0
- package/dist/lib/utils/fs.js +35 -2
- package/dist/lib/utils/options/declaration.d.ts +14 -0
- package/dist/lib/utils/options/options.d.ts +5 -0
- package/dist/lib/utils/options/options.js +2 -2
- package/dist/lib/utils/options/sources/typedoc.js +14 -0
- package/package.json +1 -1
- package/static/main.js +3 -3
- package/static/style.css +186 -257
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ export { Application } from "./lib/application";
|
|
|
2
2
|
export { EventDispatcher, Event } from "./lib/utils/events";
|
|
3
3
|
export { resetReflectionID } from "./lib/models/reflections/abstract";
|
|
4
4
|
export { normalizePath } from "./lib/utils/fs";
|
|
5
|
+
/**
|
|
6
|
+
* All symbols documented under the Models namespace are also available in the root import.
|
|
7
|
+
*/
|
|
8
|
+
export * as Models from "./lib/models";
|
|
5
9
|
export * from "./lib/models";
|
|
6
10
|
export { Converter, Context, type CommentParserConfig, type DeclarationReference, type SymbolReference, type ComponentPath, type Meaning, type MeaningKeyword, type ExternalResolveResult, type ExternalSymbolResolver, } from "./lib/converter";
|
|
7
11
|
export { Renderer, DefaultTheme, DefaultThemeRenderContext, UrlMapping, Theme, PageEvent, RendererEvent, MarkdownEvent, IndexEvent, } from "./lib/output";
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,18 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
13
25
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
27
|
};
|
|
@@ -17,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
30
|
};
|
|
19
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.TypeScript = exports.SerializeEvent = exports.Deserializer = exports.Serializer = exports.JSONOutput = exports.MinimalSourceFile = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.CommentStyle = exports.BindOption = exports.ArgumentsReader = exports.IndexEvent = 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;
|
|
32
|
+
exports.TypeScript = exports.SerializeEvent = exports.Deserializer = exports.Serializer = exports.JSONOutput = exports.MinimalSourceFile = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.CommentStyle = exports.BindOption = exports.ArgumentsReader = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.Models = exports.normalizePath = exports.resetReflectionID = exports.Event = exports.EventDispatcher = exports.Application = void 0;
|
|
21
33
|
var application_1 = require("./lib/application");
|
|
22
34
|
Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return application_1.Application; } });
|
|
23
35
|
var events_1 = require("./lib/utils/events");
|
|
@@ -27,6 +39,10 @@ var abstract_1 = require("./lib/models/reflections/abstract");
|
|
|
27
39
|
Object.defineProperty(exports, "resetReflectionID", { enumerable: true, get: function () { return abstract_1.resetReflectionID; } });
|
|
28
40
|
var fs_1 = require("./lib/utils/fs");
|
|
29
41
|
Object.defineProperty(exports, "normalizePath", { enumerable: true, get: function () { return fs_1.normalizePath; } });
|
|
42
|
+
/**
|
|
43
|
+
* All symbols documented under the Models namespace are also available in the root import.
|
|
44
|
+
*/
|
|
45
|
+
exports.Models = __importStar(require("./lib/models"));
|
|
30
46
|
__exportStar(require("./lib/models"), exports);
|
|
31
47
|
var converter_1 = require("./lib/converter");
|
|
32
48
|
Object.defineProperty(exports, "Converter", { enumerable: true, get: function () { return converter_1.Converter; } });
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import { Comment, ReflectionKind } from "../../models";
|
|
3
3
|
import { Logger } from "../../utils";
|
|
4
|
-
import type { CommentStyle } from "../../utils/options/declaration";
|
|
4
|
+
import type { CommentStyle, JsDocCompatibility } from "../../utils/options/declaration";
|
|
5
5
|
export interface CommentParserConfig {
|
|
6
6
|
blockTags: Set<string>;
|
|
7
7
|
inlineTags: Set<string>;
|
|
8
8
|
modifierTags: Set<string>;
|
|
9
|
+
jsDocCompatibility: JsDocCompatibility;
|
|
9
10
|
}
|
|
10
11
|
export declare function clearCommentCache(): void;
|
|
11
12
|
export declare function getComment(symbol: ts.Symbol, kind: ReflectionKind, config: CommentParserConfig, logger: Logger, commentStyle: CommentStyle, checker: ts.TypeChecker | undefined): Comment | undefined;
|
|
@@ -127,17 +127,47 @@ function blockTag(comment, lexer, config, warning) {
|
|
|
127
127
|
(0, assert_1.ok)(blockTag.kind === lexer_1.TokenSyntaxKind.Tag, "blockTag called not at the start of a block tag."); // blockContent is broken if this fails.
|
|
128
128
|
const tagName = aliasedTags.get(blockTag.text) || blockTag.text;
|
|
129
129
|
let content;
|
|
130
|
-
if (tagName === "@example") {
|
|
130
|
+
if (tagName === "@example" && config.jsDocCompatibility.exampleTag) {
|
|
131
131
|
content = exampleBlockContent(comment, lexer, config, warning);
|
|
132
132
|
}
|
|
133
|
+
else if (tagName === "@default" && config.jsDocCompatibility.defaultTag) {
|
|
134
|
+
content = defaultBlockContent(comment, lexer, config, warning);
|
|
135
|
+
}
|
|
133
136
|
else {
|
|
134
137
|
content = blockContent(comment, lexer, config, warning);
|
|
135
138
|
}
|
|
136
139
|
return new models_1.CommentTag(tagName, content);
|
|
137
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* The `@default` tag gets a special case because otherwise we will produce many warnings
|
|
143
|
+
* about unescaped/mismatched/missing braces in legacy JSDoc comments
|
|
144
|
+
*/
|
|
145
|
+
function defaultBlockContent(comment, lexer, config, warning) {
|
|
146
|
+
lexer.mark();
|
|
147
|
+
const content = blockContent(comment, lexer, config, () => { });
|
|
148
|
+
const end = lexer.done() || lexer.peek();
|
|
149
|
+
lexer.release();
|
|
150
|
+
if (content.some((part) => part.kind === "code")) {
|
|
151
|
+
return blockContent(comment, lexer, config, warning);
|
|
152
|
+
}
|
|
153
|
+
const tokens = [];
|
|
154
|
+
while ((lexer.done() || lexer.peek()) !== end) {
|
|
155
|
+
tokens.push(lexer.take());
|
|
156
|
+
}
|
|
157
|
+
const blockText = tokens
|
|
158
|
+
.map((tok) => tok.text)
|
|
159
|
+
.join("")
|
|
160
|
+
.trim();
|
|
161
|
+
return [
|
|
162
|
+
{
|
|
163
|
+
kind: "code",
|
|
164
|
+
text: makeCodeBlock(blockText),
|
|
165
|
+
},
|
|
166
|
+
];
|
|
167
|
+
}
|
|
138
168
|
/**
|
|
139
169
|
* The `@example` tag gets a special case because otherwise we will produce many warnings
|
|
140
|
-
* about unescaped/mismatched/missing braces
|
|
170
|
+
* about unescaped/mismatched/missing braces in legacy JSDoc comments.
|
|
141
171
|
*/
|
|
142
172
|
function exampleBlockContent(comment, lexer, config, warning) {
|
|
143
173
|
lexer.mark();
|
|
@@ -114,10 +114,10 @@ class Context {
|
|
|
114
114
|
if (exportSymbol &&
|
|
115
115
|
reflection.kind &
|
|
116
116
|
(index_1.ReflectionKind.SomeModule | index_1.ReflectionKind.Reference)) {
|
|
117
|
-
reflection.comment =
|
|
117
|
+
reflection.comment = this.getComment(exportSymbol, reflection.kind);
|
|
118
118
|
}
|
|
119
119
|
if (symbol && !reflection.comment) {
|
|
120
|
-
reflection.comment =
|
|
120
|
+
reflection.comment = this.getComment(symbol, reflection.kind);
|
|
121
121
|
}
|
|
122
122
|
if (this.shouldBeStatic) {
|
|
123
123
|
reflection.setFlag(index_1.ReflectionFlag.Static);
|
|
@@ -27,6 +27,8 @@ export declare class Converter extends ChildableComponent<Application, Converter
|
|
|
27
27
|
/** @internal */
|
|
28
28
|
excludeProtected: boolean;
|
|
29
29
|
/** @internal */
|
|
30
|
+
excludeReferences: boolean;
|
|
31
|
+
/** @internal */
|
|
30
32
|
commentStyle: CommentStyle;
|
|
31
33
|
/** @internal */
|
|
32
34
|
validation: ValidationOptions;
|
|
@@ -57,13 +59,13 @@ export declare class Converter extends ChildableComponent<Application, Converter
|
|
|
57
59
|
*/
|
|
58
60
|
/**
|
|
59
61
|
* Triggered when the converter has created a declaration reflection.
|
|
60
|
-
* The listener will be given {@link Context} and a {@link DeclarationReflection}.
|
|
62
|
+
* The listener will be given {@link Context} and a {@link Models.DeclarationReflection}.
|
|
61
63
|
* @event
|
|
62
64
|
*/
|
|
63
65
|
static readonly EVENT_CREATE_DECLARATION: "createDeclaration";
|
|
64
66
|
/**
|
|
65
67
|
* Triggered when the converter has created a signature reflection.
|
|
66
|
-
* The listener will be given {@link Context}, {@link SignatureReflection} | {@link ProjectReflection} the declaration,
|
|
68
|
+
* The listener will be given {@link Context}, {@link Models.SignatureReflection} | {@link Models.ProjectReflection} the declaration,
|
|
67
69
|
* `ts.SignatureDeclaration | ts.IndexSignatureDeclaration | ts.JSDocSignature | undefined`,
|
|
68
70
|
* and `ts.Signature | undefined`. The signature will be undefined if the created signature is an index signature.
|
|
69
71
|
* @event
|
|
@@ -71,13 +73,13 @@ export declare class Converter extends ChildableComponent<Application, Converter
|
|
|
71
73
|
static readonly EVENT_CREATE_SIGNATURE: "createSignature";
|
|
72
74
|
/**
|
|
73
75
|
* Triggered when the converter has created a parameter reflection.
|
|
74
|
-
* The listener will be given {@link Context}, {@link ParameterReflection} and a `ts.Node?`
|
|
76
|
+
* The listener will be given {@link Context}, {@link Models.ParameterReflection} and a `ts.Node?`
|
|
75
77
|
* @event
|
|
76
78
|
*/
|
|
77
79
|
static readonly EVENT_CREATE_PARAMETER: "createParameter";
|
|
78
80
|
/**
|
|
79
81
|
* Triggered when the converter has created a type parameter reflection.
|
|
80
|
-
* The listener will be given {@link Context} and a {@link TypeParameterReflection}
|
|
82
|
+
* The listener will be given {@link Context} and a {@link Models.TypeParameterReflection}
|
|
81
83
|
* @event
|
|
82
84
|
*/
|
|
83
85
|
static readonly EVENT_CREATE_TYPE_PARAMETER: "createTypeParameter";
|
|
@@ -72,7 +72,7 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
|
|
|
72
72
|
this.compile(entryPoints, context);
|
|
73
73
|
this.resolve(context);
|
|
74
74
|
this.trigger(Converter_1.EVENT_END, context);
|
|
75
|
-
|
|
75
|
+
this._config = undefined;
|
|
76
76
|
return project;
|
|
77
77
|
}
|
|
78
78
|
/** @internal */
|
|
@@ -239,6 +239,7 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
|
|
|
239
239
|
blockTags: new Set(this.application.options.getValue("blockTags")),
|
|
240
240
|
inlineTags: new Set(this.application.options.getValue("inlineTags")),
|
|
241
241
|
modifierTags: new Set(this.application.options.getValue("modifierTags")),
|
|
242
|
+
jsDocCompatibility: this.application.options.getValue("jsDocCompatibility"),
|
|
242
243
|
};
|
|
243
244
|
return this._config;
|
|
244
245
|
}
|
|
@@ -263,13 +264,13 @@ Converter.EVENT_END = converter_events_1.ConverterEvents.END;
|
|
|
263
264
|
*/
|
|
264
265
|
/**
|
|
265
266
|
* Triggered when the converter has created a declaration reflection.
|
|
266
|
-
* The listener will be given {@link Context} and a {@link DeclarationReflection}.
|
|
267
|
+
* The listener will be given {@link Context} and a {@link Models.DeclarationReflection}.
|
|
267
268
|
* @event
|
|
268
269
|
*/
|
|
269
270
|
Converter.EVENT_CREATE_DECLARATION = converter_events_1.ConverterEvents.CREATE_DECLARATION;
|
|
270
271
|
/**
|
|
271
272
|
* Triggered when the converter has created a signature reflection.
|
|
272
|
-
* The listener will be given {@link Context}, {@link SignatureReflection} | {@link ProjectReflection} the declaration,
|
|
273
|
+
* The listener will be given {@link Context}, {@link Models.SignatureReflection} | {@link Models.ProjectReflection} the declaration,
|
|
273
274
|
* `ts.SignatureDeclaration | ts.IndexSignatureDeclaration | ts.JSDocSignature | undefined`,
|
|
274
275
|
* and `ts.Signature | undefined`. The signature will be undefined if the created signature is an index signature.
|
|
275
276
|
* @event
|
|
@@ -277,13 +278,13 @@ Converter.EVENT_CREATE_DECLARATION = converter_events_1.ConverterEvents.CREATE_D
|
|
|
277
278
|
Converter.EVENT_CREATE_SIGNATURE = converter_events_1.ConverterEvents.CREATE_SIGNATURE;
|
|
278
279
|
/**
|
|
279
280
|
* Triggered when the converter has created a parameter reflection.
|
|
280
|
-
* The listener will be given {@link Context}, {@link ParameterReflection} and a `ts.Node?`
|
|
281
|
+
* The listener will be given {@link Context}, {@link Models.ParameterReflection} and a `ts.Node?`
|
|
281
282
|
* @event
|
|
282
283
|
*/
|
|
283
284
|
Converter.EVENT_CREATE_PARAMETER = converter_events_1.ConverterEvents.CREATE_PARAMETER;
|
|
284
285
|
/**
|
|
285
286
|
* Triggered when the converter has created a type parameter reflection.
|
|
286
|
-
* The listener will be given {@link Context} and a {@link TypeParameterReflection}
|
|
287
|
+
* The listener will be given {@link Context} and a {@link Models.TypeParameterReflection}
|
|
287
288
|
* @event
|
|
288
289
|
*/
|
|
289
290
|
Converter.EVENT_CREATE_TYPE_PARAMETER = converter_events_1.ConverterEvents.CREATE_TYPE_PARAMETER;
|
|
@@ -323,6 +324,9 @@ __decorate([
|
|
|
323
324
|
__decorate([
|
|
324
325
|
(0, utils_1.BindOption)("excludeProtected")
|
|
325
326
|
], Converter.prototype, "excludeProtected", void 0);
|
|
327
|
+
__decorate([
|
|
328
|
+
(0, utils_1.BindOption)("excludeReferences")
|
|
329
|
+
], Converter.prototype, "excludeReferences", void 0);
|
|
326
330
|
__decorate([
|
|
327
331
|
(0, utils_1.BindOption)("commentStyle")
|
|
328
332
|
], Converter.prototype, "commentStyle", void 0);
|
|
@@ -50,6 +50,7 @@ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent
|
|
|
50
50
|
[converter_1.Converter.EVENT_RESOLVE_BEGIN]: this.onBeginResolve,
|
|
51
51
|
[converter_1.Converter.EVENT_END]: () => {
|
|
52
52
|
delete this.readmeFile;
|
|
53
|
+
delete this.readmeContents;
|
|
53
54
|
delete this.packageJson;
|
|
54
55
|
},
|
|
55
56
|
});
|
|
@@ -62,6 +63,7 @@ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent
|
|
|
62
63
|
this.addEntries(project);
|
|
63
64
|
delete this.readmeFile;
|
|
64
65
|
delete this.packageJson;
|
|
66
|
+
delete this.readmeContents;
|
|
65
67
|
}
|
|
66
68
|
onBegin() {
|
|
67
69
|
this.readmeFile = undefined;
|
|
@@ -117,7 +119,7 @@ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent
|
|
|
117
119
|
project.name = project.packageName || "Documentation";
|
|
118
120
|
}
|
|
119
121
|
if (this.includeVersion) {
|
|
120
|
-
project.packageVersion = this.packageJson.version;
|
|
122
|
+
project.packageVersion = this.packageJson.version?.replace(/^v/, "");
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
125
|
else if (!project.name) {
|
|
@@ -80,7 +80,7 @@ function convertSymbol(context, symbol, exportSymbol) {
|
|
|
80
80
|
// but aren't aliased symbols because `export *` was used.
|
|
81
81
|
const previous = context.project.getReflectionFromSymbol(symbol);
|
|
82
82
|
if (previous &&
|
|
83
|
-
previous.parent?.kindOf(models_1.ReflectionKind.
|
|
83
|
+
previous.parent?.kindOf(models_1.ReflectionKind.SomeModule | models_1.ReflectionKind.Project)) {
|
|
84
84
|
createAlias(previous, context, symbol, exportSymbol);
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
@@ -191,7 +191,9 @@ function convertTypeAlias(context, symbol, exportSymbol) {
|
|
|
191
191
|
typescript_1.default.isJSDocEnumTag(d));
|
|
192
192
|
(0, assert_1.default)(declaration);
|
|
193
193
|
if (typescript_1.default.isTypeAliasDeclaration(declaration)) {
|
|
194
|
-
if (
|
|
194
|
+
if (context
|
|
195
|
+
.getComment(symbol, models_1.ReflectionKind.TypeAlias)
|
|
196
|
+
?.hasModifier("@interface")) {
|
|
195
197
|
return convertTypeAliasAsInterface(context, symbol, exportSymbol, declaration);
|
|
196
198
|
}
|
|
197
199
|
const reflection = context.createDeclarationReflection(models_1.ReflectionKind.TypeAlias, symbol, exportSymbol);
|
|
@@ -444,6 +446,8 @@ function convertAlias(context, symbol, exportSymbol) {
|
|
|
444
446
|
}
|
|
445
447
|
}
|
|
446
448
|
function createAlias(target, context, symbol, exportSymbol) {
|
|
449
|
+
if (context.converter.excludeReferences)
|
|
450
|
+
return;
|
|
447
451
|
// We already have this. Create a reference.
|
|
448
452
|
const ref = new models_1.ReferenceReflection(exportSymbol?.name ?? symbol.name, target, context.scope);
|
|
449
453
|
context.postReflectionCreation(ref, symbol, exportSymbol);
|
|
@@ -452,12 +456,13 @@ function createAlias(target, context, symbol, exportSymbol) {
|
|
|
452
456
|
function convertVariable(context, symbol, exportSymbol) {
|
|
453
457
|
const declaration = symbol.getDeclarations()?.[0];
|
|
454
458
|
(0, assert_1.default)(declaration);
|
|
459
|
+
const comment = context.getComment(symbol, models_1.ReflectionKind.Variable);
|
|
455
460
|
const type = context.checker.getTypeOfSymbolAtLocation(symbol, declaration);
|
|
456
461
|
if (isEnumLike(context.checker, type, declaration) &&
|
|
457
|
-
|
|
462
|
+
comment?.hasModifier("@enum")) {
|
|
458
463
|
return convertVariableAsEnum(context, symbol, exportSymbol);
|
|
459
464
|
}
|
|
460
|
-
if (
|
|
465
|
+
if (comment?.hasModifier("@namespace")) {
|
|
461
466
|
return convertVariableAsNamespace(context, symbol, exportSymbol);
|
|
462
467
|
}
|
|
463
468
|
if (type.getCallSignatures().length) {
|
|
@@ -392,8 +392,8 @@ const queryConverter = {
|
|
|
392
392
|
}
|
|
393
393
|
return new models_1.QueryType(models_1.ReferenceType.createSymbolReference(context.resolveAliasedSymbol(querySymbol), context, node.exprName.getText()));
|
|
394
394
|
},
|
|
395
|
-
convertType(context, type) {
|
|
396
|
-
const symbol = type.getSymbol();
|
|
395
|
+
convertType(context, type, node) {
|
|
396
|
+
const symbol = type.getSymbol() || context.getSymbolAtLocation(node.exprName);
|
|
397
397
|
(0, assert_1.default)(symbol, `Query type failed to get a symbol for: ${context.checker.typeToString(type)}. This is a bug.`);
|
|
398
398
|
return new models_1.QueryType(models_1.ReferenceType.createSymbolReference(context.resolveAliasedSymbol(symbol), context));
|
|
399
399
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Reflection
|
|
1
|
+
import type { Reflection } from "../reflections";
|
|
2
|
+
import { ReflectionSymbolId } from "../reflections/ReflectionSymbolId";
|
|
2
3
|
import type { Serializer, Deserializer, JSONOutput } from "../../serialization";
|
|
3
4
|
export type CommentDisplayPart = {
|
|
4
5
|
kind: "text";
|
|
@@ -99,7 +100,6 @@ export declare class Comment {
|
|
|
99
100
|
modifierTags: Set<string>;
|
|
100
101
|
/**
|
|
101
102
|
* Label associated with this reflection, if any (https://tsdoc.org/pages/tags/label/)
|
|
102
|
-
* Added by the CommentPlugin during resolution.
|
|
103
103
|
*/
|
|
104
104
|
label?: string;
|
|
105
105
|
/**
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Comment = exports.CommentTag = void 0;
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
|
+
const ReflectionSymbolId_1 = require("../reflections/ReflectionSymbolId");
|
|
5
6
|
/**
|
|
6
7
|
* A model that represents a single TypeDoc comment tag.
|
|
7
8
|
*
|
|
@@ -162,20 +163,39 @@ class Comment {
|
|
|
162
163
|
case "code":
|
|
163
164
|
return { ...part };
|
|
164
165
|
case "inline-tag": {
|
|
165
|
-
if (typeof part.target
|
|
166
|
-
// TS isn't quite smart enough here...
|
|
167
|
-
// GERRIT this is wrong
|
|
168
|
-
return { ...part };
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
166
|
+
if (typeof part.target === "number") {
|
|
171
167
|
const part2 = {
|
|
172
168
|
kind: part.kind,
|
|
173
169
|
tag: part.tag,
|
|
174
170
|
text: part.text,
|
|
171
|
+
target: undefined,
|
|
172
|
+
tsLinkText: part.tsLinkText,
|
|
175
173
|
};
|
|
176
174
|
links.push([part.target, part2]);
|
|
177
175
|
return part2;
|
|
178
176
|
}
|
|
177
|
+
else if (typeof part.target === "string" ||
|
|
178
|
+
part.target === undefined) {
|
|
179
|
+
return {
|
|
180
|
+
kind: "inline-tag",
|
|
181
|
+
tag: part.tag,
|
|
182
|
+
text: part.text,
|
|
183
|
+
target: part.target,
|
|
184
|
+
tsLinkText: part.tsLinkText,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
else if (typeof part.target === "object") {
|
|
188
|
+
return {
|
|
189
|
+
kind: "inline-tag",
|
|
190
|
+
tag: part.tag,
|
|
191
|
+
text: part.text,
|
|
192
|
+
target: new ReflectionSymbolId_1.ReflectionSymbolId(part.target),
|
|
193
|
+
tsLinkText: part.tsLinkText,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
(0, utils_1.assertNever)(part.target);
|
|
198
|
+
}
|
|
179
199
|
}
|
|
180
200
|
}
|
|
181
201
|
});
|
|
@@ -40,7 +40,7 @@ export declare enum ConversionFlags {
|
|
|
40
40
|
* kind of a reflection is stored in its ´kind´ member.
|
|
41
41
|
*/
|
|
42
42
|
export declare class DeclarationReflection extends ContainerReflection {
|
|
43
|
-
readonly variant: "
|
|
43
|
+
readonly variant: "declaration" | "reference";
|
|
44
44
|
/**
|
|
45
45
|
* A list of all source files that contributed to this reflection.
|
|
46
46
|
*/
|
|
@@ -52,12 +52,6 @@ export declare class ProjectReflection extends ContainerReflection {
|
|
|
52
52
|
* @returns An array containing all reflections with the desired kind.
|
|
53
53
|
*/
|
|
54
54
|
getReflectionsByKind(kind: ReflectionKind): Reflection[];
|
|
55
|
-
/**
|
|
56
|
-
* Disassociate this project with all TypeScript created objects, allowing the underlying
|
|
57
|
-
* `ts.Program` to be garbage collected. This is very important for monorepo projects where
|
|
58
|
-
* we need to create multiple programs. See #1606 and surrounding discussion.
|
|
59
|
-
*/
|
|
60
|
-
forgetTsReferences(): void;
|
|
61
55
|
/**
|
|
62
56
|
* Registers the given reflection so that it can be quickly looked up by helper methods.
|
|
63
57
|
* Should be called for *every* reflection added to the project.
|
|
@@ -49,22 +49,6 @@ class ProjectReflection extends container_1.ContainerReflection {
|
|
|
49
49
|
getReflectionsByKind(kind) {
|
|
50
50
|
return Object.values(this.reflections).filter((reflection) => reflection.kindOf(kind));
|
|
51
51
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Disassociate this project with all TypeScript created objects, allowing the underlying
|
|
54
|
-
* `ts.Program` to be garbage collected. This is very important for monorepo projects where
|
|
55
|
-
* we need to create multiple programs. See #1606 and surrounding discussion.
|
|
56
|
-
*/
|
|
57
|
-
forgetTsReferences() {
|
|
58
|
-
// Clear ts.Symbol references
|
|
59
|
-
this.reflectionIdToSymbolMap.clear();
|
|
60
|
-
// TODO: I think we need to do something like this.
|
|
61
|
-
// Update local references
|
|
62
|
-
this.symbolToReflectionIdMap.clear();
|
|
63
|
-
for (const [k, v] of this.reflectionIdToSymbolIdMap) {
|
|
64
|
-
v.pos = Infinity;
|
|
65
|
-
this.symbolToReflectionIdMap.set(v, k);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
52
|
/**
|
|
69
53
|
* Registers the given reflection so that it can be quickly looked up by helper methods.
|
|
70
54
|
* Should be called for *every* reflection added to the project.
|
package/dist/lib/models/types.js
CHANGED
|
@@ -24,11 +24,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.UnknownType = exports.UnionType = exports.TypeOperatorType = exports.NamedTupleMember = exports.TupleType = exports.TemplateLiteralType = exports.RestType = exports.ReflectionType = exports.ReferenceType = exports.QueryType = exports.PredicateType = exports.OptionalType = exports.MappedType = exports.LiteralType = exports.IntrinsicType = exports.IntersectionType = exports.InferredType = exports.IndexedAccessType = exports.ConditionalType = exports.ArrayType = exports.TypeContext = exports.makeRecursiveVisitor = exports.Type = void 0;
|
|
27
|
-
const fs = __importStar(require("fs"));
|
|
28
|
-
const path = __importStar(require("path"));
|
|
29
27
|
const ts = __importStar(require("typescript"));
|
|
30
28
|
const tsutils_1 = require("../utils/tsutils");
|
|
31
29
|
const ReflectionSymbolId_1 = require("./reflections/ReflectionSymbolId");
|
|
30
|
+
const fs_1 = require("../utils/fs");
|
|
32
31
|
/**
|
|
33
32
|
* Base class of all type definitions.
|
|
34
33
|
*/
|
|
@@ -740,7 +739,7 @@ class ReferenceType extends Type {
|
|
|
740
739
|
return ref;
|
|
741
740
|
}
|
|
742
741
|
// Otherwise, look for a "package.json" file in a parent path
|
|
743
|
-
ref.package = findPackageForPath(symbolPath);
|
|
742
|
+
ref.package = (0, fs_1.findPackageForPath)(symbolPath);
|
|
744
743
|
return ref;
|
|
745
744
|
}
|
|
746
745
|
/** @internal this is used for type parameters, which don't actually point to something */
|
|
@@ -1134,31 +1133,3 @@ class UnknownType extends Type {
|
|
|
1134
1133
|
}
|
|
1135
1134
|
}
|
|
1136
1135
|
exports.UnknownType = UnknownType;
|
|
1137
|
-
const packageJsonLookupCache = {};
|
|
1138
|
-
function findPackageForPath(sourcePath) {
|
|
1139
|
-
if (packageJsonLookupCache[sourcePath] !== undefined) {
|
|
1140
|
-
return packageJsonLookupCache[sourcePath];
|
|
1141
|
-
}
|
|
1142
|
-
let basePath = sourcePath;
|
|
1143
|
-
for (;;) {
|
|
1144
|
-
const nextPath = path.dirname(basePath);
|
|
1145
|
-
if (nextPath === basePath) {
|
|
1146
|
-
return;
|
|
1147
|
-
}
|
|
1148
|
-
basePath = nextPath;
|
|
1149
|
-
const projectPath = path.join(basePath, "package.json");
|
|
1150
|
-
try {
|
|
1151
|
-
const packageJsonData = fs.readFileSync(projectPath, {
|
|
1152
|
-
encoding: "utf8",
|
|
1153
|
-
});
|
|
1154
|
-
const packageJson = JSON.parse(packageJsonData);
|
|
1155
|
-
if (packageJson.name !== undefined) {
|
|
1156
|
-
packageJsonLookupCache[sourcePath] = packageJson.name;
|
|
1157
|
-
}
|
|
1158
|
-
return packageJson.name;
|
|
1159
|
-
}
|
|
1160
|
-
catch (err) {
|
|
1161
|
-
continue;
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, AbstractComponent } from "../utils/component";
|
|
2
|
-
import { ProjectReflection,
|
|
2
|
+
import type { ProjectReflection, Reflection } from "../models/reflections/index";
|
|
3
3
|
import type { Renderer } from "./renderer";
|
|
4
4
|
import { RendererEvent, PageEvent } from "./events";
|
|
5
5
|
export { Component };
|
|
@@ -16,7 +16,7 @@ export declare abstract class ContextAwareRendererComponent extends RendererComp
|
|
|
16
16
|
/**
|
|
17
17
|
* The reflection that is currently processed.
|
|
18
18
|
*/
|
|
19
|
-
protected
|
|
19
|
+
protected page?: PageEvent<Reflection>;
|
|
20
20
|
/**
|
|
21
21
|
* The url of the document that is being currently generated.
|
|
22
22
|
* Set when a page begins rendering.
|
|
@@ -50,5 +50,5 @@ export declare abstract class ContextAwareRendererComponent extends RendererComp
|
|
|
50
50
|
*
|
|
51
51
|
* @param page An event object describing the current render operation.
|
|
52
52
|
*/
|
|
53
|
-
protected onBeginPage(page: PageEvent): void;
|
|
53
|
+
protected onBeginPage(page: PageEvent<Reflection>): void;
|
|
54
54
|
}
|
|
@@ -27,7 +27,6 @@ exports.ContextAwareRendererComponent = exports.RendererComponent = exports.Comp
|
|
|
27
27
|
const Path = __importStar(require("path"));
|
|
28
28
|
const component_1 = require("../utils/component");
|
|
29
29
|
Object.defineProperty(exports, "Component", { enumerable: true, get: function () { return component_1.Component; } });
|
|
30
|
-
const index_1 = require("../models/reflections/index");
|
|
31
30
|
const events_1 = require("./events");
|
|
32
31
|
class RendererComponent extends component_1.AbstractComponent {
|
|
33
32
|
}
|
|
@@ -84,10 +83,7 @@ class ContextAwareRendererComponent extends RendererComponent {
|
|
|
84
83
|
*/
|
|
85
84
|
onBeginPage(page) {
|
|
86
85
|
this.location = page.url;
|
|
87
|
-
this.
|
|
88
|
-
page.model instanceof index_1.DeclarationReflection
|
|
89
|
-
? page.model
|
|
90
|
-
: undefined;
|
|
86
|
+
this.page = page;
|
|
91
87
|
}
|
|
92
88
|
}
|
|
93
89
|
exports.ContextAwareRendererComponent = ContextAwareRendererComponent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Event } from "../utils/events";
|
|
2
2
|
import type { ProjectReflection } from "../models/reflections/project";
|
|
3
3
|
import type { RenderTemplate, UrlMapping } from "./models/UrlMapping";
|
|
4
|
-
import type { DeclarationReflection } from "../models";
|
|
4
|
+
import type { DeclarationReflection, ReflectionKind } from "../models";
|
|
5
5
|
/**
|
|
6
6
|
* An event emitted by the {@link Renderer} class at the very beginning and
|
|
7
7
|
* ending of the entire rendering process.
|
|
@@ -42,7 +42,7 @@ export declare class RendererEvent extends Event {
|
|
|
42
42
|
* @param mapping The mapping that defines the generated {@link PageEvent} state.
|
|
43
43
|
* @returns A newly created {@link PageEvent} instance.
|
|
44
44
|
*/
|
|
45
|
-
createPageEvent<Model>(mapping: UrlMapping<Model>): PageEvent<Model
|
|
45
|
+
createPageEvent<Model>(mapping: UrlMapping<Model>): [RenderTemplate<PageEvent<Model>>, PageEvent<Model>];
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* An event emitted by the {@link Renderer} class before and after the
|
|
@@ -51,7 +51,7 @@ export declare class RendererEvent extends Event {
|
|
|
51
51
|
* @see {@link Renderer.EVENT_BEGIN_PAGE}
|
|
52
52
|
* @see {@link Renderer.EVENT_END_PAGE}
|
|
53
53
|
*/
|
|
54
|
-
export declare class PageEvent<Model = unknown> extends Event {
|
|
54
|
+
export declare class PageEvent<out Model = unknown> extends Event {
|
|
55
55
|
/**
|
|
56
56
|
* The project the renderer is currently processing.
|
|
57
57
|
*/
|
|
@@ -67,17 +67,24 @@ export declare class PageEvent<Model = unknown> extends Event {
|
|
|
67
67
|
/**
|
|
68
68
|
* The model that should be rendered on this page.
|
|
69
69
|
*/
|
|
70
|
-
model: Model;
|
|
71
|
-
/**
|
|
72
|
-
* The template that should be used to render this page.
|
|
73
|
-
*/
|
|
74
|
-
template: RenderTemplate<this>;
|
|
70
|
+
readonly model: Model;
|
|
75
71
|
/**
|
|
76
72
|
* The final html content of this page.
|
|
77
73
|
*
|
|
78
74
|
* Should be rendered by layout templates and can be modified by plugins.
|
|
79
75
|
*/
|
|
80
76
|
contents?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Links to content within this page that should be rendered in the page navigation.
|
|
79
|
+
* This is built when rendering the document content.
|
|
80
|
+
*/
|
|
81
|
+
pageHeadings: Array<{
|
|
82
|
+
link: string;
|
|
83
|
+
text: string;
|
|
84
|
+
level?: number;
|
|
85
|
+
kind?: ReflectionKind;
|
|
86
|
+
classes?: string;
|
|
87
|
+
}>;
|
|
81
88
|
/**
|
|
82
89
|
* Triggered before a document will be rendered.
|
|
83
90
|
* @event
|
|
@@ -88,11 +95,12 @@ export declare class PageEvent<Model = unknown> extends Event {
|
|
|
88
95
|
* @event
|
|
89
96
|
*/
|
|
90
97
|
static readonly END = "endPage";
|
|
98
|
+
constructor(name: string, model: Model);
|
|
91
99
|
}
|
|
92
100
|
/**
|
|
93
101
|
* An event emitted when markdown is being parsed. Allows other plugins to manipulate the result.
|
|
94
102
|
*
|
|
95
|
-
* @see {@link PARSE}
|
|
103
|
+
* @see {@link MarkdownEvent.PARSE}
|
|
96
104
|
*/
|
|
97
105
|
export declare class MarkdownEvent extends Event {
|
|
98
106
|
/**
|
|
@@ -103,12 +111,16 @@ export declare class MarkdownEvent extends Event {
|
|
|
103
111
|
* The parsed output.
|
|
104
112
|
*/
|
|
105
113
|
parsedText: string;
|
|
114
|
+
/**
|
|
115
|
+
* The page that this markdown is being parsed for.
|
|
116
|
+
*/
|
|
117
|
+
readonly page: PageEvent;
|
|
106
118
|
/**
|
|
107
119
|
* Triggered on the renderer when this plugin parses a markdown string.
|
|
108
120
|
* @event
|
|
109
121
|
*/
|
|
110
122
|
static readonly PARSE = "parseMarkdown";
|
|
111
|
-
constructor(name: string, originalText: string, parsedText: string);
|
|
123
|
+
constructor(name: string, page: PageEvent, originalText: string, parsedText: string);
|
|
112
124
|
}
|
|
113
125
|
/**
|
|
114
126
|
* An event emitted when the search index is being prepared.
|