typedoc 0.24.0-beta.8 → 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/lib/converter/comments/index.d.ts +2 -1
- package/dist/lib/converter/comments/parser.js +32 -2
- package/dist/lib/converter/converter.js +2 -0
- package/dist/lib/converter/types.js +2 -2
- 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/utils/options/declaration.d.ts +13 -0
- package/dist/lib/utils/options/options.js +2 -2
- package/dist/lib/utils/options/sources/typedoc.js +9 -0
- package/package.json +1 -1
|
@@ -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();
|
|
@@ -72,6 +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
|
+
this._config = undefined;
|
|
75
76
|
return project;
|
|
76
77
|
}
|
|
77
78
|
/** @internal */
|
|
@@ -238,6 +239,7 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
|
|
|
238
239
|
blockTags: new Set(this.application.options.getValue("blockTags")),
|
|
239
240
|
inlineTags: new Set(this.application.options.getValue("inlineTags")),
|
|
240
241
|
modifierTags: new Set(this.application.options.getValue("modifierTags")),
|
|
242
|
+
jsDocCompatibility: this.application.options.getValue("jsDocCompatibility"),
|
|
241
243
|
};
|
|
242
244
|
return this._config;
|
|
243
245
|
}
|
|
@@ -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,3 +1,3 @@
|
|
|
1
1
|
import { JSX } from "../../../../utils";
|
|
2
2
|
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
|
|
3
|
-
export declare
|
|
3
|
+
export declare function anchorIcon(context: DefaultThemeRenderContext, anchor: string | undefined): JSX.Element;
|
|
@@ -2,5 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.anchorIcon = void 0;
|
|
4
4
|
const utils_1 = require("../../../../utils");
|
|
5
|
-
|
|
5
|
+
function anchorIcon(context, anchor) {
|
|
6
|
+
if (!anchor)
|
|
7
|
+
return utils_1.JSX.createElement(utils_1.JSX.Fragment, null);
|
|
8
|
+
return (utils_1.JSX.createElement("a", { href: `#${anchor}`, "aria-label": "Permalink", class: "tsd-anchor-icon" }, context.icons.anchor()));
|
|
9
|
+
}
|
|
6
10
|
exports.anchorIcon = anchorIcon;
|
|
@@ -102,6 +102,7 @@ export interface TypeDocOptionMap {
|
|
|
102
102
|
titleLink: string;
|
|
103
103
|
navigationLinks: ManuallyValidatedOption<Record<string, string>>;
|
|
104
104
|
sidebarLinks: ManuallyValidatedOption<Record<string, string>>;
|
|
105
|
+
jsDocCompatibility: JsDocCompatibility;
|
|
105
106
|
commentStyle: typeof CommentStyle;
|
|
106
107
|
useTsLinkResolution: boolean;
|
|
107
108
|
blockTags: `@${string}`[];
|
|
@@ -157,6 +158,18 @@ export type ValidationOptions = {
|
|
|
157
158
|
*/
|
|
158
159
|
notDocumented: boolean;
|
|
159
160
|
};
|
|
161
|
+
export type JsDocCompatibility = {
|
|
162
|
+
/**
|
|
163
|
+
* If set, TypeDoc will treat `@example` blocks as code unless they contain a code block.
|
|
164
|
+
* On by default, this is how VSCode renders blocks.
|
|
165
|
+
*/
|
|
166
|
+
exampleTag: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* If set, TypeDoc will treat `@default` blocks as code unless they contain a code block.
|
|
169
|
+
* On by default, this is how VSCode renders blocks.
|
|
170
|
+
*/
|
|
171
|
+
defaultTag: boolean;
|
|
172
|
+
};
|
|
160
173
|
/**
|
|
161
174
|
* Converts a given TypeDoc option key to the type of the declaration expected.
|
|
162
175
|
*/
|
|
@@ -67,7 +67,7 @@ class Options {
|
|
|
67
67
|
snapshot() {
|
|
68
68
|
const key = {};
|
|
69
69
|
optionSnapshots.set(key, {
|
|
70
|
-
values:
|
|
70
|
+
values: JSON.stringify(this._values),
|
|
71
71
|
set: new Set(this._setOptions),
|
|
72
72
|
});
|
|
73
73
|
return key;
|
|
@@ -78,7 +78,7 @@ class Options {
|
|
|
78
78
|
*/
|
|
79
79
|
restore(snapshot) {
|
|
80
80
|
const data = optionSnapshots.get(snapshot);
|
|
81
|
-
this._values =
|
|
81
|
+
this._values = JSON.parse(data.values);
|
|
82
82
|
this._setOptions = new Set(data.set);
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
@@ -404,6 +404,15 @@ function addTypeDocOptions(options) {
|
|
|
404
404
|
///////////////////////////
|
|
405
405
|
///// Comment Options /////
|
|
406
406
|
///////////////////////////
|
|
407
|
+
options.addDeclaration({
|
|
408
|
+
name: "jsDocCompatibility",
|
|
409
|
+
help: "Sets compatibility options for comment parsing that increase similarity with JSDoc comments.",
|
|
410
|
+
type: declaration_1.ParameterType.Flags,
|
|
411
|
+
defaults: {
|
|
412
|
+
defaultTag: true,
|
|
413
|
+
exampleTag: true,
|
|
414
|
+
},
|
|
415
|
+
});
|
|
407
416
|
options.addDeclaration({
|
|
408
417
|
name: "commentStyle",
|
|
409
418
|
help: "Determines how TypeDoc searches for comments.",
|