typedoc 0.24.0-beta.6 → 0.24.0-beta.8
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/blockLexer.js +2 -1
- package/dist/lib/converter/comments/discovery.js +1 -1
- package/dist/lib/converter/comments/index.d.ts +4 -3
- package/dist/lib/converter/comments/index.js +9 -2
- package/dist/lib/converter/comments/lexer.d.ts +2 -1
- package/dist/lib/converter/comments/linkResolver.d.ts +12 -4
- package/dist/lib/converter/comments/linkResolver.js +39 -18
- package/dist/lib/converter/comments/parser.js +3 -2
- package/dist/lib/converter/context.d.ts +3 -0
- package/dist/lib/converter/context.js +11 -2
- package/dist/lib/converter/converter.d.ts +9 -7
- package/dist/lib/converter/converter.js +12 -12
- package/dist/lib/converter/factories/signature.js +5 -6
- package/dist/lib/converter/jsdoc.js +3 -4
- package/dist/lib/converter/plugins/LinkResolverPlugin.js +1 -1
- package/dist/lib/converter/plugins/PackagePlugin.js +3 -1
- package/dist/lib/converter/symbols.js +9 -4
- package/dist/lib/models/comments/comment.d.ts +7 -3
- package/dist/lib/models/comments/comment.js +26 -5
- 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/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 +2 -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 +1 -0
- package/dist/lib/utils/options/options.d.ts +5 -0
- package/dist/lib/utils/options/sources/typedoc.js +5 -0
- package/package.json +1 -1
- package/static/main.js +3 -3
- package/static/style.css +186 -257
|
@@ -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";
|
|
@@ -9,13 +10,16 @@ export type CommentDisplayPart = {
|
|
|
9
10
|
} | InlineTagDisplayPart;
|
|
10
11
|
/**
|
|
11
12
|
* The `@link`, `@linkcode`, and `@linkplain` tags may have a `target`
|
|
12
|
-
* property set indicating which reflection/url they link to.
|
|
13
|
+
* property set indicating which reflection/url they link to. They may also
|
|
14
|
+
* have a `tsLinkText` property which includes the part of the `text` which
|
|
15
|
+
* TypeScript thinks should be displayed as the link text.
|
|
13
16
|
*/
|
|
14
17
|
export interface InlineTagDisplayPart {
|
|
15
18
|
kind: "inline-tag";
|
|
16
19
|
tag: `@${string}`;
|
|
17
20
|
text: string;
|
|
18
21
|
target?: Reflection | string | ReflectionSymbolId;
|
|
22
|
+
tsLinkText?: string;
|
|
19
23
|
}
|
|
20
24
|
/**
|
|
21
25
|
* A model that represents a single TypeDoc comment tag.
|
|
@@ -76,6 +80,7 @@ export declare class Comment {
|
|
|
76
80
|
tag: `@${string}`;
|
|
77
81
|
text: string;
|
|
78
82
|
target?: string | Reflection | ReflectionSymbolId | undefined;
|
|
83
|
+
tsLinkText?: string | undefined;
|
|
79
84
|
})[];
|
|
80
85
|
static serializeDisplayParts(serializer: Serializer, parts: CommentDisplayPart[]): JSONOutput.CommentDisplayPart[];
|
|
81
86
|
/** @hidden no point in showing this signature in api docs */
|
|
@@ -95,7 +100,6 @@ export declare class Comment {
|
|
|
95
100
|
modifierTags: Set<string>;
|
|
96
101
|
/**
|
|
97
102
|
* Label associated with this reflection, if any (https://tsdoc.org/pages/tags/label/)
|
|
98
|
-
* Added by the CommentPlugin during resolution.
|
|
99
103
|
*/
|
|
100
104
|
label?: string;
|
|
101
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,19 +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
|
-
return { ...part };
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
166
|
+
if (typeof part.target === "number") {
|
|
170
167
|
const part2 = {
|
|
171
168
|
kind: part.kind,
|
|
172
169
|
tag: part.tag,
|
|
173
170
|
text: part.text,
|
|
171
|
+
target: undefined,
|
|
172
|
+
tsLinkText: part.tsLinkText,
|
|
174
173
|
};
|
|
175
174
|
links.push([part.target, part2]);
|
|
176
175
|
return part2;
|
|
177
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
|
+
}
|
|
178
199
|
}
|
|
179
200
|
}
|
|
180
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.
|
|
@@ -47,13 +47,11 @@ class RendererEvent extends events_1.Event {
|
|
|
47
47
|
* @returns A newly created {@link PageEvent} instance.
|
|
48
48
|
*/
|
|
49
49
|
createPageEvent(mapping) {
|
|
50
|
-
const event = new PageEvent(PageEvent.BEGIN);
|
|
50
|
+
const event = new PageEvent(PageEvent.BEGIN, mapping.model);
|
|
51
51
|
event.project = this.project;
|
|
52
52
|
event.url = mapping.url;
|
|
53
|
-
event.model = mapping.model;
|
|
54
|
-
event.template = mapping.template;
|
|
55
53
|
event.filename = Path.join(this.outputDirectory, mapping.url);
|
|
56
|
-
return event;
|
|
54
|
+
return [mapping.template, event];
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
57
|
/**
|
|
@@ -75,6 +73,15 @@ exports.RendererEvent = RendererEvent;
|
|
|
75
73
|
* @see {@link Renderer.EVENT_END_PAGE}
|
|
76
74
|
*/
|
|
77
75
|
class PageEvent extends events_1.Event {
|
|
76
|
+
constructor(name, model) {
|
|
77
|
+
super(name);
|
|
78
|
+
/**
|
|
79
|
+
* Links to content within this page that should be rendered in the page navigation.
|
|
80
|
+
* This is built when rendering the document content.
|
|
81
|
+
*/
|
|
82
|
+
this.pageHeadings = [];
|
|
83
|
+
this.model = model;
|
|
84
|
+
}
|
|
78
85
|
}
|
|
79
86
|
/**
|
|
80
87
|
* Triggered before a document will be rendered.
|
|
@@ -90,11 +97,12 @@ exports.PageEvent = PageEvent;
|
|
|
90
97
|
/**
|
|
91
98
|
* An event emitted when markdown is being parsed. Allows other plugins to manipulate the result.
|
|
92
99
|
*
|
|
93
|
-
* @see {@link PARSE}
|
|
100
|
+
* @see {@link MarkdownEvent.PARSE}
|
|
94
101
|
*/
|
|
95
102
|
class MarkdownEvent extends events_1.Event {
|
|
96
|
-
constructor(name, originalText, parsedText) {
|
|
103
|
+
constructor(name, page, originalText, parsedText) {
|
|
97
104
|
super(name);
|
|
105
|
+
this.page = page;
|
|
98
106
|
this.originalText = originalText;
|
|
99
107
|
this.parsedText = parsedText;
|
|
100
108
|
}
|
|
@@ -95,9 +95,7 @@ let JavascriptIndexPlugin = class JavascriptIndexPlugin extends components_1.Ren
|
|
|
95
95
|
kind: reflection.kind,
|
|
96
96
|
name: reflection.name,
|
|
97
97
|
url: reflection.url,
|
|
98
|
-
classes: this.owner.theme
|
|
99
|
-
.getRenderContext()
|
|
100
|
-
.getReflectionClasses(reflection),
|
|
98
|
+
classes: this.owner.theme.getReflectionClasses(reflection),
|
|
101
99
|
};
|
|
102
100
|
if (parent) {
|
|
103
101
|
row.parent = parent.getFullName();
|
|
@@ -38,13 +38,21 @@ export interface RendererHooks {
|
|
|
38
38
|
*/
|
|
39
39
|
"content.end": [DefaultThemeRenderContext];
|
|
40
40
|
/**
|
|
41
|
-
* Applied immediately before calling `context.
|
|
41
|
+
* Applied immediately before calling `context.sidebar`.
|
|
42
42
|
*/
|
|
43
|
-
"
|
|
43
|
+
"sidebar.begin": [DefaultThemeRenderContext];
|
|
44
44
|
/**
|
|
45
|
-
* Applied immediately after calling `context.
|
|
45
|
+
* Applied immediately after calling `context.sidebar`.
|
|
46
46
|
*/
|
|
47
|
-
"
|
|
47
|
+
"sidebar.end": [DefaultThemeRenderContext];
|
|
48
|
+
/**
|
|
49
|
+
* Applied immediately before calling `context.pageSidebar`.
|
|
50
|
+
*/
|
|
51
|
+
"pageSidebar.begin": [DefaultThemeRenderContext];
|
|
52
|
+
/**
|
|
53
|
+
* Applied immediately after calling `context.pageSidebar`.
|
|
54
|
+
*/
|
|
55
|
+
"pageSidebar.end": [DefaultThemeRenderContext];
|
|
48
56
|
}
|
|
49
57
|
/**
|
|
50
58
|
* The renderer processes a {@link ProjectReflection} using a {@link Theme} instance and writes
|
|
@@ -156,7 +156,7 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
|
|
|
156
156
|
this.application.logger.verbose(`There are ${output.urls.length} pages to write.`);
|
|
157
157
|
output.urls.forEach((mapping) => {
|
|
158
158
|
(0, icon_1.clearSeenIconCache)();
|
|
159
|
-
this.renderDocument(output.createPageEvent(mapping));
|
|
159
|
+
this.renderDocument(...output.createPageEvent(mapping));
|
|
160
160
|
(0, type_1.validateStateIsClean)(mapping.url);
|
|
161
161
|
});
|
|
162
162
|
await Promise.all(this.postRenderAsyncJobs.map((job) => job(output)));
|
|
@@ -172,7 +172,7 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
|
|
|
172
172
|
* @param page An event describing the current page.
|
|
173
173
|
* @return TRUE if the page has been saved to disc, otherwise FALSE.
|
|
174
174
|
*/
|
|
175
|
-
renderDocument(page) {
|
|
175
|
+
renderDocument(template, page) {
|
|
176
176
|
const momento = this.hooks.saveMomento();
|
|
177
177
|
this.trigger(events_1.PageEvent.BEGIN, page);
|
|
178
178
|
if (page.isDefaultPrevented) {
|
|
@@ -180,7 +180,7 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
|
|
|
180
180
|
return false;
|
|
181
181
|
}
|
|
182
182
|
if (page.model instanceof models_1.Reflection) {
|
|
183
|
-
page.contents = this.theme.render(page);
|
|
183
|
+
page.contents = this.theme.render(page, template);
|
|
184
184
|
}
|
|
185
185
|
else {
|
|
186
186
|
throw new Error("Should be unreachable");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Renderer } from "./renderer";
|
|
2
2
|
import type { ProjectReflection } from "../models/reflections/project";
|
|
3
|
-
import type { UrlMapping } from "./models/UrlMapping";
|
|
3
|
+
import type { RenderTemplate, UrlMapping } from "./models/UrlMapping";
|
|
4
4
|
import { RendererComponent } from "./components";
|
|
5
5
|
import type { PageEvent } from "./events";
|
|
6
6
|
import type { Reflection } from "../models";
|
|
@@ -39,5 +39,5 @@ export declare abstract class Theme extends RendererComponent {
|
|
|
39
39
|
/**
|
|
40
40
|
* Renders the provided page to a string, which will be written to disk by the {@link Renderer}
|
|
41
41
|
*/
|
|
42
|
-
abstract render(page: PageEvent<Reflection
|
|
42
|
+
abstract render(page: PageEvent<Reflection>, template: RenderTemplate<PageEvent<Reflection>>): string;
|
|
43
43
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ContextAwareRendererComponent } from "../components";
|
|
2
|
-
import { RendererEvent, MarkdownEvent } from "../events";
|
|
2
|
+
import { RendererEvent, MarkdownEvent, PageEvent } from "../events";
|
|
3
3
|
import type { Theme } from "shiki";
|
|
4
4
|
/**
|
|
5
5
|
* Implements markdown and relativeURL helpers for templates.
|
|
@@ -46,7 +46,7 @@ export declare class MarkedPlugin extends ContextAwareRendererComponent {
|
|
|
46
46
|
* @param text The markdown string that should be parsed.
|
|
47
47
|
* @returns The resulting html string.
|
|
48
48
|
*/
|
|
49
|
-
parseMarkdown(text: string): string;
|
|
49
|
+
parseMarkdown(text: string, page: PageEvent<any>): string;
|
|
50
50
|
/**
|
|
51
51
|
* Triggered before the renderer starts rendering a project.
|
|
52
52
|
*
|
|
@@ -37,15 +37,6 @@ const components_1 = require("../components");
|
|
|
37
37
|
const events_1 = require("../events");
|
|
38
38
|
const utils_1 = require("../../utils");
|
|
39
39
|
const highlighter_1 = require("../../utils/highlighter");
|
|
40
|
-
const customMarkedRenderer = new Marked.Renderer();
|
|
41
|
-
customMarkedRenderer.heading = (text, level, _, slugger) => {
|
|
42
|
-
const slug = slugger.slug(text);
|
|
43
|
-
return `
|
|
44
|
-
<a href="#${slug}" id="${slug}" style="color: inherit; text-decoration: none;">
|
|
45
|
-
<h${level}>${text}</h${level}>
|
|
46
|
-
</a>
|
|
47
|
-
`;
|
|
48
|
-
};
|
|
49
40
|
/**
|
|
50
41
|
* Implements markdown and relativeURL helpers for templates.
|
|
51
42
|
* @internal
|
|
@@ -98,7 +89,7 @@ output file :
|
|
|
98
89
|
* @param text The markdown string that should be parsed.
|
|
99
90
|
* @returns The resulting html string.
|
|
100
91
|
*/
|
|
101
|
-
parseMarkdown(text) {
|
|
92
|
+
parseMarkdown(text, page) {
|
|
102
93
|
if (this.includes) {
|
|
103
94
|
text = text.replace(this.includePattern, (_match, path) => {
|
|
104
95
|
path = Path.join(this.includes, path.trim());
|
|
@@ -124,7 +115,7 @@ output file :
|
|
|
124
115
|
}
|
|
125
116
|
});
|
|
126
117
|
}
|
|
127
|
-
const event = new events_1.MarkdownEvent(events_1.MarkdownEvent.PARSE, text, text);
|
|
118
|
+
const event = new events_1.MarkdownEvent(events_1.MarkdownEvent.PARSE, page, text, text);
|
|
128
119
|
this.owner.trigger(event);
|
|
129
120
|
return event.parsedText;
|
|
130
121
|
}
|
|
@@ -169,7 +160,19 @@ output file :
|
|
|
169
160
|
const markedOptions = (this.application.options.getValue("markedOptions") ?? {});
|
|
170
161
|
// Set some default values if they are not specified via the TypeDoc option
|
|
171
162
|
markedOptions.highlight ?? (markedOptions.highlight = (text, lang) => this.getHighlighted(text, lang));
|
|
172
|
-
|
|
163
|
+
if (!markedOptions.renderer) {
|
|
164
|
+
markedOptions.renderer = new Marked.Renderer();
|
|
165
|
+
markedOptions.renderer.heading = (text, level, _, slugger) => {
|
|
166
|
+
const slug = slugger.slug(text);
|
|
167
|
+
// Prefix the slug with an extra `$` to prevent conflicts with TypeDoc's anchors.
|
|
168
|
+
this.page.pageHeadings.push({
|
|
169
|
+
link: `#$${slug}`,
|
|
170
|
+
text,
|
|
171
|
+
level,
|
|
172
|
+
});
|
|
173
|
+
return `<a id="$${slug}" class="tsd-anchor"></a><h${level}><a href="#$${slug}" style="color:inherit;text-decoration:none">${text}</a></h${level}>`;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
173
176
|
markedOptions.mangle ?? (markedOptions.mangle = false); // See https://github.com/TypeStrong/typedoc/issues/1395
|
|
174
177
|
return markedOptions;
|
|
175
178
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Theme } from "../../theme";
|
|
2
2
|
import type { Renderer } from "../../renderer";
|
|
3
3
|
import { Reflection, ProjectReflection, ContainerReflection, DeclarationReflection } from "../../../models";
|
|
4
|
-
import { UrlMapping } from "../../models/UrlMapping";
|
|
4
|
+
import { RenderTemplate, UrlMapping } from "../../models/UrlMapping";
|
|
5
5
|
import type { PageEvent } from "../../events";
|
|
6
6
|
import type { MarkedPlugin } from "../../plugins";
|
|
7
7
|
import { DefaultThemeRenderContext } from "./DefaultThemeRenderContext";
|
|
@@ -13,11 +13,11 @@ import { JSX } from "../../../utils";
|
|
|
13
13
|
export declare class DefaultTheme extends Theme {
|
|
14
14
|
/** @internal */
|
|
15
15
|
markedPlugin: MarkedPlugin;
|
|
16
|
-
|
|
17
|
-
getRenderContext(): DefaultThemeRenderContext;
|
|
16
|
+
getRenderContext(pageEvent: PageEvent<Reflection>): DefaultThemeRenderContext;
|
|
18
17
|
reflectionTemplate: (pageEvent: PageEvent<ContainerReflection>) => JSX.Element;
|
|
19
18
|
indexTemplate: (pageEvent: PageEvent<ProjectReflection>) => JSX.Element;
|
|
20
|
-
defaultLayoutTemplate: (pageEvent: PageEvent<Reflection
|
|
19
|
+
defaultLayoutTemplate: (pageEvent: PageEvent<Reflection>, template: RenderTemplate<PageEvent<Reflection>>) => JSX.Element;
|
|
20
|
+
getReflectionClasses(reflection: DeclarationReflection): string;
|
|
21
21
|
/**
|
|
22
22
|
* Mappings of reflections kinds to templates used by this theme.
|
|
23
23
|
*/
|
|
@@ -62,7 +62,7 @@ export declare class DefaultTheme extends Theme {
|
|
|
62
62
|
* @returns The altered urls array.
|
|
63
63
|
*/
|
|
64
64
|
buildUrls(reflection: DeclarationReflection, urls: UrlMapping[]): UrlMapping[];
|
|
65
|
-
render(page: PageEvent<Reflection
|
|
65
|
+
render(page: PageEvent<Reflection>, template: RenderTemplate<PageEvent<Reflection>>): string;
|
|
66
66
|
/**
|
|
67
67
|
* Generate an anchor url for the given reflection and all of its children.
|
|
68
68
|
*
|
|
@@ -11,11 +11,12 @@ const utils_1 = require("../../../utils");
|
|
|
11
11
|
* {@link Theme} implementation, this theme class will be used.
|
|
12
12
|
*/
|
|
13
13
|
class DefaultTheme extends theme_1.Theme {
|
|
14
|
-
getRenderContext() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
getRenderContext(pageEvent) {
|
|
15
|
+
return new DefaultThemeRenderContext_1.DefaultThemeRenderContext(this, pageEvent, this.application.options);
|
|
16
|
+
}
|
|
17
|
+
getReflectionClasses(reflection) {
|
|
18
|
+
const filters = this.application.options.getValue("visibilityFilters");
|
|
19
|
+
return getReflectionClasses(reflection, filters);
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
22
|
* Create a new DefaultTheme instance.
|
|
@@ -26,13 +27,13 @@ class DefaultTheme extends theme_1.Theme {
|
|
|
26
27
|
constructor(renderer) {
|
|
27
28
|
super(renderer);
|
|
28
29
|
this.reflectionTemplate = (pageEvent) => {
|
|
29
|
-
return this.getRenderContext().reflectionTemplate(pageEvent);
|
|
30
|
+
return this.getRenderContext(pageEvent).reflectionTemplate(pageEvent);
|
|
30
31
|
};
|
|
31
32
|
this.indexTemplate = (pageEvent) => {
|
|
32
|
-
return this.getRenderContext().indexTemplate(pageEvent);
|
|
33
|
+
return this.getRenderContext(pageEvent).indexTemplate(pageEvent);
|
|
33
34
|
};
|
|
34
|
-
this.defaultLayoutTemplate = (pageEvent) => {
|
|
35
|
-
return this.getRenderContext().defaultLayout(pageEvent);
|
|
35
|
+
this.defaultLayoutTemplate = (pageEvent, template) => {
|
|
36
|
+
return this.getRenderContext(pageEvent).defaultLayout(template, pageEvent);
|
|
36
37
|
};
|
|
37
38
|
/**
|
|
38
39
|
* Mappings of reflections kinds to templates used by this theme.
|
|
@@ -162,8 +163,8 @@ class DefaultTheme extends theme_1.Theme {
|
|
|
162
163
|
}
|
|
163
164
|
return urls;
|
|
164
165
|
}
|
|
165
|
-
render(page) {
|
|
166
|
-
const templateOutput = this.defaultLayoutTemplate(page);
|
|
166
|
+
render(page, template) {
|
|
167
|
+
const templateOutput = this.defaultLayoutTemplate(page, template);
|
|
167
168
|
return "<!DOCTYPE html>" + utils_1.JSX.renderElement(templateOutput);
|
|
168
169
|
}
|
|
169
170
|
/**
|
|
@@ -193,3 +194,49 @@ exports.DefaultTheme = DefaultTheme;
|
|
|
193
194
|
function hasReadme(readme) {
|
|
194
195
|
return !readme.endsWith("none");
|
|
195
196
|
}
|
|
197
|
+
function toStyleClass(str) {
|
|
198
|
+
return str.replace(/(\w)([A-Z])/g, (_m, m1, m2) => m1 + "-" + m2).toLowerCase();
|
|
199
|
+
}
|
|
200
|
+
function getReflectionClasses(reflection, filters) {
|
|
201
|
+
const classes = [];
|
|
202
|
+
classes.push(toStyleClass("tsd-kind-" + models_1.ReflectionKind[reflection.kind]));
|
|
203
|
+
if (reflection.parent && reflection.parent instanceof models_1.DeclarationReflection) {
|
|
204
|
+
classes.push(toStyleClass(`tsd-parent-kind-${models_1.ReflectionKind[reflection.parent.kind]}`));
|
|
205
|
+
}
|
|
206
|
+
// Filter classes should match up with the settings function in
|
|
207
|
+
// partials/navigation.tsx.
|
|
208
|
+
for (const key of Object.keys(filters)) {
|
|
209
|
+
if (key === "inherited") {
|
|
210
|
+
if (reflection.inheritedFrom) {
|
|
211
|
+
classes.push("tsd-is-inherited");
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else if (key === "protected") {
|
|
215
|
+
if (reflection.flags.isProtected) {
|
|
216
|
+
classes.push("tsd-is-protected");
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
else if (key === "private") {
|
|
220
|
+
if (reflection.flags.isPrivate) {
|
|
221
|
+
classes.push("tsd-is-private");
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else if (key === "external") {
|
|
225
|
+
if (reflection.flags.isExternal) {
|
|
226
|
+
classes.push("tsd-is-external");
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else if (key.startsWith("@")) {
|
|
230
|
+
if (key === "@deprecated") {
|
|
231
|
+
if (reflection.isDeprecated()) {
|
|
232
|
+
classes.push(toStyleClass(`tsd-is-${key.substring(1)}`));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
else if (reflection.comment?.hasModifier(key) ||
|
|
236
|
+
reflection.comment?.getTag(key)) {
|
|
237
|
+
classes.push(toStyleClass(`tsd-is-${key.substring(1)}`));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return classes.join(" ");
|
|
242
|
+
}
|