typedoc 0.20.33 → 0.20.37

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.
@@ -84,8 +84,8 @@ export declare class Application extends ChildableComponent<Application, Abstrac
84
84
  /**
85
85
  * Run the converter for the given set of files and write the reflections to a json file.
86
86
  *
87
- * @param out The path and file name of the target file.
88
- * @returns TRUE if the json file could be written successfully, otherwise FALSE.
87
+ * @param out The path and file name of the target file.
88
+ * @returns Whether the JSON file could be written successfully.
89
89
  */
90
90
  generateJson(project: ProjectReflection, out: string): Promise<void>;
91
91
  /**
@@ -238,8 +238,8 @@ let Application = Application_1 = class Application extends component_1.Childabl
238
238
  /**
239
239
  * Run the converter for the given set of files and write the reflections to a json file.
240
240
  *
241
- * @param out The path and file name of the target file.
242
- * @returns TRUE if the json file could be written successfully, otherwise FALSE.
241
+ * @param out The path and file name of the target file.
242
+ * @returns Whether the JSON file could be written successfully.
243
243
  */
244
244
  async generateJson(project, out) {
245
245
  out = Path.resolve(out);
@@ -251,7 +251,9 @@ let Application = Application_1 = class Application extends component_1.Childabl
251
251
  begin: eventData,
252
252
  end: eventData,
253
253
  });
254
- await FS.promises.writeFile(out, JSON.stringify(ser, null, "\t"));
254
+ const space = this.application.options.getValue("pretty") ? "\t" : "";
255
+ index_2.ensureDirectoriesExist(Path.dirname(out));
256
+ await FS.promises.writeFile(out, JSON.stringify(ser, null, space));
255
257
  this.logger.success("JSON written to %s", out);
256
258
  }
257
259
  /**
@@ -77,7 +77,7 @@ export declare class Context {
77
77
  expectSymbolAtLocation(node: ts.Node): ts.Symbol;
78
78
  resolveAliasedSymbol(symbol: ts.Symbol): ts.Symbol;
79
79
  createDeclarationReflection(kind: ReflectionKind, symbol: ts.Symbol | undefined, exportSymbol: ts.Symbol | undefined, nameOverride?: string): DeclarationReflection;
80
- finalizeDeclarationReflection(reflection: DeclarationReflection, symbol: ts.Symbol | undefined, exportSymbol?: ts.Symbol): void;
80
+ finalizeDeclarationReflection(reflection: DeclarationReflection, symbol: ts.Symbol | undefined, exportSymbol?: ts.Symbol, commentNode?: ts.Node): void;
81
81
  addChild(reflection: DeclarationReflection): void;
82
82
  shouldIgnore(symbol: ts.Symbol): boolean;
83
83
  /**
@@ -128,10 +128,11 @@ class Context {
128
128
  this.registerReflection(reflection, symbol);
129
129
  return reflection;
130
130
  }
131
- finalizeDeclarationReflection(reflection, symbol, exportSymbol) {
131
+ finalizeDeclarationReflection(reflection, symbol, exportSymbol, commentNode) {
132
+ var _a;
132
133
  this.exportSymbol = exportSymbol;
133
- this.converter.trigger(converter_events_1.ConverterEvents.CREATE_DECLARATION, this, reflection, symbol &&
134
- this.converter.getNodesForSymbol(symbol, reflection.kind)[0]);
134
+ this.converter.trigger(converter_events_1.ConverterEvents.CREATE_DECLARATION, this, reflection, (_a = (symbol &&
135
+ this.converter.getNodesForSymbol(symbol, reflection.kind)[0])) !== null && _a !== void 0 ? _a : commentNode);
135
136
  this.exportSymbol = undefined;
136
137
  }
137
138
  addChild(reflection) {
@@ -27,10 +27,17 @@ function convertExpression(expression) {
27
27
  case ts.SyntaxKind.NumericLiteral:
28
28
  case ts.SyntaxKind.PrefixUnaryExpression:
29
29
  return expression.getText();
30
- default:
31
- // More complex expressions are generally not useful in the documentation.
32
- // Show that there was a value, but not specifics.
33
- return "...";
34
30
  }
31
+ if (ts.isArrayLiteralExpression(expression) &&
32
+ expression.elements.length === 0) {
33
+ return "[]";
34
+ }
35
+ if (ts.isObjectLiteralExpression(expression) &&
36
+ expression.properties.length === 0) {
37
+ return "{}";
38
+ }
39
+ // More complex expressions are generally not useful in the documentation.
40
+ // Show that there was a value, but not specifics.
41
+ return "...";
35
42
  }
36
43
  exports.convertExpression = convertExpression;
@@ -175,7 +175,7 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
175
175
  }
176
176
  else {
177
177
  const reflection = context.createDeclarationReflection(index_1.ReflectionKind.Module, symbol, void 0, entryName);
178
- context.finalizeDeclarationReflection(reflection, symbol);
178
+ context.finalizeDeclarationReflection(reflection, symbol, void 0, node);
179
179
  moduleContext = context.withScope(reflection);
180
180
  }
181
181
  for (const exp of getExports(context, node, symbol).filter((exp) => isDirectExport(context.resolveAliasedSymbol(exp), node))) {
@@ -38,10 +38,19 @@ for (const key of Object.keys(symbolConverters)) {
38
38
  }
39
39
  }
40
40
  function convertSymbol(context, symbol, exportSymbol) {
41
- var _a;
41
+ var _a, _b;
42
42
  if (context.shouldIgnore(symbol)) {
43
43
  return;
44
44
  }
45
+ // This check can catch symbols which ought to be documented as references
46
+ // but aren't aliased symbols because `export *` was used.
47
+ const previous = context.project.getReflectionFromSymbol(symbol);
48
+ if (!context.converter.application.options.getValue("disableAliases") &&
49
+ previous &&
50
+ ((_a = previous.parent) === null || _a === void 0 ? void 0 : _a.kindOf(models_1.ReflectionKind.Module | models_1.ReflectionKind.Project))) {
51
+ createAlias(previous, context, symbol, exportSymbol);
52
+ return;
53
+ }
45
54
  let flags = enum_1.removeFlag(symbol.flags, ts.SymbolFlags.Transient |
46
55
  ts.SymbolFlags.Assignment |
47
56
  ts.SymbolFlags.Optional |
@@ -69,7 +78,7 @@ function convertSymbol(context, symbol, exportSymbol) {
69
78
  if (!(flag in symbolConverters)) {
70
79
  context.logger.verbose(`Missing converter for symbol: ${symbol.name} with flag ${ts.SymbolFlags[flag]}`);
71
80
  }
72
- (_a = symbolConverters[flag]) === null || _a === void 0 ? void 0 : _a.call(symbolConverters, context, symbol, exportSymbol);
81
+ (_b = symbolConverters[flag]) === null || _b === void 0 ? void 0 : _b.call(symbolConverters, context, symbol, exportSymbol);
73
82
  }
74
83
  }
75
84
  exports.convertSymbol = convertSymbol;
@@ -313,11 +322,6 @@ function convertProperty(context, symbol, exportSymbol) {
313
322
  parameterType = declaration.type;
314
323
  }
315
324
  setModifiers(symbol, declaration, reflection);
316
- const parentSymbol = context.project.getSymbolFromReflection(context.scope);
317
- assert(parentSymbol, "Tried to convert a property without a parent.");
318
- if (ts.isPrivateIdentifier(declaration.name)) {
319
- reflection.setFlag(models_1.ReflectionFlag.Private);
320
- }
321
325
  }
322
326
  reflection.defaultValue = declaration && convert_expression_1.convertDefaultValue(declaration);
323
327
  // FIXME: This is a horrible hack because getTypeOfSymbol is not exposed.
@@ -371,22 +375,26 @@ function convertConstructSignatures(context, symbol) {
371
375
  }
372
376
  }
373
377
  function convertAlias(context, symbol, exportSymbol) {
374
- var _a;
375
378
  const reflection = context.project.getReflectionFromSymbol(context.resolveAliasedSymbol(symbol));
376
- if (!reflection) {
379
+ if (!reflection ||
380
+ context.converter.application.options.getValue("disableAliases")) {
377
381
  // We don't have this, convert it.
378
382
  convertSymbol(context, context.resolveAliasedSymbol(symbol), exportSymbol !== null && exportSymbol !== void 0 ? exportSymbol : symbol);
379
383
  }
380
384
  else {
381
- // We already have this. Create a reference.
382
- const ref = new models_1.ReferenceReflection((_a = exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.name) !== null && _a !== void 0 ? _a : symbol.name, reflection, context.scope);
383
- context.addChild(ref);
384
- context.registerReflection(ref, symbol);
385
- context.trigger(converter_events_1.ConverterEvents.CREATE_DECLARATION, ref,
386
- // FIXME this isn't good enough.
387
- context.converter.getNodesForSymbol(symbol, models_1.ReflectionKind.Reference)[0]);
385
+ createAlias(reflection, context, symbol, exportSymbol);
388
386
  }
389
387
  }
388
+ function createAlias(target, context, symbol, exportSymbol) {
389
+ var _a;
390
+ // We already have this. Create a reference.
391
+ const ref = new models_1.ReferenceReflection((_a = exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.name) !== null && _a !== void 0 ? _a : symbol.name, target, context.scope);
392
+ context.addChild(ref);
393
+ context.registerReflection(ref, symbol);
394
+ context.trigger(converter_events_1.ConverterEvents.CREATE_DECLARATION, ref,
395
+ // FIXME this isn't good enough.
396
+ context.converter.getNodesForSymbol(symbol, models_1.ReflectionKind.Reference)[0]);
397
+ }
390
398
  function convertVariable(context, symbol, exportSymbol) {
391
399
  var _a;
392
400
  const declaration = (_a = symbol.getDeclarations()) === null || _a === void 0 ? void 0 : _a[0];
@@ -464,8 +472,13 @@ function isInherited(context, symbol) {
464
472
  function setModifiers(symbol, declaration, reflection) {
465
473
  var _a;
466
474
  const modifiers = ts.getCombinedModifierFlags(declaration);
467
- // Note: We only set this flag if the modifier is present because we allow
468
- // fake "private" or "protected" members via @private and @protected
475
+ if (ts.isMethodDeclaration(declaration) ||
476
+ ts.isPropertyDeclaration(declaration) ||
477
+ ts.isAccessor(declaration)) {
478
+ if (ts.isPrivateIdentifier(declaration.name)) {
479
+ reflection.setFlag(models_1.ReflectionFlag.Private);
480
+ }
481
+ }
469
482
  if (enum_1.hasAllFlags(modifiers, ts.ModifierFlags.Private)) {
470
483
  reflection.setFlag(models_1.ReflectionFlag.Private);
471
484
  }
@@ -77,10 +77,6 @@ function convertType(context, typeOrNode) {
77
77
  }
78
78
  return requestBugReport(context, typeOrNode);
79
79
  }
80
- // TS 4.2 added this to enable better tracking of type aliases.
81
- if (typeOrNode.isUnion() && typeOrNode.origin) {
82
- return convertType(context, typeOrNode.origin);
83
- }
84
80
  // IgnoreErrors is important, without it, we can't assert that we will get a node.
85
81
  const node = context.checker.typeToTypeNode(typeOrNode, void 0, ts.NodeBuilderFlags.IgnoreErrors);
86
82
  assert(node); // According to the TS source of typeToString, this is a bug if it does not hold.
@@ -625,6 +621,10 @@ const typeOperatorConverter = {
625
621
  // keyof will only show up with generic functions, otherwise it gets eagerly
626
622
  // resolved to a union of strings.
627
623
  if (node.operator === ts.SyntaxKind.KeyOfKeyword) {
624
+ // TS 4.2 added this to enable better tracking of type aliases.
625
+ if (type.isUnion() && type.origin) {
626
+ return convertType(context, type.origin);
627
+ }
628
628
  // There's probably an interface for this somewhere... I couldn't find it.
629
629
  const targetType = type.type;
630
630
  return new models_1.TypeOperatorType(convertType(context, targetType), "keyof");
@@ -640,6 +640,10 @@ const unionConverter = {
640
640
  return new models_1.UnionType(node.types.map((type) => convertType(context, type)));
641
641
  },
642
642
  convertType(context, type) {
643
+ // TS 4.2 added this to enable better tracking of type aliases.
644
+ if (type.origin) {
645
+ return convertType(context, type.origin);
646
+ }
643
647
  return new models_1.UnionType(type.types.map((type) => convertType(context, type)));
644
648
  },
645
649
  };
@@ -51,6 +51,8 @@ export declare class MarkedPlugin extends ContextAwareRendererComponent {
51
51
  * The pattern used to find media links.
52
52
  */
53
53
  private mediaPattern;
54
+ private sources?;
55
+ private outputFileName?;
54
56
  /**
55
57
  * Create a new MarkedPlugin instance.
56
58
  */
@@ -75,6 +75,9 @@ let MarkedPlugin = class MarkedPlugin extends components_1.ContextAwareRendererC
75
75
  // eslint-disable-next-line @typescript-eslint/no-this-alias
76
76
  const that = this;
77
77
  Handlebars.registerHelper("markdown", function (arg) {
78
+ const root = arg.data.root;
79
+ that.outputFileName = root.filename;
80
+ that.sources = root.model.sources;
78
81
  return that.parseMarkdown(arg.fn(this), this);
79
82
  });
80
83
  Handlebars.registerHelper("relativeURL", (url) => url ? this.getRelativeUrl(url) : url);
@@ -87,11 +90,18 @@ let MarkedPlugin = class MarkedPlugin extends components_1.ContextAwareRendererC
87
90
  * @return A html string with syntax highlighting.
88
91
  */
89
92
  getHighlighted(text, lang) {
93
+ var _a;
90
94
  lang = lang || "typescript";
91
95
  lang = lang.toLowerCase();
92
96
  if (!highlighter_1.isSupportedLanguage(lang)) {
93
97
  // Extra newline because of the progress bar
94
- this.application.logger.warn(`\nUnsupported highlight language "${lang}" will not be highlighted. Run typedoc --help for a list of supported languages.`);
98
+ this.application.logger.warn(`
99
+ Unsupported highlight language "${lang}" will not be highlighted. Run typedoc --help for a list of supported languages.
100
+ target code block :
101
+ \t${text.split("\n").join("\n\t")}
102
+ source files :${(_a = this.sources) === null || _a === void 0 ? void 0 : _a.map((source) => `\n\t${source.fileName}`).join()}
103
+ output file :
104
+ \t${this.outputFileName}`);
95
105
  return text;
96
106
  }
97
107
  return highlighter_1.highlight(text, lang, this.theme);
@@ -75,6 +75,7 @@ let Renderer = Renderer_1 = class Renderer extends component_1.ChildableComponen
75
75
  output.settings = this.application.options.getRawValues();
76
76
  output.urls = this.theme.getUrls(project);
77
77
  const bar = new ProgressBar("Rendering [:bar] :percent", {
78
+ stream: process.stdout,
78
79
  total: output.urls.length,
79
80
  width: 40,
80
81
  });
@@ -333,10 +333,7 @@ class NavigationBuilder {
333
333
  }
334
334
  target = target.parent;
335
335
  }
336
- if (inScope &&
337
- someModule instanceof index_1.DeclarationReflection &&
338
- someModule.children &&
339
- someModule.children.length > 0) {
336
+ if (inScope && someModule instanceof index_1.DeclarationReflection) {
340
337
  modules.push(someModule);
341
338
  }
342
339
  });
@@ -32,6 +32,7 @@ export interface TypeDocOptionMap {
32
32
  excludeNotDocumented: boolean;
33
33
  excludeInternal: boolean;
34
34
  disableSources: boolean;
35
+ disableAliases: boolean;
35
36
  includes: string;
36
37
  media: string;
37
38
  emit: boolean;
@@ -39,6 +40,7 @@ export interface TypeDocOptionMap {
39
40
  preserveWatchOutput: boolean;
40
41
  out: string;
41
42
  json: string;
43
+ pretty: boolean;
42
44
  theme: string;
43
45
  name: string;
44
46
  includeVersion: boolean;
@@ -13,7 +13,7 @@ function addTypeDocOptions(options) {
13
13
  });
14
14
  options.addDeclaration({
15
15
  name: "tsconfig",
16
- help: "Specify a typescript config file that should be loaded. If not specified TypeDoc will look for 'tsconfig.json' in the current directory.",
16
+ help: "Specify a TypeScript config file that should be loaded. If not specified TypeDoc will look for 'tsconfig.json' in the current directory.",
17
17
  hint: declaration_1.ParameterHint.File,
18
18
  defaultValue: process.cwd(),
19
19
  });
@@ -45,7 +45,7 @@ function addTypeDocOptions(options) {
45
45
  });
46
46
  options.addDeclaration({
47
47
  name: "excludeInternal",
48
- help: "Prevent symbols that marked with @internal from being documented.",
48
+ help: "Prevent symbols that are marked with @internal from being documented.",
49
49
  type: declaration_1.ParameterType.Boolean,
50
50
  });
51
51
  options.addDeclaration({
@@ -63,6 +63,11 @@ function addTypeDocOptions(options) {
63
63
  help: "Disables setting the source of a reflection when documenting it.",
64
64
  type: declaration_1.ParameterType.Boolean,
65
65
  });
66
+ options.addDeclaration({
67
+ name: "disableAliases",
68
+ help: "Disables creating aliases for shared reflections.",
69
+ type: declaration_1.ParameterType.Boolean,
70
+ });
66
71
  options.addDeclaration({
67
72
  name: "includes",
68
73
  help: "Specifies the location to look for included documents (use [[include:FILENAME]] in comments).",
@@ -95,12 +100,18 @@ function addTypeDocOptions(options) {
95
100
  });
96
101
  options.addDeclaration({
97
102
  name: "json",
98
- help: "Specifies the location and file name a json file describing the project is written to.",
103
+ help: "Specifies the location and filename a JSON file describing the project is written to.",
99
104
  hint: declaration_1.ParameterHint.File,
100
105
  });
106
+ options.addDeclaration({
107
+ name: "pretty",
108
+ help: "Specifies whether the output JSON should be formatted with tabs.",
109
+ type: declaration_1.ParameterType.Boolean,
110
+ defaultValue: true,
111
+ });
101
112
  options.addDeclaration({
102
113
  name: "theme",
103
- help: "Specify the path to the theme that should be used or 'default' or 'minimal' to use built-in themes.",
114
+ help: "Specify the path to the theme that should be used, or 'default' or 'minimal' to use built-in themes.",
104
115
  type: declaration_1.ParameterType.String,
105
116
  defaultValue: "default",
106
117
  });
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.20.33",
4
+ "version": "0.20.37",
5
5
  "homepage": "https://typedoc.org",
6
6
  "main": "dist/index.js",
7
7
  "typings": "dist/index.d.ts",
@@ -25,35 +25,35 @@
25
25
  "handlebars": "^4.7.7",
26
26
  "lodash": "^4.17.21",
27
27
  "lunr": "^2.3.9",
28
- "marked": "^2.0.1",
28
+ "marked": "~2.0.3",
29
29
  "minimatch": "^3.0.0",
30
30
  "progress": "^2.0.3",
31
31
  "shelljs": "^0.8.4",
32
32
  "shiki": "^0.9.3",
33
- "typedoc-default-themes": "^0.12.9"
33
+ "typedoc-default-themes": "^0.12.10"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "typescript": "3.9.x || 4.0.x || 4.1.x || 4.2.x"
37
37
  },
38
38
  "devDependencies": {
39
- "@types/fs-extra": "^9.0.8",
39
+ "@types/fs-extra": "^9.0.11",
40
40
  "@types/lodash": "^4.14.168",
41
41
  "@types/lunr": "^2.3.3",
42
- "@types/marked": "^2.0.0",
43
- "@types/minimatch": "3.0.3",
44
- "@types/mocha": "^8.2.1",
42
+ "@types/marked": "^2.0.2",
43
+ "@types/minimatch": "3.0.4",
44
+ "@types/mocha": "^8.2.2",
45
45
  "@types/mockery": "^1.4.29",
46
- "@types/node": "^14.14.34",
46
+ "@types/node": "^14.14.41",
47
47
  "@types/semver": "^7.3.4",
48
48
  "@types/shelljs": "^0.8.8",
49
- "@typescript-eslint/eslint-plugin": "^4.17.0",
50
- "@typescript-eslint/parser": "^4.17.0",
51
- "eslint": "^7.22.0",
52
- "mocha": "^8.3.0",
49
+ "@typescript-eslint/eslint-plugin": "^4.22.0",
50
+ "@typescript-eslint/parser": "^4.22.0",
51
+ "eslint": "^7.24.0",
52
+ "mocha": "^8.3.2",
53
53
  "mockery": "^2.1.0",
54
54
  "nyc": "^15.1.0",
55
55
  "prettier": "^2.2.1",
56
- "typescript": "^4.2.3"
56
+ "typescript": "^4.2.4"
57
57
  },
58
58
  "files": [
59
59
  "bin",