typedoc 0.24.0-beta.1 → 0.24.0-beta.3

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.
Files changed (80) hide show
  1. package/README.md +5 -32
  2. package/dist/index.d.ts +3 -3
  3. package/dist/index.js +6 -14
  4. package/dist/lib/application-events.d.ts +1 -0
  5. package/dist/lib/application-events.js +1 -0
  6. package/dist/lib/application.d.ts +6 -2
  7. package/dist/lib/application.js +21 -13
  8. package/dist/lib/cli.js +7 -14
  9. package/dist/lib/converter/comments/declarationReference.d.ts +1 -1
  10. package/dist/lib/converter/comments/discovery.d.ts +1 -1
  11. package/dist/lib/converter/comments/discovery.js +76 -96
  12. package/dist/lib/converter/comments/index.d.ts +1 -1
  13. package/dist/lib/converter/comments/index.js +21 -41
  14. package/dist/lib/converter/comments/linkResolver.d.ts +7 -2
  15. package/dist/lib/converter/comments/linkResolver.js +27 -39
  16. package/dist/lib/converter/context.d.ts +1 -1
  17. package/dist/lib/converter/context.js +5 -25
  18. package/dist/lib/converter/convert-expression.d.ts +1 -1
  19. package/dist/lib/converter/convert-expression.js +15 -35
  20. package/dist/lib/converter/converter.d.ts +6 -4
  21. package/dist/lib/converter/converter.js +17 -36
  22. package/dist/lib/converter/factories/index-signature.d.ts +1 -1
  23. package/dist/lib/converter/factories/index-signature.js +3 -26
  24. package/dist/lib/converter/factories/signature.d.ts +1 -1
  25. package/dist/lib/converter/factories/signature.js +36 -53
  26. package/dist/lib/converter/index.d.ts +1 -0
  27. package/dist/lib/converter/jsdoc.d.ts +1 -1
  28. package/dist/lib/converter/jsdoc.js +17 -37
  29. package/dist/lib/converter/plugins/CommentPlugin.d.ts +2 -0
  30. package/dist/lib/converter/plugins/CommentPlugin.js +19 -4
  31. package/dist/lib/converter/plugins/ImplementsPlugin.js +9 -29
  32. package/dist/lib/converter/plugins/LinkResolverPlugin.js +10 -2
  33. package/dist/lib/converter/plugins/PackagePlugin.d.ts +5 -0
  34. package/dist/lib/converter/plugins/PackagePlugin.js +32 -37
  35. package/dist/lib/converter/plugins/SourcePlugin.js +6 -26
  36. package/dist/lib/converter/symbols.d.ts +1 -1
  37. package/dist/lib/converter/symbols.js +120 -142
  38. package/dist/lib/converter/types.d.ts +1 -1
  39. package/dist/lib/converter/types.js +89 -112
  40. package/dist/lib/converter/utils/nodes.d.ts +1 -1
  41. package/dist/lib/converter/utils/nodes.js +4 -24
  42. package/dist/lib/converter/utils/symbols.d.ts +1 -1
  43. package/dist/lib/converter/utils/symbols.js +4 -24
  44. package/dist/lib/models/comments/comment.d.ts +6 -0
  45. package/dist/lib/models/comments/comment.js +50 -0
  46. package/dist/lib/models/reflections/declaration.d.ts +2 -2
  47. package/dist/lib/models/reflections/declaration.js +1 -1
  48. package/dist/lib/models/reflections/type-parameter.d.ts +1 -1
  49. package/dist/lib/models/types.d.ts +1 -1
  50. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +1 -1
  51. package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +1 -2
  52. package/dist/lib/output/themes/default/layouts/default.js +5 -5
  53. package/dist/lib/output/themes/default/partials/header.js +1 -1
  54. package/dist/lib/output/themes/default/partials/navigation.js +2 -2
  55. package/dist/lib/output/themes/lib.d.ts +2 -4
  56. package/dist/lib/output/themes/lib.js +3 -45
  57. package/dist/lib/utils/entry-point.d.ts +2 -2
  58. package/dist/lib/utils/entry-point.js +11 -8
  59. package/dist/lib/utils/fs.d.ts +13 -0
  60. package/dist/lib/utils/fs.js +105 -14
  61. package/dist/lib/utils/index.d.ts +2 -2
  62. package/dist/lib/utils/index.js +4 -1
  63. package/dist/lib/utils/loggers.d.ts +1 -1
  64. package/dist/lib/utils/loggers.js +8 -28
  65. package/dist/lib/utils/options/declaration.d.ts +3 -2
  66. package/dist/lib/utils/options/index.d.ts +1 -1
  67. package/dist/lib/utils/options/index.js +2 -1
  68. package/dist/lib/utils/options/readers/index.d.ts +1 -0
  69. package/dist/lib/utils/options/readers/index.js +3 -1
  70. package/dist/lib/utils/options/readers/package-json.d.ts +9 -0
  71. package/dist/lib/utils/options/readers/package-json.js +45 -0
  72. package/dist/lib/utils/options/readers/tsconfig.js +4 -24
  73. package/dist/lib/utils/options/readers/typedoc.d.ts +1 -1
  74. package/dist/lib/utils/options/readers/typedoc.js +15 -4
  75. package/dist/lib/utils/options/sources/typedoc.js +56 -10
  76. package/dist/lib/utils/sort.d.ts +1 -1
  77. package/dist/lib/validation/documentation.js +13 -1
  78. package/package.json +16 -16
  79. package/static/main.js +55 -1
  80. package/static/style.css +4 -7
@@ -1,33 +1,10 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
28
5
  Object.defineProperty(exports, "__esModule", { value: true });
29
6
  exports.createTypeParamReflection = exports.convertTypeParameterNodes = exports.convertParameterNodes = exports.createSignature = void 0;
30
- const ts = __importStar(require("typescript"));
7
+ const typescript_1 = __importDefault(require("typescript"));
31
8
  const assert_1 = __importDefault(require("assert"));
32
9
  const models_1 = require("../../models");
33
10
  const converter_events_1 = require("../converter-events");
@@ -46,12 +23,18 @@ function createSignature(context, kind, signature, symbol, declaration) {
46
23
  if (symbol && declaration) {
47
24
  context.project.registerSymbolId(sigRef, new ReflectionSymbolId_1.ReflectionSymbolId(symbol, declaration));
48
25
  }
49
- // If we are creating signatures for a variable and the variable has a comment associated with it
50
- // then we should prefer that variable's comment over any comment on the signature. The comment plugin
26
+ // If we are creating signatures for a variable or property and it has a comment associated with it
27
+ // then we should prefer that comment over any comment on the signature. The comment plugin
51
28
  // will copy the comment down if this signature doesn't have one, so don't set one.
29
+ let parentReflection = context.scope;
30
+ if (parentReflection.kindOf(models_1.ReflectionKind.TypeLiteral) &&
31
+ parentReflection.parent instanceof models_1.DeclarationReflection) {
32
+ parentReflection = parentReflection.parent;
33
+ }
52
34
  if (declaration &&
53
- (!context.scope.comment ||
54
- !(context.scope.conversionFlags & models_1.ConversionFlags.VariableSource))) {
35
+ (!parentReflection.comment ||
36
+ !(parentReflection.conversionFlags &
37
+ models_1.ConversionFlags.VariableOrPropertySource))) {
55
38
  sigRef.comment = (0, comments_1.getSignatureComment)(declaration, context.converter.config, context.logger, context.converter.commentStyle);
56
39
  }
57
40
  sigRef.typeParameters = convertTypeParameters(sigRefCtx, sigRef, signature.typeParameters);
@@ -67,7 +50,7 @@ function createSignature(context, kind, signature, symbol, declaration) {
67
50
  sigRef.type = new models_1.IntrinsicType("void");
68
51
  }
69
52
  else {
70
- sigRef.type = context.converter.convertType(sigRefCtx, (declaration?.kind === ts.SyntaxKind.FunctionDeclaration &&
53
+ sigRef.type = context.converter.convertType(sigRefCtx, (declaration?.kind === typescript_1.default.SyntaxKind.FunctionDeclaration &&
71
54
  declaration.type) ||
72
55
  signature.getReturnType());
73
56
  }
@@ -92,10 +75,10 @@ function convertParameters(context, sigRef, parameters, parameterNodes) {
92
75
  return parameters.map((param, i) => {
93
76
  const declaration = param.valueDeclaration;
94
77
  (0, assert_1.default)(!declaration ||
95
- ts.isParameter(declaration) ||
96
- ts.isJSDocParameterTag(declaration));
78
+ typescript_1.default.isParameter(declaration) ||
79
+ typescript_1.default.isJSDocParameterTag(declaration));
97
80
  const paramRefl = new models_1.ParameterReflection(/__\d+/.test(param.name) ? "__namedParameters" : param.name, models_1.ReflectionKind.Parameter, sigRef);
98
- if (declaration && ts.isJSDocParameterTag(declaration)) {
81
+ if (declaration && typescript_1.default.isJSDocParameterTag(declaration)) {
99
82
  paramRefl.comment = (0, comments_1.getJsDocComment)(declaration, context.converter.config, context.logger);
100
83
  }
101
84
  paramRefl.comment || (paramRefl.comment = (0, comments_1.getComment)(param, paramRefl.kind, context.converter.config, context.logger, context.converter.commentStyle));
@@ -111,9 +94,9 @@ function convertParameters(context, sigRef, parameters, parameterNodes) {
111
94
  paramRefl.type = context.converter.convertType(context.withScope(paramRefl), type);
112
95
  let isOptional = false;
113
96
  if (declaration) {
114
- isOptional = ts.isParameter(declaration)
97
+ isOptional = typescript_1.default.isParameter(declaration)
115
98
  ? !!declaration.questionToken ||
116
- ts
99
+ typescript_1.default
117
100
  .getJSDocParameterTags(declaration)
118
101
  .some((tag) => tag.isBracketed)
119
102
  : declaration.isBracketed;
@@ -127,10 +110,10 @@ function convertParameters(context, sigRef, parameters, parameterNodes) {
127
110
  // because the method body uses `arguments`... which is always a rest argument
128
111
  let isRest = true;
129
112
  if (declaration) {
130
- isRest = ts.isParameter(declaration)
113
+ isRest = typescript_1.default.isParameter(declaration)
131
114
  ? !!declaration.dotDotDotToken
132
115
  : !!declaration.typeExpression &&
133
- ts.isJSDocVariadicType(declaration.typeExpression.type);
116
+ typescript_1.default.isJSDocVariadicType(declaration.typeExpression.type);
134
117
  }
135
118
  paramRefl.setFlag(models_1.ReflectionFlag.Rest, isRest);
136
119
  return paramRefl;
@@ -141,13 +124,13 @@ function convertParameterNodes(context, sigRef, parameters) {
141
124
  const paramRefl = new models_1.ParameterReflection(/__\d+/.test(param.name.getText())
142
125
  ? "__namedParameters"
143
126
  : param.name.getText(), models_1.ReflectionKind.Parameter, sigRef);
144
- if (ts.isJSDocParameterTag(param)) {
127
+ if (typescript_1.default.isJSDocParameterTag(param)) {
145
128
  paramRefl.comment = (0, comments_1.getJsDocComment)(param, context.converter.config, context.logger);
146
129
  }
147
130
  context.registerReflection(paramRefl, context.getSymbolAtLocation(param));
148
131
  context.trigger(converter_events_1.ConverterEvents.CREATE_PARAMETER, paramRefl);
149
- paramRefl.type = context.converter.convertType(context.withScope(paramRefl), ts.isParameter(param) ? param.type : param.typeExpression?.type);
150
- const isOptional = ts.isParameter(param)
132
+ paramRefl.type = context.converter.convertType(context.withScope(paramRefl), typescript_1.default.isParameter(param) ? param.type : param.typeExpression?.type);
133
+ const isOptional = typescript_1.default.isParameter(param)
151
134
  ? !!param.questionToken
152
135
  : param.isBracketed;
153
136
  if (isOptional) {
@@ -155,10 +138,10 @@ function convertParameterNodes(context, sigRef, parameters) {
155
138
  }
156
139
  paramRefl.defaultValue = (0, convert_expression_1.convertDefaultValue)(param);
157
140
  paramRefl.setFlag(models_1.ReflectionFlag.Optional, isOptional);
158
- paramRefl.setFlag(models_1.ReflectionFlag.Rest, ts.isParameter(param)
141
+ paramRefl.setFlag(models_1.ReflectionFlag.Rest, typescript_1.default.isParameter(param)
159
142
  ? !!param.dotDotDotToken
160
143
  : !!param.typeExpression &&
161
- ts.isJSDocVariadicType(param.typeExpression.type));
144
+ typescript_1.default.isJSDocVariadicType(param.typeExpression.type));
162
145
  return paramRefl;
163
146
  });
164
147
  }
@@ -169,7 +152,7 @@ function convertTypeParameters(context, parent, parameters) {
169
152
  const defaultT = param.getDefault();
170
153
  // There's no way to determine directly from a ts.TypeParameter what it's variance modifiers are
171
154
  // so unfortunately we have to go back to the node for this...
172
- const variance = getVariance(param.getSymbol()?.declarations?.find(ts.isTypeParameterDeclaration)
155
+ const variance = getVariance(param.getSymbol()?.declarations?.find(typescript_1.default.isTypeParameterDeclaration)
173
156
  ?.modifiers);
174
157
  const paramRefl = new models_1.TypeParameterReflection(param.symbol.name, parent, variance);
175
158
  const paramCtx = context.withScope(paramRefl);
@@ -198,7 +181,7 @@ function createTypeParamReflection(param, context) {
198
181
  ? context.converter.convertType(paramScope, param.default)
199
182
  : void 0;
200
183
  context.registerReflection(paramRefl, param.symbol);
201
- if (ts.isJSDocTemplateTag(param.parent)) {
184
+ if (typescript_1.default.isJSDocTemplateTag(param.parent)) {
202
185
  paramRefl.comment = (0, comments_1.getJsDocComment)(param.parent, context.converter.config, context.logger);
203
186
  }
204
187
  context.trigger(converter_events_1.ConverterEvents.CREATE_TYPE_PARAMETER, paramRefl, param);
@@ -206,8 +189,8 @@ function createTypeParamReflection(param, context) {
206
189
  }
207
190
  exports.createTypeParamReflection = createTypeParamReflection;
208
191
  function getVariance(modifiers) {
209
- const hasIn = modifiers?.some((mod) => mod.kind === ts.SyntaxKind.InKeyword);
210
- const hasOut = modifiers?.some((mod) => mod.kind === ts.SyntaxKind.OutKeyword);
192
+ const hasIn = modifiers?.some((mod) => mod.kind === typescript_1.default.SyntaxKind.InKeyword);
193
+ const hasOut = modifiers?.some((mod) => mod.kind === typescript_1.default.SyntaxKind.OutKeyword);
211
194
  if (hasIn && hasOut) {
212
195
  return models_1.VarianceModifier.inOut;
213
196
  }
@@ -221,23 +204,23 @@ function getVariance(modifiers) {
221
204
  function convertPredicate(predicate, context) {
222
205
  let name;
223
206
  switch (predicate.kind) {
224
- case ts.TypePredicateKind.This:
225
- case ts.TypePredicateKind.AssertsThis:
207
+ case typescript_1.default.TypePredicateKind.This:
208
+ case typescript_1.default.TypePredicateKind.AssertsThis:
226
209
  name = "this";
227
210
  break;
228
- case ts.TypePredicateKind.Identifier:
229
- case ts.TypePredicateKind.AssertsIdentifier:
211
+ case typescript_1.default.TypePredicateKind.Identifier:
212
+ case typescript_1.default.TypePredicateKind.AssertsIdentifier:
230
213
  name = predicate.parameterName;
231
214
  break;
232
215
  }
233
216
  let asserts;
234
217
  switch (predicate.kind) {
235
- case ts.TypePredicateKind.This:
236
- case ts.TypePredicateKind.Identifier:
218
+ case typescript_1.default.TypePredicateKind.This:
219
+ case typescript_1.default.TypePredicateKind.Identifier:
237
220
  asserts = false;
238
221
  break;
239
- case ts.TypePredicateKind.AssertsThis:
240
- case ts.TypePredicateKind.AssertsIdentifier:
222
+ case typescript_1.default.TypePredicateKind.AssertsThis:
223
+ case typescript_1.default.TypePredicateKind.AssertsIdentifier:
241
224
  asserts = true;
242
225
  break;
243
226
  }
@@ -3,4 +3,5 @@ export { Converter } 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";
6
+ export type { ExternalSymbolResolver, ExternalResolveResult, } from "./comments/linkResolver";
6
7
  import "./plugins/index";
@@ -1,4 +1,4 @@
1
- import * as ts from "typescript";
1
+ import ts from "typescript";
2
2
  import type { Context } from "./context";
3
3
  export declare function convertJsDocAlias(context: Context, symbol: ts.Symbol, declaration: ts.JSDocTypedefTag | ts.JSDocEnumTag, exportSymbol?: ts.Symbol): void;
4
4
  export declare function convertJsDocCallback(context: Context, symbol: ts.Symbol, declaration: ts.JSDocCallbackTag, exportSymbol?: ts.Symbol): void;
@@ -2,33 +2,13 @@
2
2
  // Converter functions for JSDoc defined types
3
3
  // @typedef
4
4
  // @callback
5
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = { enumerable: true, get: function() { return m[k]; } };
10
- }
11
- Object.defineProperty(o, k2, desc);
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
- Object.defineProperty(o, "default", { enumerable: true, value: v });
18
- }) : function(o, v) {
19
- o["default"] = v;
20
- });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
7
  };
28
8
  Object.defineProperty(exports, "__esModule", { value: true });
29
9
  exports.convertJsDocCallback = exports.convertJsDocAlias = void 0;
30
10
  const assert_1 = require("assert");
31
- const ts = __importStar(require("typescript"));
11
+ const typescript_1 = __importDefault(require("typescript"));
32
12
  const models_1 = require("../models");
33
13
  const ReflectionSymbolId_1 = require("../models/reflections/ReflectionSymbolId");
34
14
  const comments_1 = require("./comments");
@@ -36,7 +16,7 @@ const converter_events_1 = require("./converter-events");
36
16
  const signature_1 = require("./factories/signature");
37
17
  function convertJsDocAlias(context, symbol, declaration, exportSymbol) {
38
18
  if (declaration.typeExpression &&
39
- ts.isJSDocTypeLiteral(declaration.typeExpression)) {
19
+ typescript_1.default.isJSDocTypeLiteral(declaration.typeExpression)) {
40
20
  convertJsDocInterface(context, declaration, symbol, exportSymbol);
41
21
  return;
42
22
  }
@@ -96,7 +76,7 @@ function convertJsDocSignature(context, node) {
96
76
  }
97
77
  function convertTemplateParameters(context, node) {
98
78
  (0, assert_1.ok)(context.scope instanceof models_1.DeclarationReflection);
99
- context.scope.typeParameters = convertTemplateParameterNodes(context, node.tags?.filter(ts.isJSDocTemplateTag));
79
+ context.scope.typeParameters = convertTemplateParameterNodes(context, node.tags?.filter(typescript_1.default.isJSDocTemplateTag));
100
80
  }
101
81
  function convertTemplateParameterNodes(context, nodes) {
102
82
  const params = (nodes ?? []).flatMap((tag) => tag.typeParameters);
@@ -104,31 +84,31 @@ function convertTemplateParameterNodes(context, nodes) {
104
84
  }
105
85
  function getTypedefReExportTarget(context, declaration) {
106
86
  const typeExpression = declaration.typeExpression;
107
- if (!ts.isJSDocTypedefTag(declaration) ||
87
+ if (!typescript_1.default.isJSDocTypedefTag(declaration) ||
108
88
  !typeExpression ||
109
- ts.isJSDocTypeLiteral(typeExpression) ||
110
- !ts.isImportTypeNode(typeExpression.type) ||
89
+ typescript_1.default.isJSDocTypeLiteral(typeExpression) ||
90
+ !typescript_1.default.isImportTypeNode(typeExpression.type) ||
111
91
  !typeExpression.type.qualifier ||
112
- !ts.isIdentifier(typeExpression.type.qualifier)) {
92
+ !typescript_1.default.isIdentifier(typeExpression.type.qualifier)) {
113
93
  return;
114
94
  }
115
95
  const targetSymbol = context.expectSymbolAtLocation(typeExpression.type.qualifier);
116
96
  const decl = targetSymbol.declarations?.[0];
117
97
  if (!decl ||
118
- !(ts.isTypeAliasDeclaration(decl) ||
119
- ts.isInterfaceDeclaration(decl) ||
120
- ts.isJSDocTypedefTag(decl) ||
121
- ts.isJSDocCallbackTag(decl))) {
98
+ !(typescript_1.default.isTypeAliasDeclaration(decl) ||
99
+ typescript_1.default.isInterfaceDeclaration(decl) ||
100
+ typescript_1.default.isJSDocTypedefTag(decl) ||
101
+ typescript_1.default.isJSDocCallbackTag(decl))) {
122
102
  return;
123
103
  }
124
- const targetParams = ts.getEffectiveTypeParameterDeclarations(decl);
125
- const localParams = ts.getEffectiveTypeParameterDeclarations(declaration);
104
+ const targetParams = typescript_1.default.getEffectiveTypeParameterDeclarations(decl);
105
+ const localParams = typescript_1.default.getEffectiveTypeParameterDeclarations(declaration);
126
106
  const localArgs = typeExpression.type.typeArguments || [];
127
107
  // If we have type parameters, ensure they are forwarding parameters with no transformations.
128
108
  // This doesn't check constraints since they aren't checked in JSDoc types.
129
109
  if (targetParams.length !== localParams.length ||
130
- localArgs.some((arg, i) => !ts.isTypeReferenceNode(arg) ||
131
- !ts.isIdentifier(arg.typeName) ||
110
+ localArgs.some((arg, i) => !typescript_1.default.isTypeReferenceNode(arg) ||
111
+ !typescript_1.default.isIdentifier(arg.typeName) ||
132
112
  arg.typeArguments ||
133
113
  localParams[i]?.name.text !== arg.typeName.text)) {
134
114
  return;
@@ -61,6 +61,8 @@ export declare class CommentPlugin extends ConverterComponent {
61
61
  excludePrivate: boolean;
62
62
  excludeProtected: boolean;
63
63
  excludeNotDocumented: boolean;
64
+ private _excludeKinds;
65
+ private get excludeNotDocumentedKinds();
64
66
  /**
65
67
  * Create a new CommentPlugin instance.
66
68
  */
@@ -89,6 +89,12 @@ const NEVER_RENDERED = [
89
89
  *
90
90
  */
91
91
  let CommentPlugin = class CommentPlugin extends components_1.ConverterComponent {
92
+ get excludeNotDocumentedKinds() {
93
+ this._excludeKinds ?? (this._excludeKinds = this.application.options
94
+ .getValue("excludeNotDocumentedKinds")
95
+ .reduce((a, b) => a | models_1.ReflectionKind[b], 0));
96
+ return this._excludeKinds;
97
+ }
92
98
  /**
93
99
  * Create a new CommentPlugin instance.
94
100
  */
@@ -99,6 +105,9 @@ let CommentPlugin = class CommentPlugin extends components_1.ConverterComponent
99
105
  [converter_1.Converter.EVENT_CREATE_TYPE_PARAMETER]: this.onCreateTypeParameter,
100
106
  [converter_1.Converter.EVENT_RESOLVE_BEGIN]: this.onBeginResolve,
101
107
  [converter_1.Converter.EVENT_RESOLVE]: this.onResolve,
108
+ [converter_1.Converter.EVENT_END]: () => {
109
+ this._excludeKinds = undefined;
110
+ },
102
111
  });
103
112
  }
104
113
  /**
@@ -335,12 +344,22 @@ let CommentPlugin = class CommentPlugin extends components_1.ConverterComponent
335
344
  return true;
336
345
  }
337
346
  if (!comment) {
347
+ // We haven't moved comments from the parent for signatures without a direct
348
+ // comment, so don't exclude those due to not being documented.
349
+ if (reflection.kindOf(models_1.ReflectionKind.CallSignature |
350
+ models_1.ReflectionKind.ConstructorSignature) &&
351
+ reflection.parent?.comment) {
352
+ return false;
353
+ }
338
354
  if (this.excludeNotDocumented) {
339
355
  // Don't let excludeNotDocumented remove parameters.
340
356
  if (!(reflection instanceof models_1.DeclarationReflection) &&
341
357
  !(reflection instanceof models_1.SignatureReflection)) {
342
358
  return false;
343
359
  }
360
+ if (!reflection.kindOf(this.excludeNotDocumentedKinds)) {
361
+ return false;
362
+ }
344
363
  // excludeNotDocumented should hide a module only if it has no visible children
345
364
  if (reflection.kindOf(models_1.ReflectionKind.SomeModule)) {
346
365
  if (!reflection.children) {
@@ -348,10 +367,6 @@ let CommentPlugin = class CommentPlugin extends components_1.ConverterComponent
348
367
  }
349
368
  return reflection.children.every((child) => this.isHidden(child));
350
369
  }
351
- // enum members should all be included if the parent enum is documented
352
- if (reflection.kind === models_1.ReflectionKind.EnumMember) {
353
- return false;
354
- }
355
370
  // signature containers should only be hidden if all their signatures are hidden
356
371
  if (reflection.kindOf(models_1.ReflectionKind.SignatureContainer)) {
357
372
  return reflection
@@ -1,36 +1,16 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
23
7
  };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
30
10
  };
31
11
  Object.defineProperty(exports, "__esModule", { value: true });
32
12
  exports.ImplementsPlugin = void 0;
33
- const ts = __importStar(require("typescript"));
13
+ const typescript_1 = __importDefault(require("typescript"));
34
14
  const application_events_1 = require("../../application-events");
35
15
  const index_1 = require("../../models/reflections/index");
36
16
  const types_1 = require("../../models/types");
@@ -174,7 +154,7 @@ let ImplementsPlugin = class ImplementsPlugin extends components_1.ConverterComp
174
154
  }
175
155
  const declaration = symbol
176
156
  .getDeclarations()
177
- ?.find((n) => ts.isClassDeclaration(n) || ts.isInterfaceDeclaration(n));
157
+ ?.find((n) => typescript_1.default.isClassDeclaration(n) || typescript_1.default.isInterfaceDeclaration(n));
178
158
  if (!declaration) {
179
159
  return;
180
160
  }
@@ -195,7 +175,7 @@ let ImplementsPlugin = class ImplementsPlugin extends components_1.ConverterComp
195
175
  return;
196
176
  }
197
177
  if (reflection.kind === index_1.ReflectionKind.Constructor) {
198
- const ctor = info.declaration.members.find(ts.isConstructorDeclaration);
178
+ const ctor = info.declaration.members.find(typescript_1.default.isConstructorDeclaration);
199
179
  constructorInheritance(context, reflection, info.declaration, ctor);
200
180
  return;
201
181
  }
@@ -212,7 +192,7 @@ let ImplementsPlugin = class ImplementsPlugin extends components_1.ConverterComp
212
192
  out: for (const clause of info.declaration.heritageClauses ?? []) {
213
193
  // No point checking implemented types for static members, they won't exist.
214
194
  if (reflection.flags.isStatic &&
215
- clause.token === ts.SyntaxKind.ImplementsKeyword) {
195
+ clause.token === typescript_1.default.SyntaxKind.ImplementsKeyword) {
216
196
  continue;
217
197
  }
218
198
  for (const expr of clause.types) {
@@ -226,7 +206,7 @@ let ImplementsPlugin = class ImplementsPlugin extends components_1.ConverterComp
226
206
  createLink(context, reflection, clause, expr, parentProperty, isInherit);
227
207
  // Can't always break because we need to also set `implementationOf` if we
228
208
  // inherit from a base class and also implement an interface.
229
- if (clause.token === ts.SyntaxKind.ImplementsKeyword) {
209
+ if (clause.token === typescript_1.default.SyntaxKind.ImplementsKeyword) {
230
210
  break out;
231
211
  }
232
212
  }
@@ -239,7 +219,7 @@ ImplementsPlugin = __decorate([
239
219
  ], ImplementsPlugin);
240
220
  exports.ImplementsPlugin = ImplementsPlugin;
241
221
  function constructorInheritance(context, reflection, childDecl, constructorDecl) {
242
- const extendsClause = childDecl.heritageClauses?.find((cl) => cl.token === ts.SyntaxKind.ExtendsKeyword);
222
+ const extendsClause = childDecl.heritageClauses?.find((cl) => cl.token === typescript_1.default.SyntaxKind.ExtendsKeyword);
243
223
  if (!extendsClause)
244
224
  return;
245
225
  const name = `${extendsClause.types[0].getText()}.constructor`;
@@ -271,7 +251,7 @@ function createLink(context, reflection, clause, expr, symbol, isOverwrite) {
271
251
  function link(target) {
272
252
  if (!target)
273
253
  return;
274
- if (clause.token === ts.SyntaxKind.ImplementsKeyword) {
254
+ if (clause.token === typescript_1.default.SyntaxKind.ImplementsKeyword) {
275
255
  target.implementationOf ?? (target.implementationOf = types_1.ReferenceType.createBrokenReference(name, project));
276
256
  return;
277
257
  }
@@ -38,9 +38,17 @@ let LinkResolverPlugin = class LinkResolverPlugin extends components_1.Converter
38
38
  if (project.readme) {
39
39
  project.readme = this.owner.resolveLinks(project.readme, project);
40
40
  }
41
- for (const { type } of (0, reflections_1.discoverAllReferenceTypes)(project, false)) {
41
+ for (const { type, owner } of (0, reflections_1.discoverAllReferenceTypes)(project, false)) {
42
42
  if (!type.reflection) {
43
- type.externalUrl = this.owner.resolveExternalLink(type.toDeclarationReference());
43
+ const resolveResult = this.owner.resolveExternalLink(type.toDeclarationReference(), owner);
44
+ switch (typeof resolveResult) {
45
+ case "string":
46
+ type.externalUrl = resolveResult;
47
+ break;
48
+ case "object":
49
+ type.externalUrl = resolveResult.target;
50
+ break;
51
+ }
44
52
  }
45
53
  }
46
54
  }
@@ -8,10 +8,15 @@ export declare class PackagePlugin extends ConverterComponent {
8
8
  readme: string;
9
9
  entryPointStrategy: EntryPointStrategy;
10
10
  entryPoints: string[];
11
+ includeVersion: boolean;
11
12
  /**
12
13
  * The file name of the found readme.md file.
13
14
  */
14
15
  private readmeFile?;
16
+ /**
17
+ * Contents of the readme.md file discovered, if any
18
+ */
19
+ private readmeContents?;
15
20
  /**
16
21
  * Contents of package.json for the active project
17
22
  */
@@ -31,7 +31,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
32
  exports.PackagePlugin = void 0;
33
33
  const Path = __importStar(require("path"));
34
- const FS = __importStar(require("fs"));
35
34
  const components_1 = require("../components");
36
35
  const converter_1 = require("../converter");
37
36
  const utils_1 = require("../../utils");
@@ -39,7 +38,6 @@ const fs_1 = require("../../utils/fs");
39
38
  const paths_1 = require("../../utils/paths");
40
39
  const minimalSourceFile_1 = require("../../utils/minimalSourceFile");
41
40
  const application_events_1 = require("../../application-events");
42
- const validation_1 = require("../../utils/validation");
43
41
  const path_1 = require("path");
44
42
  /**
45
43
  * A handler that tries to find the package.json and readme.md files of the
@@ -67,51 +65,43 @@ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent
67
65
  }
68
66
  onBegin() {
69
67
  this.readmeFile = undefined;
68
+ this.readmeContents = undefined;
70
69
  this.packageJson = undefined;
71
- // Path will be resolved already. This is kind of ugly, but...
72
- const noReadmeFile = this.readme.endsWith("none");
73
- if (!noReadmeFile && this.readme) {
74
- if (FS.existsSync(this.readme)) {
75
- this.readmeFile = this.readme;
76
- }
77
- }
78
- const packageAndReadmeFound = () => (noReadmeFile || this.readmeFile) && this.packageJson;
79
- const reachedTopDirectory = (dirName) => dirName === Path.resolve(Path.join(dirName, ".."));
80
70
  const entryFiles = this.entryPointStrategy === utils_1.EntryPointStrategy.Packages
81
71
  ? this.entryPoints.map((d) => (0, path_1.join)(d, "package.json"))
82
72
  : this.entryPoints;
83
- let dirName = Path.resolve((0, fs_1.getCommonDirectory)(entryFiles));
73
+ const dirName = Path.resolve((0, fs_1.getCommonDirectory)(entryFiles));
84
74
  this.application.logger.verbose(`Begin readme.md/package.json search at ${(0, paths_1.nicePath)(dirName)}`);
85
- while (!packageAndReadmeFound() && !reachedTopDirectory(dirName)) {
86
- FS.readdirSync(dirName).forEach((file) => {
87
- const lowercaseFileName = file.toLowerCase();
88
- if (!noReadmeFile &&
89
- !this.readmeFile &&
90
- lowercaseFileName === "readme.md") {
91
- this.readmeFile = Path.join(dirName, file);
92
- }
93
- if (!this.packageJson && lowercaseFileName === "package.json") {
94
- try {
95
- const packageJson = JSON.parse((0, utils_1.readFile)(Path.join(dirName, file)));
96
- if ((0, validation_1.validate)({ name: String, version: (0, validation_1.optional)(String) }, packageJson)) {
97
- this.packageJson = packageJson;
98
- }
99
- }
100
- catch {
101
- // Ignore
102
- }
103
- }
104
- });
105
- dirName = Path.resolve(Path.join(dirName, ".."));
75
+ this.packageJson = (0, fs_1.discoverPackageJson)(dirName)?.content;
76
+ // Path will be resolved already. This is kind of ugly, but...
77
+ if (this.readme.endsWith("none")) {
78
+ return; // No readme, we're done
79
+ }
80
+ if (this.readme) {
81
+ // Readme path provided, read only that file.
82
+ try {
83
+ this.readmeContents = (0, utils_1.readFile)(this.readme);
84
+ this.readmeFile = this.readme;
85
+ }
86
+ catch {
87
+ this.application.logger.error(`Provided README path, ${(0, paths_1.nicePath)(this.readme)} could not be read.`);
88
+ }
89
+ }
90
+ else {
91
+ // No readme provided, automatically find the readme
92
+ const result = (0, fs_1.discoverInParentDir)("readme.md", dirName, (content) => content);
93
+ if (result) {
94
+ this.readmeFile = result.file;
95
+ this.readmeContents = result.content;
96
+ }
106
97
  }
107
98
  }
108
99
  onBeginResolve(context) {
109
100
  this.addEntries(context.project);
110
101
  }
111
102
  addEntries(project) {
112
- if (this.readmeFile) {
113
- const readme = (0, utils_1.readFile)(this.readmeFile);
114
- const comment = this.application.converter.parseRawComment(new minimalSourceFile_1.MinimalSourceFile(readme, this.readmeFile));
103
+ if (this.readmeFile && this.readmeContents) {
104
+ const comment = this.application.converter.parseRawComment(new minimalSourceFile_1.MinimalSourceFile(this.readmeContents, this.readmeFile));
115
105
  if (comment.blockTags.length || comment.modifierTags.size) {
116
106
  const ignored = [
117
107
  ...comment.blockTags.map((tag) => tag.tag),
@@ -126,7 +116,9 @@ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent
126
116
  if (!project.name) {
127
117
  project.name = project.packageName || "Documentation";
128
118
  }
129
- project.packageVersion = this.packageJson.version;
119
+ if (this.includeVersion) {
120
+ project.packageVersion = this.packageJson.version;
121
+ }
130
122
  }
131
123
  else if (!project.name) {
132
124
  this.application.logger.warn('The --name option was not specified, and no package.json was found. Defaulting project name to "Documentation".');
@@ -143,6 +135,9 @@ __decorate([
143
135
  __decorate([
144
136
  (0, utils_1.BindOption)("entryPoints")
145
137
  ], PackagePlugin.prototype, "entryPoints", void 0);
138
+ __decorate([
139
+ (0, utils_1.BindOption)("includeVersion")
140
+ ], PackagePlugin.prototype, "includeVersion", void 0);
146
141
  PackagePlugin = __decorate([
147
142
  (0, components_1.Component)({ name: "package" })
148
143
  ], PackagePlugin);