typedoc 0.26.0-beta.5 → 0.26.1
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 +5 -6
- package/dist/index.js +1 -2
- package/dist/lib/application-events.d.ts +3 -3
- package/dist/lib/application.d.ts +9 -4
- package/dist/lib/application.js +14 -4
- package/dist/lib/converter/comments/parser.js +7 -3
- package/dist/lib/converter/comments/textParser.d.ts +12 -1
- package/dist/lib/converter/comments/textParser.js +72 -25
- package/dist/lib/converter/components.d.ts +1 -1
- package/dist/lib/converter/context.d.ts +0 -10
- package/dist/lib/converter/context.js +0 -12
- package/dist/lib/converter/converter.d.ts +22 -2
- package/dist/lib/converter/converter.js +0 -1
- package/dist/lib/converter/factories/index-signature.js +1 -1
- package/dist/lib/converter/factories/signature.js +5 -5
- package/dist/lib/converter/index.d.ts +1 -1
- package/dist/lib/converter/jsdoc.js +1 -1
- package/dist/lib/converter/plugins/CategoryPlugin.js +2 -4
- package/dist/lib/converter/plugins/CommentPlugin.js +12 -11
- package/dist/lib/converter/plugins/GroupPlugin.js +8 -10
- package/dist/lib/converter/plugins/ImplementsPlugin.js +4 -4
- package/dist/lib/converter/plugins/InheritDocPlugin.js +1 -1
- package/dist/lib/converter/plugins/LinkResolverPlugin.js +2 -2
- package/dist/lib/converter/plugins/PackagePlugin.js +7 -11
- package/dist/lib/converter/plugins/SourcePlugin.js +4 -6
- package/dist/lib/converter/plugins/TypePlugin.js +4 -8
- package/dist/lib/converter/types.js +6 -6
- package/dist/lib/internationalization/locales/jp.cjs +15 -1
- package/dist/lib/internationalization/locales/jp.d.cts +15 -1
- package/dist/lib/internationalization/locales/ko.cjs +154 -0
- package/dist/lib/internationalization/locales/ko.d.cts +153 -0
- package/dist/lib/internationalization/locales/zh.cjs +15 -1
- package/dist/lib/internationalization/locales/zh.d.cts +15 -1
- package/dist/lib/internationalization/translatable.d.ts +2 -1
- package/dist/lib/internationalization/translatable.js +3 -1
- package/dist/lib/models/FileRegistry.d.ts +9 -4
- package/dist/lib/models/FileRegistry.js +6 -1
- package/dist/lib/models/comments/comment.d.ts +2 -2
- package/dist/lib/models/reflections/declaration.js +1 -0
- package/dist/lib/models/reflections/project.js +1 -1
- package/dist/lib/output/components.d.ts +1 -1
- package/dist/lib/output/components.js +3 -5
- package/dist/lib/output/events.d.ts +6 -13
- package/dist/lib/output/events.js +7 -17
- package/dist/lib/output/index.d.ts +1 -1
- package/dist/lib/output/plugins/AssetsPlugin.d.ts +1 -0
- package/dist/lib/output/plugins/AssetsPlugin.js +13 -15
- package/dist/lib/output/plugins/IconsPlugin.js +1 -3
- package/dist/lib/output/plugins/JavascriptIndexPlugin.d.ts +0 -8
- package/dist/lib/output/plugins/JavascriptIndexPlugin.js +4 -18
- package/dist/lib/output/plugins/NavigationPlugin.js +2 -5
- package/dist/lib/output/plugins/SitemapPlugin.js +3 -3
- package/dist/lib/output/renderer.d.ts +11 -4
- package/dist/lib/output/renderer.js +11 -21
- package/dist/lib/output/themes/MarkedPlugin.js +4 -4
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +4 -5
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +0 -2
- package/dist/lib/output/themes/default/layouts/default.js +0 -1
- package/dist/lib/output/themes/default/partials/comment.js +2 -3
- package/dist/lib/output/themes/default/partials/navigation.js +1 -1
- package/dist/lib/output/themes/default/templates/hierarchy.js +1 -1
- package/dist/lib/serialization/events.d.ts +2 -3
- package/dist/lib/serialization/events.js +2 -4
- package/dist/lib/serialization/index.d.ts +1 -1
- package/dist/lib/serialization/serializer.d.ts +10 -5
- package/dist/lib/serialization/serializer.js +6 -6
- package/dist/lib/utils/component.d.ts +4 -18
- package/dist/lib/utils/component.js +1 -39
- package/dist/lib/utils/events.d.ts +18 -113
- package/dist/lib/utils/events.js +33 -374
- package/dist/lib/utils/highlighter.js +1 -1
- package/dist/lib/utils/index.d.ts +1 -1
- package/dist/lib/utils/index.js +1 -2
- package/dist/lib/utils/minimalSourceFile.js +1 -1
- package/dist/lib/utils/options/declaration.d.ts +0 -1
- package/dist/lib/utils/options/options.js +3 -3
- package/dist/lib/utils/options/readers/typedoc.js +1 -1
- package/dist/lib/utils/options/sources/typedoc.js +1 -4
- package/dist/lib/utils/options/tsdoc-defaults.d.ts +3 -3
- package/dist/lib/utils/options/tsdoc-defaults.js +11 -12
- package/package.json +7 -6
- package/tsdoc.json +9 -1
- package/dist/lib/output/themes/default/partials/analytics.d.ts +0 -3
- package/dist/lib/output/themes/default/partials/analytics.js +0 -19
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { Application } from "./lib/application";
|
|
2
|
-
export { EventDispatcher
|
|
1
|
+
export { Application, type ApplicationEvents } from "./lib/application";
|
|
2
|
+
export { EventDispatcher } from "./lib/utils/events";
|
|
3
3
|
export { resetReflectionID } from "./lib/models/reflections/abstract";
|
|
4
4
|
/**
|
|
5
5
|
* All symbols documented under the Models namespace are also available in the root import.
|
|
@@ -17,13 +17,12 @@ export * as Models from "./lib/models";
|
|
|
17
17
|
*/
|
|
18
18
|
export * as Configuration from "./lib/utils/options";
|
|
19
19
|
export * from "./lib/models";
|
|
20
|
-
export { Converter, Context, type CommentParserConfig, type DeclarationReference, type SymbolReference, type ComponentPath, type Meaning, type MeaningKeyword, type ExternalResolveResult, type ExternalSymbolResolver, } from "./lib/converter";
|
|
20
|
+
export { Converter, Context, type CommentParserConfig, type DeclarationReference, type SymbolReference, type ComponentPath, type Meaning, type MeaningKeyword, type ExternalResolveResult, type ExternalSymbolResolver, type ConverterEvents, } from "./lib/converter";
|
|
21
21
|
export { Renderer, DefaultTheme, DefaultThemeRenderContext, Slugger, UrlMapping, Theme, PageEvent, RendererEvent, MarkdownEvent, IndexEvent, } from "./lib/output";
|
|
22
|
-
export type { RenderTemplate, RendererHooks, NavigationElement, } from "./lib/output";
|
|
22
|
+
export type { RenderTemplate, RendererHooks, NavigationElement, RendererEvents, } from "./lib/output";
|
|
23
23
|
export { ArgumentsReader, Option, CommentStyle, JSX, LogLevel, Logger, Options, PackageJsonReader, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, EventHooks, MinimalSourceFile, normalizePath, } from "./lib/utils";
|
|
24
24
|
export type { OptionsReader, TypeDocOptions, TypeDocOptionMap, ValidationOptions, TypeDocOptionValues, KeyToDeclaration, DeclarationOption, DeclarationOptionBase, StringDeclarationOption, NumberDeclarationOption, BooleanDeclarationOption, ArrayDeclarationOption, MixedDeclarationOption, ObjectDeclarationOption, MapDeclarationOption, FlagsDeclarationOption, DeclarationOptionToOptionType, SortStrategy, ParameterTypeToOptionTypeMap, DocumentationEntryPoint, ManuallyValidatedOption, EnumKeys, JsDocCompatibility, } from "./lib/utils";
|
|
25
|
-
export type
|
|
26
|
-
export { JSONOutput, Serializer, Deserializer, type Deserializable, type DeserializerComponent, type SerializerComponent, SerializeEvent, } from "./lib/serialization";
|
|
25
|
+
export { JSONOutput, Serializer, type SerializerEvents, Deserializer, type Deserializable, type DeserializerComponent, type SerializerComponent, SerializeEvent, } from "./lib/serialization";
|
|
27
26
|
export * as Internationalization from "./lib/internationalization/index";
|
|
28
27
|
import TypeScript from "typescript";
|
|
29
28
|
export { TypeScript };
|
package/dist/index.js
CHANGED
|
@@ -29,12 +29,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.TypeScript = exports.Internationalization = exports.SerializeEvent = exports.Deserializer = exports.Serializer = exports.JSONOutput = exports.normalizePath = 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.Option = exports.ArgumentsReader = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.Slugger = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.Configuration = exports.Models = exports.resetReflectionID = exports.
|
|
32
|
+
exports.TypeScript = exports.Internationalization = exports.SerializeEvent = exports.Deserializer = exports.Serializer = exports.JSONOutput = exports.normalizePath = 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.Option = exports.ArgumentsReader = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.Slugger = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.Configuration = exports.Models = exports.resetReflectionID = exports.EventDispatcher = exports.Application = void 0;
|
|
33
33
|
var application_1 = require("./lib/application");
|
|
34
34
|
Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return application_1.Application; } });
|
|
35
35
|
var events_1 = require("./lib/utils/events");
|
|
36
36
|
Object.defineProperty(exports, "EventDispatcher", { enumerable: true, get: function () { return events_1.EventDispatcher; } });
|
|
37
|
-
Object.defineProperty(exports, "Event", { enumerable: true, get: function () { return events_1.Event; } });
|
|
38
37
|
var abstract_1 = require("./lib/models/reflections/abstract");
|
|
39
38
|
Object.defineProperty(exports, "resetReflectionID", { enumerable: true, get: function () { return abstract_1.resetReflectionID; } });
|
|
40
39
|
/**
|
|
@@ -10,6 +10,11 @@ import { type DocumentationEntryPoint, EntryPointStrategy } from "./utils/entry-
|
|
|
10
10
|
import { Internationalization } from "./internationalization/internationalization";
|
|
11
11
|
import { FileRegistry } from "./models/FileRegistry";
|
|
12
12
|
export declare function createAppForTesting(): Application;
|
|
13
|
+
export interface ApplicationEvents {
|
|
14
|
+
bootstrapEnd: [Application];
|
|
15
|
+
reviveProject: [ProjectReflection];
|
|
16
|
+
validateProject: [ProjectReflection];
|
|
17
|
+
}
|
|
13
18
|
/**
|
|
14
19
|
* The default TypeDoc main application class.
|
|
15
20
|
*
|
|
@@ -28,7 +33,7 @@ export declare function createAppForTesting(): Application;
|
|
|
28
33
|
* Access to an Application instance can be retrieved with {@link Application.bootstrap} or
|
|
29
34
|
* {@link Application.bootstrapWithPlugins}. It can not be constructed manually.
|
|
30
35
|
*/
|
|
31
|
-
export declare class Application extends ChildableComponent<Application, AbstractComponent<Application
|
|
36
|
+
export declare class Application extends ChildableComponent<Application, AbstractComponent<Application, {}>, ApplicationEvents> {
|
|
32
37
|
/**
|
|
33
38
|
* The converter used to create the declaration reflections.
|
|
34
39
|
*/
|
|
@@ -76,17 +81,17 @@ export declare class Application extends ChildableComponent<Application, Abstrac
|
|
|
76
81
|
* Emitted after plugins have been loaded and options have been read, but before they have been frozen.
|
|
77
82
|
* The listener will be given an instance of {@link Application}.
|
|
78
83
|
*/
|
|
79
|
-
static readonly EVENT_BOOTSTRAP_END:
|
|
84
|
+
static readonly EVENT_BOOTSTRAP_END: "bootstrapEnd";
|
|
80
85
|
/**
|
|
81
86
|
* Emitted after a project has been deserialized from JSON.
|
|
82
87
|
* The listener will be given an instance of {@link ProjectReflection}.
|
|
83
88
|
*/
|
|
84
|
-
static readonly EVENT_PROJECT_REVIVE:
|
|
89
|
+
static readonly EVENT_PROJECT_REVIVE: "reviveProject";
|
|
85
90
|
/**
|
|
86
91
|
* Emitted when validation is being run.
|
|
87
92
|
* The listener will be given an instance of {@link ProjectReflection}.
|
|
88
93
|
*/
|
|
89
|
-
static readonly EVENT_VALIDATE_PROJECT:
|
|
94
|
+
static readonly EVENT_VALIDATE_PROJECT: "validateProject";
|
|
90
95
|
/**
|
|
91
96
|
* Create a new TypeDoc application instance.
|
|
92
97
|
*/
|
package/dist/lib/application.js
CHANGED
|
@@ -204,8 +204,8 @@ let Application = (() => {
|
|
|
204
204
|
_Application_entryPointStrategy_accessor_storage.set(this, (__runInitializers(this, _skipErrorChecking_extraInitializers), __runInitializers(this, _entryPointStrategy_initializers, void 0)));
|
|
205
205
|
_Application_entryPoints_accessor_storage.set(this, (__runInitializers(this, _entryPointStrategy_extraInitializers), __runInitializers(this, _entryPoints_initializers, void 0)));
|
|
206
206
|
__runInitializers(this, _entryPoints_extraInitializers);
|
|
207
|
-
this.converter =
|
|
208
|
-
this.renderer =
|
|
207
|
+
this.converter = new index_1.Converter(this);
|
|
208
|
+
this.renderer = new renderer_1.Renderer(this);
|
|
209
209
|
this.logger.i18n = this.i18n;
|
|
210
210
|
}
|
|
211
211
|
/**
|
|
@@ -496,6 +496,7 @@ let Application = (() => {
|
|
|
496
496
|
this.logger.error(this.i18n.failed_to_find_packages());
|
|
497
497
|
return;
|
|
498
498
|
}
|
|
499
|
+
const origFiles = this.files;
|
|
499
500
|
const origOptions = this.options;
|
|
500
501
|
const projects = [];
|
|
501
502
|
const projectsToConvert = [];
|
|
@@ -526,14 +527,23 @@ let Application = (() => {
|
|
|
526
527
|
for (const { dir, options } of projectsToConvert) {
|
|
527
528
|
this.logger.info(this.i18n.converting_project_at_0((0, paths_1.nicePath)(dir)));
|
|
528
529
|
this.options = options;
|
|
529
|
-
|
|
530
|
+
this.files = new FileRegistry_1.ValidatingFileRegistry();
|
|
531
|
+
let project = await this.convert();
|
|
530
532
|
if (project) {
|
|
531
533
|
this.validate(project);
|
|
532
|
-
|
|
534
|
+
const serialized = this.serializer.projectToObject(project, process.cwd());
|
|
535
|
+
projects.push(serialized);
|
|
533
536
|
}
|
|
537
|
+
// When debugging memory issues, it's useful to set these
|
|
538
|
+
// here so that a breakpoint on resetReflectionID below
|
|
539
|
+
// gets the memory as it ought to be with all TS objects released.
|
|
540
|
+
project = undefined;
|
|
541
|
+
this.files = undefined;
|
|
542
|
+
// global.gc!();
|
|
534
543
|
(0, abstract_1.resetReflectionID)();
|
|
535
544
|
}
|
|
536
545
|
this.options = origOptions;
|
|
546
|
+
this.files = origFiles;
|
|
537
547
|
if (projects.length !== packageDirs.length) {
|
|
538
548
|
this.logger.error(this.i18n.failed_to_convert_packages());
|
|
539
549
|
return;
|
|
@@ -99,12 +99,14 @@ function parseCommentString(tokens, config, file, logger, files) {
|
|
|
99
99
|
inheritDocTag: true,
|
|
100
100
|
},
|
|
101
101
|
};
|
|
102
|
+
const reentry = new textParser_1.TextParserReentryState();
|
|
102
103
|
const content = [];
|
|
103
104
|
const lexer = makeLookaheadGenerator(tokens);
|
|
104
105
|
let atNewLine = false;
|
|
105
106
|
while (!lexer.done()) {
|
|
106
107
|
let consume = true;
|
|
107
108
|
const next = lexer.peek();
|
|
109
|
+
reentry.checkState(next);
|
|
108
110
|
switch (next.kind) {
|
|
109
111
|
case lexer_1.TokenSyntaxKind.TypeAnnotation:
|
|
110
112
|
// Shouldn't have been produced by our lexer
|
|
@@ -114,7 +116,7 @@ function parseCommentString(tokens, config, file, logger, files) {
|
|
|
114
116
|
case lexer_1.TokenSyntaxKind.Text:
|
|
115
117
|
case lexer_1.TokenSyntaxKind.Tag:
|
|
116
118
|
case lexer_1.TokenSyntaxKind.CloseBrace:
|
|
117
|
-
(0, textParser_1.textContent)(file.fileName, next, logger.i18n, (msg, token) => logger.warn(msg, token.pos, file), content, files, atNewLine);
|
|
119
|
+
(0, textParser_1.textContent)(file.fileName, next, logger.i18n, (msg, token) => logger.warn(msg, token.pos, file), content, files, atNewLine, reentry);
|
|
118
120
|
break;
|
|
119
121
|
case lexer_1.TokenSyntaxKind.Code:
|
|
120
122
|
content.push({ kind: "code", text: next.text });
|
|
@@ -257,7 +259,7 @@ function defaultBlockContent(comment, lexer, config, i18n, warning, files) {
|
|
|
257
259
|
const content = blockContent(comment, lexer, config, i18n, () => { }, tempRegistry);
|
|
258
260
|
const end = lexer.done() || lexer.peek();
|
|
259
261
|
lexer.release();
|
|
260
|
-
if (content.some((part) => part.kind === "code")) {
|
|
262
|
+
if (content.some((part) => part.kind === "code" || part.kind === "inline-tag")) {
|
|
261
263
|
return blockContent(comment, lexer, config, i18n, warning, files);
|
|
262
264
|
}
|
|
263
265
|
const tokens = [];
|
|
@@ -367,8 +369,10 @@ function exampleBlock(comment, lexer, config, i18n, warning, files) {
|
|
|
367
369
|
function blockContent(comment, lexer, config, i18n, warning, files) {
|
|
368
370
|
const content = [];
|
|
369
371
|
let atNewLine = true;
|
|
372
|
+
const reentry = new textParser_1.TextParserReentryState();
|
|
370
373
|
loop: while (!lexer.done()) {
|
|
371
374
|
const next = lexer.peek();
|
|
375
|
+
reentry.checkState(next);
|
|
372
376
|
let consume = true;
|
|
373
377
|
switch (next.kind) {
|
|
374
378
|
case lexer_1.TokenSyntaxKind.NewLine:
|
|
@@ -376,7 +380,7 @@ function blockContent(comment, lexer, config, i18n, warning, files) {
|
|
|
376
380
|
break;
|
|
377
381
|
case lexer_1.TokenSyntaxKind.Text:
|
|
378
382
|
(0, textParser_1.textContent)(comment.sourcePath, next, i18n, warning,
|
|
379
|
-
/*out*/ content, files, atNewLine);
|
|
383
|
+
/*out*/ content, files, atNewLine, reentry);
|
|
380
384
|
break;
|
|
381
385
|
case lexer_1.TokenSyntaxKind.Code:
|
|
382
386
|
content.push({ kind: "code", text: next.text });
|
|
@@ -9,8 +9,19 @@ import type { TranslationProxy, TranslatedString } from "../../internationalizat
|
|
|
9
9
|
import type { CommentDisplayPart } from "../../models";
|
|
10
10
|
import type { FileRegistry } from "../../models/FileRegistry";
|
|
11
11
|
import { type Token } from "./lexer";
|
|
12
|
+
/**
|
|
13
|
+
* This is incredibly unfortunate. The comment lexer owns the responsibility
|
|
14
|
+
* for splitting up text into text/code, this is totally fine for HTML links
|
|
15
|
+
* but for markdown links, ``[`code`](./link)`` is valid, so we need to keep
|
|
16
|
+
* track of state across calls to {@link textContent}.
|
|
17
|
+
*/
|
|
18
|
+
export declare class TextParserReentryState {
|
|
19
|
+
withinLinkLabel: boolean;
|
|
20
|
+
private lastPartWasNewline;
|
|
21
|
+
checkState(token: Token): void;
|
|
22
|
+
}
|
|
12
23
|
/**
|
|
13
24
|
* Look for relative links within a piece of text and add them to the {@link FileRegistry}
|
|
14
25
|
* so that they can be correctly resolved during rendering.
|
|
15
26
|
*/
|
|
16
|
-
export declare function textContent(sourcePath: string, token: Token, i18n: TranslationProxy, warning: (msg: TranslatedString, token: Token) => void, outContent: CommentDisplayPart[], files: FileRegistry, atNewLine: boolean): void;
|
|
27
|
+
export declare function textContent(sourcePath: string, token: Token, i18n: TranslationProxy, warning: (msg: TranslatedString, token: Token) => void, outContent: CommentDisplayPart[], files: FileRegistry, atNewLine: boolean, reentry: TextParserReentryState): void;
|
|
@@ -3,21 +3,50 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TextParserReentryState = void 0;
|
|
6
7
|
exports.textContent = textContent;
|
|
7
8
|
const html_1 = require("../../utils/html");
|
|
8
9
|
const lexer_1 = require("./lexer");
|
|
9
10
|
const markdown_it_1 = __importDefault(require("markdown-it"));
|
|
10
11
|
const MdHelpers = new markdown_it_1.default().helpers;
|
|
12
|
+
/**
|
|
13
|
+
* This is incredibly unfortunate. The comment lexer owns the responsibility
|
|
14
|
+
* for splitting up text into text/code, this is totally fine for HTML links
|
|
15
|
+
* but for markdown links, ``[`code`](./link)`` is valid, so we need to keep
|
|
16
|
+
* track of state across calls to {@link textContent}.
|
|
17
|
+
*/
|
|
18
|
+
class TextParserReentryState {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.withinLinkLabel = false;
|
|
21
|
+
this.lastPartWasNewline = false;
|
|
22
|
+
}
|
|
23
|
+
checkState(token) {
|
|
24
|
+
switch (token.kind) {
|
|
25
|
+
case lexer_1.TokenSyntaxKind.Code:
|
|
26
|
+
if (/\n\s*\n/.test(token.text)) {
|
|
27
|
+
this.withinLinkLabel = false;
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
case lexer_1.TokenSyntaxKind.NewLine:
|
|
31
|
+
if (this.lastPartWasNewline) {
|
|
32
|
+
this.withinLinkLabel = false;
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
this.lastPartWasNewline = token.kind === lexer_1.TokenSyntaxKind.NewLine;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.TextParserReentryState = TextParserReentryState;
|
|
11
40
|
/**
|
|
12
41
|
* Look for relative links within a piece of text and add them to the {@link FileRegistry}
|
|
13
42
|
* so that they can be correctly resolved during rendering.
|
|
14
43
|
*/
|
|
15
|
-
function textContent(sourcePath, token, i18n, warning, outContent, files, atNewLine) {
|
|
44
|
+
function textContent(sourcePath, token, i18n, warning, outContent, files, atNewLine, reentry) {
|
|
16
45
|
let lastPartEnd = 0;
|
|
17
46
|
const data = {
|
|
18
47
|
sourcePath,
|
|
19
48
|
token,
|
|
20
|
-
pos: 0,
|
|
49
|
+
pos: 0, // relative to the token
|
|
21
50
|
i18n,
|
|
22
51
|
warning,
|
|
23
52
|
files: files,
|
|
@@ -38,13 +67,14 @@ function textContent(sourcePath, token, i18n, warning, outContent, files, atNewL
|
|
|
38
67
|
if (!ref.target) {
|
|
39
68
|
warning(i18n.relative_path_0_does_not_exist(token.text.slice(ref.pos, ref.end)), {
|
|
40
69
|
kind: lexer_1.TokenSyntaxKind.Text,
|
|
41
|
-
|
|
70
|
+
// ref.pos is relative to the token, but this pos is relative to the file.
|
|
71
|
+
pos: token.pos + ref.pos,
|
|
42
72
|
text: token.text.slice(ref.pos, ref.end),
|
|
43
73
|
});
|
|
44
74
|
}
|
|
45
75
|
}
|
|
46
76
|
while (data.pos < token.text.length) {
|
|
47
|
-
const link = checkMarkdownLink(data);
|
|
77
|
+
const link = checkMarkdownLink(data, reentry);
|
|
48
78
|
if (link) {
|
|
49
79
|
addRef(link);
|
|
50
80
|
continue;
|
|
@@ -76,28 +106,44 @@ function textContent(sourcePath, token, i18n, warning, outContent, files, atNewL
|
|
|
76
106
|
* Reference: https://github.com/markdown-it/markdown-it/blob/14.1.0/lib/rules_inline/image.mjs
|
|
77
107
|
*
|
|
78
108
|
*/
|
|
79
|
-
function checkMarkdownLink(data) {
|
|
109
|
+
function checkMarkdownLink(data, reentry) {
|
|
80
110
|
const { token, sourcePath, files } = data;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
111
|
+
let searchStart;
|
|
112
|
+
if (reentry.withinLinkLabel) {
|
|
113
|
+
searchStart = data.pos;
|
|
114
|
+
reentry.withinLinkLabel = false;
|
|
115
|
+
}
|
|
116
|
+
else if (token.text[data.pos] === "[") {
|
|
117
|
+
searchStart = data.pos + 1;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const labelEnd = findLabelEnd(token.text, searchStart);
|
|
123
|
+
if (labelEnd === -1) {
|
|
124
|
+
// This markdown link might be split across multiple display parts
|
|
125
|
+
// [ `text` ](link)
|
|
126
|
+
// ^^ text
|
|
127
|
+
// ^^^^^^ code
|
|
128
|
+
// ^^^^^^^^ text
|
|
129
|
+
reentry.withinLinkLabel = true;
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (token.text[labelEnd] === "]" && token.text[labelEnd + 1] === "(") {
|
|
133
|
+
const link = MdHelpers.parseLinkDestination(token.text, labelEnd + 2, token.text.length);
|
|
134
|
+
if (link.ok) {
|
|
135
|
+
// Only make a relative-link display part if it's actually a relative link.
|
|
136
|
+
// Discard protocol:// links, unix style absolute paths, and windows style absolute paths.
|
|
137
|
+
if (isRelativeLink(link.str)) {
|
|
138
|
+
return {
|
|
139
|
+
pos: labelEnd + 2,
|
|
140
|
+
end: link.pos,
|
|
141
|
+
target: files.register(sourcePath, link.str),
|
|
142
|
+
};
|
|
100
143
|
}
|
|
144
|
+
// This was a link, skip ahead to ensure we don't happen to parse
|
|
145
|
+
// something else as a link within the link.
|
|
146
|
+
data.pos = link.pos - 1;
|
|
101
147
|
}
|
|
102
148
|
}
|
|
103
149
|
}
|
|
@@ -175,13 +221,14 @@ function checkAttribute(data, attr) {
|
|
|
175
221
|
}
|
|
176
222
|
}
|
|
177
223
|
function isRelativeLink(link) {
|
|
178
|
-
return !/^[a-z]+:\/\/|^\/|^[a-z]
|
|
224
|
+
return !/^[a-z]+:\/\/|^\/|^[a-z]:\\|^#/i.test(link);
|
|
179
225
|
}
|
|
180
226
|
function findLabelEnd(text, pos) {
|
|
181
227
|
while (pos < text.length) {
|
|
182
228
|
switch (text[pos]) {
|
|
183
229
|
case "\n":
|
|
184
230
|
case "]":
|
|
231
|
+
case "[":
|
|
185
232
|
return pos;
|
|
186
233
|
}
|
|
187
234
|
++pos;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, AbstractComponent } from "../utils/component";
|
|
2
2
|
import type { Converter } from "./converter";
|
|
3
3
|
export { Component };
|
|
4
|
-
export declare abstract class ConverterComponent extends AbstractComponent<Converter> {
|
|
4
|
+
export declare abstract class ConverterComponent extends AbstractComponent<Converter, {}> {
|
|
5
5
|
}
|
|
@@ -71,16 +71,6 @@ export declare class Context {
|
|
|
71
71
|
* @param symbol The symbol the given reflection was resolved from.
|
|
72
72
|
*/
|
|
73
73
|
registerReflection(reflection: Reflection, symbol: ts.Symbol | undefined): void;
|
|
74
|
-
/**
|
|
75
|
-
* Trigger a node reflection event.
|
|
76
|
-
*
|
|
77
|
-
* All events are dispatched on the current converter instance.
|
|
78
|
-
*
|
|
79
|
-
* @param name The name of the event that should be triggered.
|
|
80
|
-
* @param reflection The triggering reflection.
|
|
81
|
-
* @param node The triggering TypeScript node if available.
|
|
82
|
-
*/
|
|
83
|
-
trigger(name: string, reflection: Reflection, node?: ts.Node): void;
|
|
84
74
|
/** @internal */
|
|
85
75
|
setActiveProgram(program: ts.Program | undefined): void;
|
|
86
76
|
getComment(symbol: ts.Symbol, kind: ReflectionKind): import("../models/index").Comment | undefined;
|
|
@@ -169,18 +169,6 @@ class Context {
|
|
|
169
169
|
registerReflection(reflection, symbol) {
|
|
170
170
|
this.project.registerReflection(reflection, symbol, void 0);
|
|
171
171
|
}
|
|
172
|
-
/**
|
|
173
|
-
* Trigger a node reflection event.
|
|
174
|
-
*
|
|
175
|
-
* All events are dispatched on the current converter instance.
|
|
176
|
-
*
|
|
177
|
-
* @param name The name of the event that should be triggered.
|
|
178
|
-
* @param reflection The triggering reflection.
|
|
179
|
-
* @param node The triggering TypeScript node if available.
|
|
180
|
-
*/
|
|
181
|
-
trigger(name, reflection, node) {
|
|
182
|
-
this.converter.trigger(name, this, reflection, node);
|
|
183
|
-
}
|
|
184
172
|
/** @internal */
|
|
185
173
|
setActiveProgram(program) {
|
|
186
174
|
this._program = program;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import type { Application } from "../application";
|
|
3
|
-
import { Comment, type CommentDisplayPart, type ContainerReflection, ProjectReflection, type Reflection, type ReflectionSymbolId, type SomeType } from "../models/index";
|
|
3
|
+
import { Comment, type CommentDisplayPart, type ContainerReflection, type DeclarationReflection, type ParameterReflection, ProjectReflection, type Reflection, type ReflectionSymbolId, type SignatureReflection, type SomeType, type TypeParameterReflection } from "../models/index";
|
|
4
4
|
import { Context } from "./context";
|
|
5
5
|
import { ConverterComponent } from "./components";
|
|
6
6
|
import { ChildableComponent } from "../utils/component";
|
|
@@ -11,10 +11,30 @@ import type { CommentStyle, ValidationOptions } from "../utils/options/declarati
|
|
|
11
11
|
import { type ExternalSymbolResolver, type ExternalResolveResult } from "./comments/linkResolver";
|
|
12
12
|
import { type DeclarationReference } from "./comments/declarationReference";
|
|
13
13
|
import type { FileRegistry } from "../models/FileRegistry";
|
|
14
|
+
export interface ConverterEvents {
|
|
15
|
+
begin: [Context];
|
|
16
|
+
end: [Context];
|
|
17
|
+
createDeclaration: [Context, DeclarationReflection];
|
|
18
|
+
createSignature: [
|
|
19
|
+
Context,
|
|
20
|
+
SignatureReflection,
|
|
21
|
+
(ts.SignatureDeclaration | ts.IndexSignatureDeclaration | ts.JSDocSignature)?,
|
|
22
|
+
ts.Signature?
|
|
23
|
+
];
|
|
24
|
+
createParameter: [Context, ParameterReflection, ts.Node?];
|
|
25
|
+
createTypeParameter: [
|
|
26
|
+
Context,
|
|
27
|
+
TypeParameterReflection,
|
|
28
|
+
ts.TypeParameterDeclaration?
|
|
29
|
+
];
|
|
30
|
+
resolveBegin: [Context];
|
|
31
|
+
resolveReflection: [Context, Reflection];
|
|
32
|
+
resolveEnd: [Context];
|
|
33
|
+
}
|
|
14
34
|
/**
|
|
15
35
|
* Compiles source files using TypeScript and converts compiler symbols to reflections.
|
|
16
36
|
*/
|
|
17
|
-
export declare class Converter extends ChildableComponent<Application, ConverterComponent> {
|
|
37
|
+
export declare class Converter extends ChildableComponent<Application, ConverterComponent, ConverterEvents> {
|
|
18
38
|
/** @internal */
|
|
19
39
|
accessor externalPattern: string[];
|
|
20
40
|
private externalPatternCache?;
|
|
@@ -329,7 +329,6 @@ let Converter = (() => {
|
|
|
329
329
|
? context.getComment(symbol, context.project.kind)
|
|
330
330
|
: context.getFileComment(node);
|
|
331
331
|
this.processDocumentTags(context.project, context.project);
|
|
332
|
-
context.trigger(Converter.EVENT_CREATE_DECLARATION, context.project);
|
|
333
332
|
moduleContext = context;
|
|
334
333
|
}
|
|
335
334
|
else {
|
|
@@ -27,6 +27,6 @@ function convertIndexSignatures(context, symbol) {
|
|
|
27
27
|
context.registerReflection(index, indexSymbol);
|
|
28
28
|
context.scope.indexSignatures ||= [];
|
|
29
29
|
context.scope.indexSignatures.push(index);
|
|
30
|
-
context.trigger(converter_events_1.ConverterEvents.CREATE_SIGNATURE, index, indexDeclaration);
|
|
30
|
+
context.converter.trigger(converter_events_1.ConverterEvents.CREATE_SIGNATURE, context, index, indexDeclaration);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -111,7 +111,7 @@ function convertParameters(context, sigRef, parameters, parameterNodes) {
|
|
|
111
111
|
}
|
|
112
112
|
paramRefl.comment ||= context.getComment(param, paramRefl.kind);
|
|
113
113
|
context.registerReflection(paramRefl, param);
|
|
114
|
-
context.trigger(converter_events_1.ConverterEvents.CREATE_PARAMETER, paramRefl);
|
|
114
|
+
context.converter.trigger(converter_events_1.ConverterEvents.CREATE_PARAMETER, context, paramRefl);
|
|
115
115
|
let type;
|
|
116
116
|
if (declaration) {
|
|
117
117
|
type = context.checker.getTypeOfSymbolAtLocation(param, declaration);
|
|
@@ -164,7 +164,7 @@ function convertParameterNodes(context, sigRef, parameters) {
|
|
|
164
164
|
paramRefl.comment = context.getJsDocComment(param);
|
|
165
165
|
}
|
|
166
166
|
context.registerReflection(paramRefl, context.getSymbolAtLocation(param));
|
|
167
|
-
context.trigger(converter_events_1.ConverterEvents.CREATE_PARAMETER, paramRefl);
|
|
167
|
+
context.converter.trigger(converter_events_1.ConverterEvents.CREATE_PARAMETER, context, paramRefl);
|
|
168
168
|
paramRefl.type = context.converter.convertType(context.withScope(paramRefl), typescript_1.default.isParameter(param) ? param.type : param.typeExpression?.type);
|
|
169
169
|
const isOptional = typescript_1.default.isParameter(param)
|
|
170
170
|
? !!param.questionToken
|
|
@@ -221,7 +221,7 @@ function convertTypeParameters(context, parent, parameters) {
|
|
|
221
221
|
paramRefl.flags.setFlag(models_1.ReflectionFlag.Const, true);
|
|
222
222
|
}
|
|
223
223
|
context.registerReflection(paramRefl, param.getSymbol());
|
|
224
|
-
context.trigger(converter_events_1.ConverterEvents.CREATE_TYPE_PARAMETER, paramRefl);
|
|
224
|
+
context.converter.trigger(converter_events_1.ConverterEvents.CREATE_TYPE_PARAMETER, context, paramRefl);
|
|
225
225
|
return paramRefl;
|
|
226
226
|
});
|
|
227
227
|
}
|
|
@@ -244,7 +244,7 @@ function createTypeParamReflection(param, context) {
|
|
|
244
244
|
if (typescript_1.default.isJSDocTemplateTag(param.parent)) {
|
|
245
245
|
paramRefl.comment = context.getJsDocComment(param.parent);
|
|
246
246
|
}
|
|
247
|
-
context.trigger(converter_events_1.ConverterEvents.CREATE_TYPE_PARAMETER, paramRefl, param);
|
|
247
|
+
context.converter.trigger(converter_events_1.ConverterEvents.CREATE_TYPE_PARAMETER, context, paramRefl, param);
|
|
248
248
|
return paramRefl;
|
|
249
249
|
}
|
|
250
250
|
function convertTemplateParameterNodes(context, nodes) {
|
|
@@ -266,7 +266,7 @@ function convertTemplateParameterNodes(context, nodes) {
|
|
|
266
266
|
if (typescript_1.default.isJSDocTemplateTag(param.parent)) {
|
|
267
267
|
paramRefl.comment = context.getJsDocComment(param.parent);
|
|
268
268
|
}
|
|
269
|
-
context.trigger(converter_events_1.ConverterEvents.CREATE_TYPE_PARAMETER, paramRefl, param);
|
|
269
|
+
context.converter.trigger(converter_events_1.ConverterEvents.CREATE_TYPE_PARAMETER, context, paramRefl, param);
|
|
270
270
|
return paramRefl;
|
|
271
271
|
});
|
|
272
272
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Context } from "./context";
|
|
2
|
-
export { Converter } from "./converter";
|
|
2
|
+
export { Converter, type ConverterEvents } from "./converter";
|
|
3
3
|
export type { CommentParserConfig } from "./comments/index";
|
|
4
4
|
export { convertDefaultValue, convertExpression } from "./convert-expression";
|
|
5
5
|
export type { DeclarationReference, SymbolReference, ComponentPath, Meaning, MeaningKeyword, } from "./comments/declarationReference";
|
|
@@ -61,7 +61,7 @@ function convertJsDocSignature(context, node) {
|
|
|
61
61
|
}
|
|
62
62
|
const reflection = new models_1.DeclarationReflection("__type", models_1.ReflectionKind.TypeLiteral, context.scope);
|
|
63
63
|
context.registerReflection(reflection, symbol);
|
|
64
|
-
context.trigger(converter_events_1.ConverterEvents.CREATE_DECLARATION, reflection);
|
|
64
|
+
context.converter.trigger(converter_events_1.ConverterEvents.CREATE_DECLARATION, context, reflection);
|
|
65
65
|
const signature = new models_1.SignatureReflection("__type", models_1.ReflectionKind.CallSignature, reflection);
|
|
66
66
|
context.project.registerSymbolId(signature, new ReflectionSymbolId_1.ReflectionSymbolId(symbol, node));
|
|
67
67
|
context.registerReflection(signature, void 0);
|
|
@@ -100,10 +100,8 @@ let CategoryPlugin = (() => {
|
|
|
100
100
|
* Create a new CategoryPlugin instance.
|
|
101
101
|
*/
|
|
102
102
|
initialize() {
|
|
103
|
-
this.
|
|
104
|
-
|
|
105
|
-
[converter_1.Converter.EVENT_RESOLVE_END]: this.onEndResolve,
|
|
106
|
-
}, undefined, -200);
|
|
103
|
+
this.owner.on(converter_1.Converter.EVENT_BEGIN, this.onBegin.bind(this), -200);
|
|
104
|
+
this.owner.on(converter_1.Converter.EVENT_RESOLVE_END, this.onEndResolve.bind(this), -200);
|
|
107
105
|
}
|
|
108
106
|
/**
|
|
109
107
|
* Triggered when the converter begins converting a project.
|
|
@@ -215,15 +215,13 @@ let CommentPlugin = (() => {
|
|
|
215
215
|
* Create a new CommentPlugin instance.
|
|
216
216
|
*/
|
|
217
217
|
initialize() {
|
|
218
|
-
this.
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
this._excludeKinds = undefined;
|
|
226
|
-
},
|
|
218
|
+
this.owner.on(converter_1.Converter.EVENT_CREATE_DECLARATION, this.onDeclaration.bind(this));
|
|
219
|
+
this.owner.on(converter_1.Converter.EVENT_CREATE_SIGNATURE, this.onDeclaration.bind(this));
|
|
220
|
+
this.owner.on(converter_1.Converter.EVENT_CREATE_TYPE_PARAMETER, this.onCreateTypeParameter.bind(this));
|
|
221
|
+
this.owner.on(converter_1.Converter.EVENT_RESOLVE_BEGIN, this.onBeginResolve.bind(this));
|
|
222
|
+
this.owner.on(converter_1.Converter.EVENT_RESOLVE, this.onResolve.bind(this));
|
|
223
|
+
this.owner.on(converter_1.Converter.EVENT_END, () => {
|
|
224
|
+
this._excludeKinds = undefined;
|
|
227
225
|
});
|
|
228
226
|
}
|
|
229
227
|
/**
|
|
@@ -273,8 +271,7 @@ let CommentPlugin = (() => {
|
|
|
273
271
|
comment.removeModifier("@event");
|
|
274
272
|
comment.removeModifier("@eventProperty");
|
|
275
273
|
}
|
|
276
|
-
if (reflection.kindOf(models_1.ReflectionKind.
|
|
277
|
-
reflection.kind === models_1.ReflectionKind.Project) {
|
|
274
|
+
if (reflection.kindOf(models_1.ReflectionKind.Project | models_1.ReflectionKind.SomeModule)) {
|
|
278
275
|
comment.removeTags("@module");
|
|
279
276
|
comment.removeModifier("@packageDocumentation");
|
|
280
277
|
}
|
|
@@ -340,6 +337,10 @@ let CommentPlugin = (() => {
|
|
|
340
337
|
* @param context The context object describing the current state the converter is in.
|
|
341
338
|
*/
|
|
342
339
|
onBeginResolve(context) {
|
|
340
|
+
if (context.project.comment) {
|
|
341
|
+
this.applyModifiers(context.project, context.project.comment);
|
|
342
|
+
this.removeExcludedTags(context.project.comment);
|
|
343
|
+
}
|
|
343
344
|
const project = context.project;
|
|
344
345
|
const reflections = Object.values(project.reflections);
|
|
345
346
|
// Remove hidden reflections
|
|
@@ -116,16 +116,14 @@ let GroupPlugin = (() => {
|
|
|
116
116
|
* Create a new GroupPlugin instance.
|
|
117
117
|
*/
|
|
118
118
|
initialize() {
|
|
119
|
-
this.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
[converter_1.Converter.EVENT_RESOLVE_END]: this.onEndResolve,
|
|
128
|
-
}, undefined, -100);
|
|
119
|
+
this.owner.on(converter_1.Converter.EVENT_RESOLVE_BEGIN, () => {
|
|
120
|
+
this.sortFunction = (0, sort_1.getSortFunction)(this.application.options);
|
|
121
|
+
GroupPlugin.WEIGHTS = this.groupOrder;
|
|
122
|
+
if (GroupPlugin.WEIGHTS.length === 0) {
|
|
123
|
+
GroupPlugin.WEIGHTS = defaultGroupOrder.map((kind) => this.application.internationalization.kindPluralString(kind));
|
|
124
|
+
}
|
|
125
|
+
}, -100);
|
|
126
|
+
this.owner.on(converter_1.Converter.EVENT_RESOLVE_END, this.onEndResolve.bind(this), -100);
|
|
129
127
|
}
|
|
130
128
|
/**
|
|
131
129
|
* Triggered when the converter has finished resolving a project.
|
|
@@ -70,10 +70,10 @@ let ImplementsPlugin = (() => {
|
|
|
70
70
|
* Create a new ImplementsPlugin instance.
|
|
71
71
|
*/
|
|
72
72
|
initialize() {
|
|
73
|
-
this.
|
|
74
|
-
this.
|
|
75
|
-
this.
|
|
76
|
-
this.
|
|
73
|
+
this.owner.on(converter_1.Converter.EVENT_RESOLVE_END, this.onResolveEnd.bind(this));
|
|
74
|
+
this.owner.on(converter_1.Converter.EVENT_CREATE_DECLARATION, this.onDeclaration.bind(this), -1000);
|
|
75
|
+
this.owner.on(converter_1.Converter.EVENT_CREATE_SIGNATURE, this.onSignature.bind(this), 1000);
|
|
76
|
+
this.application.on(application_events_1.ApplicationEvents.REVIVE, this.resolve.bind(this));
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* Mark all members of the given class to be the implementation of the matching interface member.
|