typedoc 0.24.0-beta.8 → 0.24.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.
@@ -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,24 +127,54 @@ 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();
144
174
  const content = blockContent(comment, lexer, config, () => { });
145
175
  const end = lexer.done() || lexer.peek();
146
176
  lexer.release();
147
- if (content.some((part) => part.kind === "code")) {
177
+ if (content.some((part) => part.kind === "code" && part.text.startsWith("```"))) {
148
178
  return blockContent(comment, lexer, config, warning);
149
179
  }
150
180
  const tokens = [];
@@ -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 const anchorIcon: (context: DefaultThemeRenderContext, anchor: string | undefined) => JSX.Element;
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
- const anchorIcon = (context, anchor) => (utils_1.JSX.createElement("a", { href: `#${anchor}`, "aria-label": "Permalink", class: "tsd-anchor-icon" }, context.icons.anchor()));
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;
@@ -59,6 +59,7 @@ export interface TypeDocOptionMap {
59
59
  options: string;
60
60
  tsconfig: string;
61
61
  compilerOptions: unknown;
62
+ plugin: string[];
62
63
  entryPoints: string[];
63
64
  entryPointStrategy: typeof EntryPointStrategy;
64
65
  exclude: string[];
@@ -70,9 +71,13 @@ export interface TypeDocOptionMap {
70
71
  excludePrivate: boolean;
71
72
  excludeProtected: boolean;
72
73
  excludeReferences: boolean;
73
- externalSymbolLinkMappings: ManuallyValidatedOption<Record<string, Record<string, string>>>;
74
- media: string;
75
- includes: string;
74
+ name: string;
75
+ includeVersion: boolean;
76
+ disableSources: boolean;
77
+ sourceLinkTemplate: string;
78
+ gitRevision: string;
79
+ gitRemote: string;
80
+ readme: string;
76
81
  out: string;
77
82
  json: string;
78
83
  pretty: boolean;
@@ -82,58 +87,54 @@ export interface TypeDocOptionMap {
82
87
  darkHighlightTheme: ShikiTheme;
83
88
  customCss: string;
84
89
  markedOptions: unknown;
85
- name: string;
86
- includeVersion: boolean;
87
- disableSources: boolean;
88
90
  basePath: string;
89
- excludeTags: `@${string}`[];
90
- readme: string;
91
91
  cname: string;
92
- sourceLinkTemplate: string;
93
- gitRevision: string;
94
- gitRemote: string;
95
92
  htmlLang: string;
96
93
  githubPages: boolean;
94
+ cacheBust: boolean;
97
95
  gaID: string;
98
96
  hideGenerator: boolean;
99
- cacheBust: boolean;
100
97
  searchInComments: boolean;
101
98
  cleanOutputDir: boolean;
102
99
  titleLink: string;
103
100
  navigationLinks: ManuallyValidatedOption<Record<string, string>>;
104
101
  sidebarLinks: ManuallyValidatedOption<Record<string, string>>;
102
+ visibilityFilters: ManuallyValidatedOption<{
103
+ protected?: boolean;
104
+ private?: boolean;
105
+ inherited?: boolean;
106
+ external?: boolean;
107
+ [tag: `@${string}`]: boolean;
108
+ }>;
109
+ searchCategoryBoosts: ManuallyValidatedOption<Record<string, number>>;
110
+ searchGroupBoosts: ManuallyValidatedOption<Record<string, number>>;
105
111
  commentStyle: typeof CommentStyle;
106
112
  useTsLinkResolution: boolean;
113
+ jsDocCompatibility: JsDocCompatibility;
107
114
  blockTags: `@${string}`[];
108
115
  inlineTags: `@${string}`[];
109
116
  modifierTags: `@${string}`[];
117
+ excludeTags: `@${string}`[];
118
+ externalSymbolLinkMappings: ManuallyValidatedOption<Record<string, Record<string, string>>>;
119
+ media: string;
120
+ includes: string;
110
121
  categorizeByGroup: boolean;
111
122
  defaultCategory: string;
112
123
  categoryOrder: string[];
113
124
  sort: SortStrategy[];
114
125
  kindSortOrder: ReflectionKind.KindString[];
115
- visibilityFilters: ManuallyValidatedOption<{
116
- protected?: boolean;
117
- private?: boolean;
118
- inherited?: boolean;
119
- external?: boolean;
120
- [tag: `@${string}`]: boolean;
121
- }>;
122
- searchCategoryBoosts: ManuallyValidatedOption<Record<string, number>>;
123
- searchGroupBoosts: ManuallyValidatedOption<Record<string, number>>;
126
+ treatWarningsAsErrors: boolean;
127
+ treatValidationWarningsAsErrors: boolean;
128
+ intentionallyNotExported: string[];
129
+ validation: ValidationOptions;
130
+ requiredToBeDocumented: ReflectionKind.KindString[];
124
131
  watch: boolean;
125
132
  preserveWatchOutput: boolean;
126
- skipErrorChecking: boolean;
127
133
  help: boolean;
128
134
  version: boolean;
129
135
  showConfig: boolean;
130
- plugin: string[];
131
136
  logLevel: typeof LogLevel;
132
- treatWarningsAsErrors: boolean;
133
- treatValidationWarningsAsErrors: boolean;
134
- intentionallyNotExported: string[];
135
- validation: ValidationOptions;
136
- requiredToBeDocumented: ReflectionKind.KindString[];
137
+ skipErrorChecking: boolean;
137
138
  }
138
139
  /**
139
140
  * Wrapper type for values in TypeDocOptionMap which are represented with an unknown option type, but
@@ -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: { ...this._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 = { ...data.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.",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typedoc",
3
3
  "description": "Create api documentation for TypeScript projects.",
4
- "version": "0.24.0-beta.8",
4
+ "version": "0.24.1",
5
5
  "homepage": "https://typedoc.org",
6
6
  "exports": {
7
7
  ".": "./dist/index.js",
package/static/style.css CHANGED
@@ -228,6 +228,8 @@ dd {
228
228
 
229
229
  .container-main {
230
230
  margin: 0 auto;
231
+ /* toolbar, footer, margin */
232
+ min-height: calc(100vh - 41px - 56px - 4rem);
231
233
  }
232
234
 
233
235
  @keyframes fade-in {