typedoc 0.23.0-beta.6 → 0.23.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 CHANGED
@@ -6,7 +6,7 @@ export * from "./lib/models";
6
6
  export { Converter, Context, type CommentParserConfig } from "./lib/converter";
7
7
  export { Renderer, DefaultTheme, DefaultThemeRenderContext, UrlMapping, Theme, PageEvent, RendererEvent, MarkdownEvent, } from "./lib/output";
8
8
  export type { RenderTemplate, RendererHooks } from "./lib/output";
9
- export { ArgumentsReader, BindOption, JSX, LogLevel, Logger, Options, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, EventHooks, } from "./lib/utils";
9
+ export { ArgumentsReader, BindOption, CommentStyle, JSX, LogLevel, Logger, Options, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, EventHooks, } from "./lib/utils";
10
10
  export type { OptionsReader, TypeDocOptions, TypeDocOptionMap, ValidationOptions, TypeDocOptionValues, KeyToDeclaration, DeclarationOption, DeclarationOptionBase, StringDeclarationOption, NumberDeclarationOption, BooleanDeclarationOption, ArrayDeclarationOption, MixedDeclarationOption, MapDeclarationOption, FlagsDeclarationOption, DeclarationOptionToOptionType, SortStrategy, ParameterTypeToOptionTypeMap, DocumentationEntryPoint, ManuallyValidatedOption, } from "./lib/utils";
11
11
  export type { EventMap, EventCallback } from "./lib/utils/events";
12
12
  export { JSONOutput, Serializer, type SerializerComponent, SerializeEvent, } from "./lib/serialization";
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.TypeScript = exports.SerializeEvent = exports.Serializer = exports.JSONOutput = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.BindOption = exports.ArgumentsReader = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.normalizePath = exports.resetReflectionID = exports.Event = exports.EventDispatcher = exports.Application = void 0;
17
+ exports.TypeScript = exports.SerializeEvent = exports.Serializer = exports.JSONOutput = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.CommentStyle = exports.BindOption = exports.ArgumentsReader = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.normalizePath = exports.resetReflectionID = exports.Event = exports.EventDispatcher = exports.Application = void 0;
18
18
  var application_1 = require("./lib/application");
19
19
  Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return application_1.Application; } });
20
20
  var events_1 = require("./lib/utils/events");
@@ -40,6 +40,7 @@ Object.defineProperty(exports, "MarkdownEvent", { enumerable: true, get: functio
40
40
  var utils_1 = require("./lib/utils");
41
41
  Object.defineProperty(exports, "ArgumentsReader", { enumerable: true, get: function () { return utils_1.ArgumentsReader; } });
42
42
  Object.defineProperty(exports, "BindOption", { enumerable: true, get: function () { return utils_1.BindOption; } });
43
+ Object.defineProperty(exports, "CommentStyle", { enumerable: true, get: function () { return utils_1.CommentStyle; } });
43
44
  Object.defineProperty(exports, "JSX", { enumerable: true, get: function () { return utils_1.JSX; } });
44
45
  Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return utils_1.LogLevel; } });
45
46
  Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return utils_1.Logger; } });
@@ -230,7 +230,7 @@ function* lexBlockComment2(file, pos, end) {
230
230
  return lookahead;
231
231
  }
232
232
  function lookaheadExactlyNTicks(pos, n) {
233
- if (pos + n >= end) {
233
+ if (pos + n > end) {
234
234
  return false;
235
235
  }
236
236
  return file.startsWith("`".repeat(n), pos) && file[pos + n] !== "`";
@@ -14,6 +14,7 @@ export interface DeclarationReference {
14
14
  }
15
15
  export interface Meaning {
16
16
  keyword?: MeaningKeyword;
17
+ label?: string;
17
18
  index?: number;
18
19
  }
19
20
  export interface SymbolReference {
@@ -35,8 +36,5 @@ export declare function parseModuleSource(source: string, pos: number, end: numb
35
36
  export declare function parseSymbolReference(source: string, pos: number, end: number): [SymbolReference, number] | undefined;
36
37
  export declare function parseComponent(source: string, pos: number, end: number): [string, number] | undefined;
37
38
  export declare function parseComponentPath(source: string, pos: number, end: number): readonly [ComponentPath[], number] | undefined;
38
- export declare function parseMeaning(source: string, pos: number, end: number): [{
39
- keyword?: MeaningKeyword;
40
- index?: number;
41
- }, number] | undefined;
39
+ export declare function parseMeaning(source: string, pos: number, end: number): [Meaning, number] | undefined;
42
40
  export declare function parseDeclarationReference(source: string, pos: number, end: number): [DeclarationReference, number] | undefined;
@@ -34,6 +34,8 @@ const DecimalDigit = "0123456789";
34
34
  const HexDigit = DecimalDigit + "abcdefABCDEF";
35
35
  const SingleEscapeCharacter = `'"\\bfnrtv`;
36
36
  const EscapeCharacter = SingleEscapeCharacter + DecimalDigit + "xu";
37
+ const UserLabelStart = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_";
38
+ const UserLabelCharacter = UserLabelStart + DecimalDigit;
37
39
  const SingleEscapeChars = {
38
40
  "'": "'",
39
41
  '"': '"',
@@ -217,11 +219,17 @@ function parseComponentPath(source, pos, end) {
217
219
  return [components, pos];
218
220
  }
219
221
  exports.parseComponentPath = parseComponentPath;
222
+ // The TSDoc specification permits the first four branches of Meaning. TypeDoc adds the UserLabel
223
+ // branch so that the @label tag can be used with this form of declaration references.
220
224
  // Meaning:
221
225
  // `:` MeaningKeyword // Indicates the meaning of a symbol (i.e. ':class')
222
226
  // `:` MeaningKeyword `(` DecimalDigits `)` // Indicates an overloaded meaning (i.e. ':function(1)')
223
227
  // `:` `(` DecimalDigits `)` // Shorthand for an overloaded meaning (i.e. `:(1)`)
224
228
  // `:` DecimalDigits // Shorthand for an overloaded meaning (i.e. ':1')
229
+ // `:` UserLabel // Indicates a user defined label via {@label CUSTOM_LABEL}
230
+ //
231
+ // UserLabel:
232
+ // UserLabelStart UserLabelCharacter*
225
233
  function parseMeaning(source, pos, end) {
226
234
  if (source[pos++] !== ":")
227
235
  return;
@@ -229,6 +237,14 @@ function parseMeaning(source, pos, end) {
229
237
  if (keyword) {
230
238
  pos += keyword.length;
231
239
  }
240
+ if (!keyword && UserLabelStart.includes(source[pos])) {
241
+ let lookahead = pos + 1;
242
+ while (lookahead < end &&
243
+ UserLabelCharacter.includes(source[lookahead])) {
244
+ lookahead++;
245
+ }
246
+ return [{ label: source.substring(pos, lookahead) }, lookahead];
247
+ }
232
248
  if (pos + 1 < end &&
233
249
  source[pos] === "(" &&
234
250
  DecimalDigit.includes(source[pos + 1])) {
@@ -242,7 +258,7 @@ function parseMeaning(source, pos, end) {
242
258
  keyword,
243
259
  index: parseInt(source.substring(pos + 1, lookahead)),
244
260
  },
245
- pos,
261
+ lookahead + 1,
246
262
  ];
247
263
  }
248
264
  }
@@ -255,7 +271,7 @@ function parseMeaning(source, pos, end) {
255
271
  {
256
272
  index: parseInt(source.substring(pos, lookahead)),
257
273
  },
258
- pos,
274
+ lookahead,
259
275
  ];
260
276
  }
261
277
  if (keyword) {
@@ -69,6 +69,9 @@ exports.resolveDeclarationReference = resolveDeclarationReference;
69
69
  function filterMapByMeaning(reflections, meaning) {
70
70
  return (0, utils_1.filterMap)(reflections, (refl) => {
71
71
  const kwResolved = resolveKeyword(refl, meaning.keyword) || [];
72
+ if (meaning.label) {
73
+ return kwResolved.find((r) => r.label === meaning.label);
74
+ }
72
75
  return kwResolved[meaning.index || 0];
73
76
  });
74
77
  }
@@ -84,7 +84,7 @@ const wantedKinds = {
84
84
  function discoverComment(symbol, kind, logger, commentStyle) {
85
85
  // For a module comment, we want the first one defined in the file,
86
86
  // not the last one, since that will apply to the import or declaration.
87
- const reverse = symbol.declarations?.some(ts.isSourceFile);
87
+ const reverse = !symbol.declarations?.some(ts.isSourceFile);
88
88
  const discovered = [];
89
89
  for (const decl of symbol.declarations || []) {
90
90
  const text = decl.getSourceFile().text;
@@ -105,7 +105,7 @@ function discoverComment(symbol, kind, logger, commentStyle) {
105
105
  }
106
106
  const comments = collectCommentRanges(ts.getLeadingCommentRanges(text, node.pos));
107
107
  if (reverse) {
108
- comments?.reverse();
108
+ comments.reverse();
109
109
  }
110
110
  const selectedDocComment = comments.find((ranges) => permittedRange(text, ranges, commentStyle));
111
111
  if (selectedDocComment) {
@@ -200,7 +200,7 @@ function* lexBlockComment2(file, pos, end) {
200
200
  return lookahead;
201
201
  }
202
202
  function lookaheadExactlyNTicks(pos, n) {
203
- if (pos + n >= end) {
203
+ if (pos + n > end) {
204
204
  return false;
205
205
  }
206
206
  return file.startsWith("`".repeat(n), pos) && file[pos + n] !== "`";
@@ -191,7 +191,7 @@ function* lexCommentString2(file) {
191
191
  };
192
192
  }
193
193
  function lookaheadExactlyNTicks(pos, n) {
194
- if (pos + n >= end) {
194
+ if (pos + n > end) {
195
195
  return false;
196
196
  }
197
197
  return file.startsWith("`".repeat(n), pos) && file[pos + n] !== "`";
@@ -196,9 +196,13 @@ let CommentPlugin = class CommentPlugin extends components_1.ConverterComponent
196
196
  * @param context The context object describing the current state the converter is in.
197
197
  * @param reflection The reflection that is currently resolved.
198
198
  */
199
- onResolve(_context, reflection) {
199
+ onResolve(context, reflection) {
200
200
  if (reflection.comment) {
201
201
  reflection.label = extractLabelTag(reflection.comment);
202
+ if (reflection.label && !/[A-Z_][A-Z0-9_]/.test(reflection.label)) {
203
+ context.logger.warn(`The label "${reflection.label}" for ${reflection.getFriendlyFullName()} cannot be referenced with a declaration reference. ` +
204
+ `Labels may only contain A-Z, 0-9, and _, and may not start with a number.`);
205
+ }
202
206
  mergeSeeTags(reflection.comment);
203
207
  }
204
208
  if (!(reflection instanceof models_1.DeclarationReflection)) {
@@ -53,6 +53,9 @@ let InheritDocPlugin = class InheritDocPlugin extends components_1.ConverterComp
53
53
  if (!source)
54
54
  continue;
55
55
  const declRef = (0, declarationReference_1.parseDeclarationReference)(source, 0, source.length);
56
+ if (!declRef || /\S/.test(source.substring(declRef[1]))) {
57
+ context.logger.warn(`Declaration reference in @inheritDoc for ${reflection.getFriendlyFullName()} was not fully parsed and may resolve incorrectly.`);
58
+ }
56
59
  let sourceRefl = declRef && (0, declarationReferenceResolver_1.resolveDeclarationReference)(reflection, declRef[0]);
57
60
  if (reflection instanceof models_1.SignatureReflection) {
58
61
  // Assumes that if there are overloads, they are declared in the same order as the parent.
@@ -6,7 +6,7 @@ export type { IfInternal, NeverIfInternal, Chars } from "./general";
6
6
  export { assertNever } from "./general";
7
7
  export { CallbackLogger, ConsoleLogger, Logger, LogLevel } from "./loggers";
8
8
  export { DefaultMap } from "./map";
9
- export { ArgumentsReader, BindOption, Options, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, } from "./options";
9
+ export { ArgumentsReader, BindOption, CommentStyle, Options, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, } from "./options";
10
10
  export type { ArrayDeclarationOption, BooleanDeclarationOption, DeclarationOption, DeclarationOptionBase, DeclarationOptionToOptionType, KeyToDeclaration, MapDeclarationOption, MixedDeclarationOption, NumberDeclarationOption, FlagsDeclarationOption, OptionsReader, StringDeclarationOption, TypeDocOptionMap, TypeDocOptions, ValidationOptions, TypeDocOptionValues, ParameterTypeToOptionTypeMap, ManuallyValidatedOption, } from "./options";
11
11
  export { discoverPlugins, loadPlugins } from "./plugins";
12
12
  export { sortReflections } from "./sort";
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Validation = exports.renderElement = exports.Raw = exports.Fragment = exports.JSX = exports.EventHooks = exports.sortReflections = exports.loadPlugins = exports.discoverPlugins = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.Options = exports.BindOption = exports.ArgumentsReader = exports.DefaultMap = exports.LogLevel = exports.Logger = exports.ConsoleLogger = exports.CallbackLogger = exports.assertNever = exports.writeFileSync = exports.writeFile = exports.readFile = exports.normalizePath = exports.getCommonDirectory = exports.copySync = exports.copy = exports.EventDispatcher = exports.Event = exports.Component = exports.ChildableComponent = exports.AbstractComponent = exports.unique = exports.removeIfPresent = exports.removeIf = exports.partition = exports.insertPrioritySorted = exports.filterMap = void 0;
17
+ exports.Validation = exports.renderElement = exports.Raw = exports.Fragment = exports.JSX = exports.EventHooks = exports.sortReflections = exports.loadPlugins = exports.discoverPlugins = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.Options = exports.CommentStyle = exports.BindOption = exports.ArgumentsReader = exports.DefaultMap = exports.LogLevel = exports.Logger = exports.ConsoleLogger = exports.CallbackLogger = exports.assertNever = exports.writeFileSync = exports.writeFile = exports.readFile = exports.normalizePath = exports.getCommonDirectory = exports.copySync = exports.copy = exports.EventDispatcher = exports.Event = exports.Component = exports.ChildableComponent = exports.AbstractComponent = exports.unique = exports.removeIfPresent = exports.removeIf = exports.partition = exports.insertPrioritySorted = exports.filterMap = void 0;
18
18
  var array_1 = require("./array");
19
19
  Object.defineProperty(exports, "filterMap", { enumerable: true, get: function () { return array_1.filterMap; } });
20
20
  Object.defineProperty(exports, "insertPrioritySorted", { enumerable: true, get: function () { return array_1.insertPrioritySorted; } });
@@ -49,6 +49,7 @@ Object.defineProperty(exports, "DefaultMap", { enumerable: true, get: function (
49
49
  var options_1 = require("./options");
50
50
  Object.defineProperty(exports, "ArgumentsReader", { enumerable: true, get: function () { return options_1.ArgumentsReader; } });
51
51
  Object.defineProperty(exports, "BindOption", { enumerable: true, get: function () { return options_1.BindOption; } });
52
+ Object.defineProperty(exports, "CommentStyle", { enumerable: true, get: function () { return options_1.CommentStyle; } });
52
53
  Object.defineProperty(exports, "Options", { enumerable: true, get: function () { return options_1.Options; } });
53
54
  Object.defineProperty(exports, "ParameterHint", { enumerable: true, get: function () { return options_1.ParameterHint; } });
54
55
  Object.defineProperty(exports, "ParameterType", { enumerable: true, get: function () { return options_1.ParameterType; } });
@@ -1,5 +1,5 @@
1
1
  export { Options, BindOption } from "./options";
2
2
  export type { OptionsReader } from "./options";
3
3
  export { ArgumentsReader, TypeDocReader, TSConfigReader } from "./readers";
4
- export { EmitStrategy, ParameterType, ParameterHint } from "./declaration";
4
+ export { CommentStyle, EmitStrategy, ParameterType, ParameterHint, } from "./declaration";
5
5
  export type { TypeDocOptions, TypeDocOptionMap, ValidationOptions, KeyToDeclaration, DeclarationOption, DeclarationOptionBase, StringDeclarationOption, NumberDeclarationOption, BooleanDeclarationOption, ArrayDeclarationOption, MixedDeclarationOption, MapDeclarationOption, FlagsDeclarationOption, DeclarationOptionToOptionType, TypeDocOptionValues, ParameterTypeToOptionTypeMap, ManuallyValidatedOption, } from "./declaration";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParameterHint = exports.ParameterType = exports.EmitStrategy = exports.TSConfigReader = exports.TypeDocReader = exports.ArgumentsReader = exports.BindOption = exports.Options = void 0;
3
+ exports.ParameterHint = exports.ParameterType = exports.EmitStrategy = exports.CommentStyle = exports.TSConfigReader = exports.TypeDocReader = exports.ArgumentsReader = exports.BindOption = exports.Options = void 0;
4
4
  var options_1 = require("./options");
5
5
  Object.defineProperty(exports, "Options", { enumerable: true, get: function () { return options_1.Options; } });
6
6
  Object.defineProperty(exports, "BindOption", { enumerable: true, get: function () { return options_1.BindOption; } });
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "ArgumentsReader", { enumerable: true, get: funct
9
9
  Object.defineProperty(exports, "TypeDocReader", { enumerable: true, get: function () { return readers_1.TypeDocReader; } });
10
10
  Object.defineProperty(exports, "TSConfigReader", { enumerable: true, get: function () { return readers_1.TSConfigReader; } });
11
11
  var declaration_1 = require("./declaration");
12
+ Object.defineProperty(exports, "CommentStyle", { enumerable: true, get: function () { return declaration_1.CommentStyle; } });
12
13
  Object.defineProperty(exports, "EmitStrategy", { enumerable: true, get: function () { return declaration_1.EmitStrategy; } });
13
14
  Object.defineProperty(exports, "ParameterType", { enumerable: true, get: function () { return declaration_1.ParameterType; } });
14
15
  Object.defineProperty(exports, "ParameterHint", { enumerable: true, get: function () { return declaration_1.ParameterHint; } });
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.23.0-beta.6",
4
+ "version": "0.23.1",
5
5
  "homepage": "https://typedoc.org",
6
6
  "main": "./dist/index.js",
7
7
  "exports": {