typedoc 0.24.0-beta.7 → 0.24.0-beta.8

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 (50) hide show
  1. package/dist/index.d.ts +4 -0
  2. package/dist/index.js +17 -1
  3. package/dist/lib/converter/comments/discovery.js +1 -1
  4. package/dist/lib/converter/context.js +2 -2
  5. package/dist/lib/converter/converter.d.ts +6 -4
  6. package/dist/lib/converter/converter.js +7 -5
  7. package/dist/lib/converter/plugins/PackagePlugin.js +3 -1
  8. package/dist/lib/converter/symbols.js +9 -4
  9. package/dist/lib/models/comments/comment.d.ts +2 -2
  10. package/dist/lib/models/comments/comment.js +26 -6
  11. package/dist/lib/models/reflections/declaration.d.ts +1 -1
  12. package/dist/lib/models/reflections/project.d.ts +0 -6
  13. package/dist/lib/models/reflections/project.js +0 -16
  14. package/dist/lib/models/types.js +2 -31
  15. package/dist/lib/output/components.d.ts +3 -3
  16. package/dist/lib/output/components.js +1 -5
  17. package/dist/lib/output/events.d.ts +22 -10
  18. package/dist/lib/output/events.js +14 -6
  19. package/dist/lib/output/plugins/JavascriptIndexPlugin.js +1 -3
  20. package/dist/lib/output/renderer.d.ts +12 -4
  21. package/dist/lib/output/renderer.js +3 -3
  22. package/dist/lib/output/theme.d.ts +2 -2
  23. package/dist/lib/output/themes/MarkedPlugin.d.ts +2 -2
  24. package/dist/lib/output/themes/MarkedPlugin.js +15 -12
  25. package/dist/lib/output/themes/default/DefaultTheme.d.ts +5 -5
  26. package/dist/lib/output/themes/default/DefaultTheme.js +58 -11
  27. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +15 -13
  28. package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +9 -59
  29. package/dist/lib/output/themes/default/layouts/default.d.ts +2 -1
  30. package/dist/lib/output/themes/default/layouts/default.js +18 -12
  31. package/dist/lib/output/themes/default/partials/footer.js +1 -1
  32. package/dist/lib/output/themes/default/partials/member.d.ts +1 -1
  33. package/dist/lib/output/themes/default/partials/member.js +22 -14
  34. package/dist/lib/output/themes/default/partials/members.group.js +3 -3
  35. package/dist/lib/output/themes/default/partials/navigation.d.ts +4 -3
  36. package/dist/lib/output/themes/default/partials/navigation.js +71 -74
  37. package/dist/lib/output/themes/default/partials/toolbar.js +2 -1
  38. package/dist/lib/serialization/schema.d.ts +1 -0
  39. package/dist/lib/serialization/schema.js +1 -0
  40. package/dist/lib/serialization/serializer.d.ts +1 -1
  41. package/dist/lib/utils/entry-point.d.ts +3 -3
  42. package/dist/lib/utils/entry-point.js +4 -4
  43. package/dist/lib/utils/fs.d.ts +5 -0
  44. package/dist/lib/utils/fs.js +35 -2
  45. package/dist/lib/utils/options/declaration.d.ts +1 -0
  46. package/dist/lib/utils/options/options.d.ts +5 -0
  47. package/dist/lib/utils/options/sources/typedoc.js +5 -0
  48. package/package.json +1 -1
  49. package/static/main.js +3 -3
  50. package/static/style.css +186 -257
package/dist/index.d.ts CHANGED
@@ -2,6 +2,10 @@ export { Application } from "./lib/application";
2
2
  export { EventDispatcher, Event } from "./lib/utils/events";
3
3
  export { resetReflectionID } from "./lib/models/reflections/abstract";
4
4
  export { normalizePath } from "./lib/utils/fs";
5
+ /**
6
+ * All symbols documented under the Models namespace are also available in the root import.
7
+ */
8
+ export * as Models from "./lib/models";
5
9
  export * from "./lib/models";
6
10
  export { Converter, Context, type CommentParserConfig, type DeclarationReference, type SymbolReference, type ComponentPath, type Meaning, type MeaningKeyword, type ExternalResolveResult, type ExternalSymbolResolver, } from "./lib/converter";
7
11
  export { Renderer, DefaultTheme, DefaultThemeRenderContext, UrlMapping, Theme, PageEvent, RendererEvent, MarkdownEvent, IndexEvent, } from "./lib/output";
package/dist/index.js CHANGED
@@ -10,6 +10,18 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
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
+ };
13
25
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
26
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
27
  };
@@ -17,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
30
  };
19
31
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.TypeScript = exports.SerializeEvent = exports.Deserializer = exports.Serializer = exports.JSONOutput = exports.MinimalSourceFile = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.CommentStyle = exports.BindOption = exports.ArgumentsReader = exports.IndexEvent = 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;
32
+ exports.TypeScript = exports.SerializeEvent = exports.Deserializer = exports.Serializer = exports.JSONOutput = exports.MinimalSourceFile = exports.EventHooks = exports.EntryPointStrategy = exports.TypeDocReader = exports.TSConfigReader = exports.ParameterType = exports.ParameterHint = exports.PackageJsonReader = exports.Options = exports.Logger = exports.LogLevel = exports.JSX = exports.CommentStyle = exports.BindOption = exports.ArgumentsReader = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = exports.Theme = exports.UrlMapping = exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Renderer = exports.Context = exports.Converter = exports.Models = exports.normalizePath = exports.resetReflectionID = exports.Event = exports.EventDispatcher = exports.Application = void 0;
21
33
  var application_1 = require("./lib/application");
22
34
  Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return application_1.Application; } });
23
35
  var events_1 = require("./lib/utils/events");
@@ -27,6 +39,10 @@ var abstract_1 = require("./lib/models/reflections/abstract");
27
39
  Object.defineProperty(exports, "resetReflectionID", { enumerable: true, get: function () { return abstract_1.resetReflectionID; } });
28
40
  var fs_1 = require("./lib/utils/fs");
29
41
  Object.defineProperty(exports, "normalizePath", { enumerable: true, get: function () { return fs_1.normalizePath; } });
42
+ /**
43
+ * All symbols documented under the Models namespace are also available in the root import.
44
+ */
45
+ exports.Models = __importStar(require("./lib/models"));
30
46
  __exportStar(require("./lib/models"), exports);
31
47
  var converter_1 = require("./lib/converter");
32
48
  Object.defineProperty(exports, "Converter", { enumerable: true, get: function () { return converter_1.Converter; } });
@@ -173,7 +173,7 @@ function discoverSignatureComment(declaration, commentStyle) {
173
173
  end: comment.end,
174
174
  },
175
175
  ],
176
- jsDoc: undefined,
176
+ jsDoc: comment,
177
177
  };
178
178
  }
179
179
  const text = node.getSourceFile().text;
@@ -114,10 +114,10 @@ class Context {
114
114
  if (exportSymbol &&
115
115
  reflection.kind &
116
116
  (index_1.ReflectionKind.SomeModule | index_1.ReflectionKind.Reference)) {
117
- reflection.comment = (0, comments_1.getComment)(exportSymbol, reflection.kind, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined);
117
+ reflection.comment = this.getComment(exportSymbol, reflection.kind);
118
118
  }
119
119
  if (symbol && !reflection.comment) {
120
- reflection.comment = (0, comments_1.getComment)(symbol, reflection.kind, this.converter.config, this.logger, this.converter.commentStyle, this.converter.useTsLinkResolution ? this.checker : undefined);
120
+ reflection.comment = this.getComment(symbol, reflection.kind);
121
121
  }
122
122
  if (this.shouldBeStatic) {
123
123
  reflection.setFlag(index_1.ReflectionFlag.Static);
@@ -27,6 +27,8 @@ export declare class Converter extends ChildableComponent<Application, Converter
27
27
  /** @internal */
28
28
  excludeProtected: boolean;
29
29
  /** @internal */
30
+ excludeReferences: boolean;
31
+ /** @internal */
30
32
  commentStyle: CommentStyle;
31
33
  /** @internal */
32
34
  validation: ValidationOptions;
@@ -57,13 +59,13 @@ export declare class Converter extends ChildableComponent<Application, Converter
57
59
  */
58
60
  /**
59
61
  * Triggered when the converter has created a declaration reflection.
60
- * The listener will be given {@link Context} and a {@link DeclarationReflection}.
62
+ * The listener will be given {@link Context} and a {@link Models.DeclarationReflection}.
61
63
  * @event
62
64
  */
63
65
  static readonly EVENT_CREATE_DECLARATION: "createDeclaration";
64
66
  /**
65
67
  * Triggered when the converter has created a signature reflection.
66
- * The listener will be given {@link Context}, {@link SignatureReflection} | {@link ProjectReflection} the declaration,
68
+ * The listener will be given {@link Context}, {@link Models.SignatureReflection} | {@link Models.ProjectReflection} the declaration,
67
69
  * `ts.SignatureDeclaration | ts.IndexSignatureDeclaration | ts.JSDocSignature | undefined`,
68
70
  * and `ts.Signature | undefined`. The signature will be undefined if the created signature is an index signature.
69
71
  * @event
@@ -71,13 +73,13 @@ export declare class Converter extends ChildableComponent<Application, Converter
71
73
  static readonly EVENT_CREATE_SIGNATURE: "createSignature";
72
74
  /**
73
75
  * Triggered when the converter has created a parameter reflection.
74
- * The listener will be given {@link Context}, {@link ParameterReflection} and a `ts.Node?`
76
+ * The listener will be given {@link Context}, {@link Models.ParameterReflection} and a `ts.Node?`
75
77
  * @event
76
78
  */
77
79
  static readonly EVENT_CREATE_PARAMETER: "createParameter";
78
80
  /**
79
81
  * Triggered when the converter has created a type parameter reflection.
80
- * The listener will be given {@link Context} and a {@link TypeParameterReflection}
82
+ * The listener will be given {@link Context} and a {@link Models.TypeParameterReflection}
81
83
  * @event
82
84
  */
83
85
  static readonly EVENT_CREATE_TYPE_PARAMETER: "createTypeParameter";
@@ -72,7 +72,6 @@ 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
- project.forgetTsReferences();
76
75
  return project;
77
76
  }
78
77
  /** @internal */
@@ -263,13 +262,13 @@ Converter.EVENT_END = converter_events_1.ConverterEvents.END;
263
262
  */
264
263
  /**
265
264
  * Triggered when the converter has created a declaration reflection.
266
- * The listener will be given {@link Context} and a {@link DeclarationReflection}.
265
+ * The listener will be given {@link Context} and a {@link Models.DeclarationReflection}.
267
266
  * @event
268
267
  */
269
268
  Converter.EVENT_CREATE_DECLARATION = converter_events_1.ConverterEvents.CREATE_DECLARATION;
270
269
  /**
271
270
  * Triggered when the converter has created a signature reflection.
272
- * The listener will be given {@link Context}, {@link SignatureReflection} | {@link ProjectReflection} the declaration,
271
+ * The listener will be given {@link Context}, {@link Models.SignatureReflection} | {@link Models.ProjectReflection} the declaration,
273
272
  * `ts.SignatureDeclaration | ts.IndexSignatureDeclaration | ts.JSDocSignature | undefined`,
274
273
  * and `ts.Signature | undefined`. The signature will be undefined if the created signature is an index signature.
275
274
  * @event
@@ -277,13 +276,13 @@ Converter.EVENT_CREATE_DECLARATION = converter_events_1.ConverterEvents.CREATE_D
277
276
  Converter.EVENT_CREATE_SIGNATURE = converter_events_1.ConverterEvents.CREATE_SIGNATURE;
278
277
  /**
279
278
  * Triggered when the converter has created a parameter reflection.
280
- * The listener will be given {@link Context}, {@link ParameterReflection} and a `ts.Node?`
279
+ * The listener will be given {@link Context}, {@link Models.ParameterReflection} and a `ts.Node?`
281
280
  * @event
282
281
  */
283
282
  Converter.EVENT_CREATE_PARAMETER = converter_events_1.ConverterEvents.CREATE_PARAMETER;
284
283
  /**
285
284
  * Triggered when the converter has created a type parameter reflection.
286
- * The listener will be given {@link Context} and a {@link TypeParameterReflection}
285
+ * The listener will be given {@link Context} and a {@link Models.TypeParameterReflection}
287
286
  * @event
288
287
  */
289
288
  Converter.EVENT_CREATE_TYPE_PARAMETER = converter_events_1.ConverterEvents.CREATE_TYPE_PARAMETER;
@@ -323,6 +322,9 @@ __decorate([
323
322
  __decorate([
324
323
  (0, utils_1.BindOption)("excludeProtected")
325
324
  ], Converter.prototype, "excludeProtected", void 0);
325
+ __decorate([
326
+ (0, utils_1.BindOption)("excludeReferences")
327
+ ], Converter.prototype, "excludeReferences", void 0);
326
328
  __decorate([
327
329
  (0, utils_1.BindOption)("commentStyle")
328
330
  ], Converter.prototype, "commentStyle", void 0);
@@ -50,6 +50,7 @@ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent
50
50
  [converter_1.Converter.EVENT_RESOLVE_BEGIN]: this.onBeginResolve,
51
51
  [converter_1.Converter.EVENT_END]: () => {
52
52
  delete this.readmeFile;
53
+ delete this.readmeContents;
53
54
  delete this.packageJson;
54
55
  },
55
56
  });
@@ -62,6 +63,7 @@ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent
62
63
  this.addEntries(project);
63
64
  delete this.readmeFile;
64
65
  delete this.packageJson;
66
+ delete this.readmeContents;
65
67
  }
66
68
  onBegin() {
67
69
  this.readmeFile = undefined;
@@ -117,7 +119,7 @@ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent
117
119
  project.name = project.packageName || "Documentation";
118
120
  }
119
121
  if (this.includeVersion) {
120
- project.packageVersion = this.packageJson.version;
122
+ project.packageVersion = this.packageJson.version?.replace(/^v/, "");
121
123
  }
122
124
  }
123
125
  else if (!project.name) {
@@ -80,7 +80,7 @@ function convertSymbol(context, symbol, exportSymbol) {
80
80
  // but aren't aliased symbols because `export *` was used.
81
81
  const previous = context.project.getReflectionFromSymbol(symbol);
82
82
  if (previous &&
83
- previous.parent?.kindOf(models_1.ReflectionKind.Module | models_1.ReflectionKind.Project)) {
83
+ previous.parent?.kindOf(models_1.ReflectionKind.SomeModule | models_1.ReflectionKind.Project)) {
84
84
  createAlias(previous, context, symbol, exportSymbol);
85
85
  return;
86
86
  }
@@ -191,7 +191,9 @@ function convertTypeAlias(context, symbol, exportSymbol) {
191
191
  typescript_1.default.isJSDocEnumTag(d));
192
192
  (0, assert_1.default)(declaration);
193
193
  if (typescript_1.default.isTypeAliasDeclaration(declaration)) {
194
- if (symbol.getJsDocTags().some((tag) => tag.name === "interface")) {
194
+ if (context
195
+ .getComment(symbol, models_1.ReflectionKind.TypeAlias)
196
+ ?.hasModifier("@interface")) {
195
197
  return convertTypeAliasAsInterface(context, symbol, exportSymbol, declaration);
196
198
  }
197
199
  const reflection = context.createDeclarationReflection(models_1.ReflectionKind.TypeAlias, symbol, exportSymbol);
@@ -444,6 +446,8 @@ function convertAlias(context, symbol, exportSymbol) {
444
446
  }
445
447
  }
446
448
  function createAlias(target, context, symbol, exportSymbol) {
449
+ if (context.converter.excludeReferences)
450
+ return;
447
451
  // We already have this. Create a reference.
448
452
  const ref = new models_1.ReferenceReflection(exportSymbol?.name ?? symbol.name, target, context.scope);
449
453
  context.postReflectionCreation(ref, symbol, exportSymbol);
@@ -452,12 +456,13 @@ function createAlias(target, context, symbol, exportSymbol) {
452
456
  function convertVariable(context, symbol, exportSymbol) {
453
457
  const declaration = symbol.getDeclarations()?.[0];
454
458
  (0, assert_1.default)(declaration);
459
+ const comment = context.getComment(symbol, models_1.ReflectionKind.Variable);
455
460
  const type = context.checker.getTypeOfSymbolAtLocation(symbol, declaration);
456
461
  if (isEnumLike(context.checker, type, declaration) &&
457
- symbol.getJsDocTags().some((tag) => tag.name === "enum")) {
462
+ comment?.hasModifier("@enum")) {
458
463
  return convertVariableAsEnum(context, symbol, exportSymbol);
459
464
  }
460
- if (symbol.getJsDocTags().some((tag) => tag.name === "namespace")) {
465
+ if (comment?.hasModifier("@namespace")) {
461
466
  return convertVariableAsNamespace(context, symbol, exportSymbol);
462
467
  }
463
468
  if (type.getCallSignatures().length) {
@@ -1,4 +1,5 @@
1
- import type { Reflection, ReflectionSymbolId } from "../reflections";
1
+ import type { Reflection } from "../reflections";
2
+ import { ReflectionSymbolId } from "../reflections/ReflectionSymbolId";
2
3
  import type { Serializer, Deserializer, JSONOutput } from "../../serialization";
3
4
  export type CommentDisplayPart = {
4
5
  kind: "text";
@@ -99,7 +100,6 @@ export declare class Comment {
99
100
  modifierTags: Set<string>;
100
101
  /**
101
102
  * Label associated with this reflection, if any (https://tsdoc.org/pages/tags/label/)
102
- * Added by the CommentPlugin during resolution.
103
103
  */
104
104
  label?: string;
105
105
  /**
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Comment = exports.CommentTag = void 0;
4
4
  const utils_1 = require("../../utils");
5
+ const ReflectionSymbolId_1 = require("../reflections/ReflectionSymbolId");
5
6
  /**
6
7
  * A model that represents a single TypeDoc comment tag.
7
8
  *
@@ -162,20 +163,39 @@ class Comment {
162
163
  case "code":
163
164
  return { ...part };
164
165
  case "inline-tag": {
165
- if (typeof part.target !== "number") {
166
- // TS isn't quite smart enough here...
167
- // GERRIT this is wrong
168
- return { ...part };
169
- }
170
- else {
166
+ if (typeof part.target === "number") {
171
167
  const part2 = {
172
168
  kind: part.kind,
173
169
  tag: part.tag,
174
170
  text: part.text,
171
+ target: undefined,
172
+ tsLinkText: part.tsLinkText,
175
173
  };
176
174
  links.push([part.target, part2]);
177
175
  return part2;
178
176
  }
177
+ else if (typeof part.target === "string" ||
178
+ part.target === undefined) {
179
+ return {
180
+ kind: "inline-tag",
181
+ tag: part.tag,
182
+ text: part.text,
183
+ target: part.target,
184
+ tsLinkText: part.tsLinkText,
185
+ };
186
+ }
187
+ else if (typeof part.target === "object") {
188
+ return {
189
+ kind: "inline-tag",
190
+ tag: part.tag,
191
+ text: part.text,
192
+ target: new ReflectionSymbolId_1.ReflectionSymbolId(part.target),
193
+ tsLinkText: part.tsLinkText,
194
+ };
195
+ }
196
+ else {
197
+ (0, utils_1.assertNever)(part.target);
198
+ }
179
199
  }
180
200
  }
181
201
  });
@@ -40,7 +40,7 @@ export declare enum ConversionFlags {
40
40
  * kind of a reflection is stored in its ´kind´ member.
41
41
  */
42
42
  export declare class DeclarationReflection extends ContainerReflection {
43
- readonly variant: "reference" | "declaration";
43
+ readonly variant: "declaration" | "reference";
44
44
  /**
45
45
  * A list of all source files that contributed to this reflection.
46
46
  */
@@ -52,12 +52,6 @@ export declare class ProjectReflection extends ContainerReflection {
52
52
  * @returns An array containing all reflections with the desired kind.
53
53
  */
54
54
  getReflectionsByKind(kind: ReflectionKind): Reflection[];
55
- /**
56
- * Disassociate this project with all TypeScript created objects, allowing the underlying
57
- * `ts.Program` to be garbage collected. This is very important for monorepo projects where
58
- * we need to create multiple programs. See #1606 and surrounding discussion.
59
- */
60
- forgetTsReferences(): void;
61
55
  /**
62
56
  * Registers the given reflection so that it can be quickly looked up by helper methods.
63
57
  * Should be called for *every* reflection added to the project.
@@ -49,22 +49,6 @@ class ProjectReflection extends container_1.ContainerReflection {
49
49
  getReflectionsByKind(kind) {
50
50
  return Object.values(this.reflections).filter((reflection) => reflection.kindOf(kind));
51
51
  }
52
- /**
53
- * Disassociate this project with all TypeScript created objects, allowing the underlying
54
- * `ts.Program` to be garbage collected. This is very important for monorepo projects where
55
- * we need to create multiple programs. See #1606 and surrounding discussion.
56
- */
57
- forgetTsReferences() {
58
- // Clear ts.Symbol references
59
- this.reflectionIdToSymbolMap.clear();
60
- // TODO: I think we need to do something like this.
61
- // Update local references
62
- this.symbolToReflectionIdMap.clear();
63
- for (const [k, v] of this.reflectionIdToSymbolIdMap) {
64
- v.pos = Infinity;
65
- this.symbolToReflectionIdMap.set(v, k);
66
- }
67
- }
68
52
  /**
69
53
  * Registers the given reflection so that it can be quickly looked up by helper methods.
70
54
  * Should be called for *every* reflection added to the project.
@@ -24,11 +24,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.UnknownType = exports.UnionType = exports.TypeOperatorType = exports.NamedTupleMember = exports.TupleType = exports.TemplateLiteralType = exports.RestType = exports.ReflectionType = exports.ReferenceType = exports.QueryType = exports.PredicateType = exports.OptionalType = exports.MappedType = exports.LiteralType = exports.IntrinsicType = exports.IntersectionType = exports.InferredType = exports.IndexedAccessType = exports.ConditionalType = exports.ArrayType = exports.TypeContext = exports.makeRecursiveVisitor = exports.Type = void 0;
27
- const fs = __importStar(require("fs"));
28
- const path = __importStar(require("path"));
29
27
  const ts = __importStar(require("typescript"));
30
28
  const tsutils_1 = require("../utils/tsutils");
31
29
  const ReflectionSymbolId_1 = require("./reflections/ReflectionSymbolId");
30
+ const fs_1 = require("../utils/fs");
32
31
  /**
33
32
  * Base class of all type definitions.
34
33
  */
@@ -740,7 +739,7 @@ class ReferenceType extends Type {
740
739
  return ref;
741
740
  }
742
741
  // Otherwise, look for a "package.json" file in a parent path
743
- ref.package = findPackageForPath(symbolPath);
742
+ ref.package = (0, fs_1.findPackageForPath)(symbolPath);
744
743
  return ref;
745
744
  }
746
745
  /** @internal this is used for type parameters, which don't actually point to something */
@@ -1134,31 +1133,3 @@ class UnknownType extends Type {
1134
1133
  }
1135
1134
  }
1136
1135
  exports.UnknownType = UnknownType;
1137
- const packageJsonLookupCache = {};
1138
- function findPackageForPath(sourcePath) {
1139
- if (packageJsonLookupCache[sourcePath] !== undefined) {
1140
- return packageJsonLookupCache[sourcePath];
1141
- }
1142
- let basePath = sourcePath;
1143
- for (;;) {
1144
- const nextPath = path.dirname(basePath);
1145
- if (nextPath === basePath) {
1146
- return;
1147
- }
1148
- basePath = nextPath;
1149
- const projectPath = path.join(basePath, "package.json");
1150
- try {
1151
- const packageJsonData = fs.readFileSync(projectPath, {
1152
- encoding: "utf8",
1153
- });
1154
- const packageJson = JSON.parse(packageJsonData);
1155
- if (packageJson.name !== undefined) {
1156
- packageJsonLookupCache[sourcePath] = packageJson.name;
1157
- }
1158
- return packageJson.name;
1159
- }
1160
- catch (err) {
1161
- continue;
1162
- }
1163
- }
1164
- }
@@ -1,5 +1,5 @@
1
1
  import { Component, AbstractComponent } from "../utils/component";
2
- import { ProjectReflection, DeclarationReflection } from "../models/reflections/index";
2
+ import type { ProjectReflection, Reflection } from "../models/reflections/index";
3
3
  import type { Renderer } from "./renderer";
4
4
  import { RendererEvent, PageEvent } from "./events";
5
5
  export { Component };
@@ -16,7 +16,7 @@ export declare abstract class ContextAwareRendererComponent extends RendererComp
16
16
  /**
17
17
  * The reflection that is currently processed.
18
18
  */
19
- protected reflection?: DeclarationReflection;
19
+ protected page?: PageEvent<Reflection>;
20
20
  /**
21
21
  * The url of the document that is being currently generated.
22
22
  * Set when a page begins rendering.
@@ -50,5 +50,5 @@ export declare abstract class ContextAwareRendererComponent extends RendererComp
50
50
  *
51
51
  * @param page An event object describing the current render operation.
52
52
  */
53
- protected onBeginPage(page: PageEvent): void;
53
+ protected onBeginPage(page: PageEvent<Reflection>): void;
54
54
  }
@@ -27,7 +27,6 @@ exports.ContextAwareRendererComponent = exports.RendererComponent = exports.Comp
27
27
  const Path = __importStar(require("path"));
28
28
  const component_1 = require("../utils/component");
29
29
  Object.defineProperty(exports, "Component", { enumerable: true, get: function () { return component_1.Component; } });
30
- const index_1 = require("../models/reflections/index");
31
30
  const events_1 = require("./events");
32
31
  class RendererComponent extends component_1.AbstractComponent {
33
32
  }
@@ -84,10 +83,7 @@ class ContextAwareRendererComponent extends RendererComponent {
84
83
  */
85
84
  onBeginPage(page) {
86
85
  this.location = page.url;
87
- this.reflection =
88
- page.model instanceof index_1.DeclarationReflection
89
- ? page.model
90
- : undefined;
86
+ this.page = page;
91
87
  }
92
88
  }
93
89
  exports.ContextAwareRendererComponent = ContextAwareRendererComponent;
@@ -1,7 +1,7 @@
1
1
  import { Event } from "../utils/events";
2
2
  import type { ProjectReflection } from "../models/reflections/project";
3
3
  import type { RenderTemplate, UrlMapping } from "./models/UrlMapping";
4
- import type { DeclarationReflection } from "../models";
4
+ import type { DeclarationReflection, ReflectionKind } from "../models";
5
5
  /**
6
6
  * An event emitted by the {@link Renderer} class at the very beginning and
7
7
  * ending of the entire rendering process.
@@ -42,7 +42,7 @@ export declare class RendererEvent extends Event {
42
42
  * @param mapping The mapping that defines the generated {@link PageEvent} state.
43
43
  * @returns A newly created {@link PageEvent} instance.
44
44
  */
45
- createPageEvent<Model>(mapping: UrlMapping<Model>): PageEvent<Model>;
45
+ createPageEvent<Model>(mapping: UrlMapping<Model>): [RenderTemplate<PageEvent<Model>>, PageEvent<Model>];
46
46
  }
47
47
  /**
48
48
  * An event emitted by the {@link Renderer} class before and after the
@@ -51,7 +51,7 @@ export declare class RendererEvent extends Event {
51
51
  * @see {@link Renderer.EVENT_BEGIN_PAGE}
52
52
  * @see {@link Renderer.EVENT_END_PAGE}
53
53
  */
54
- export declare class PageEvent<Model = unknown> extends Event {
54
+ export declare class PageEvent<out Model = unknown> extends Event {
55
55
  /**
56
56
  * The project the renderer is currently processing.
57
57
  */
@@ -67,17 +67,24 @@ export declare class PageEvent<Model = unknown> extends Event {
67
67
  /**
68
68
  * The model that should be rendered on this page.
69
69
  */
70
- model: Model;
71
- /**
72
- * The template that should be used to render this page.
73
- */
74
- template: RenderTemplate<this>;
70
+ readonly model: Model;
75
71
  /**
76
72
  * The final html content of this page.
77
73
  *
78
74
  * Should be rendered by layout templates and can be modified by plugins.
79
75
  */
80
76
  contents?: string;
77
+ /**
78
+ * Links to content within this page that should be rendered in the page navigation.
79
+ * This is built when rendering the document content.
80
+ */
81
+ pageHeadings: Array<{
82
+ link: string;
83
+ text: string;
84
+ level?: number;
85
+ kind?: ReflectionKind;
86
+ classes?: string;
87
+ }>;
81
88
  /**
82
89
  * Triggered before a document will be rendered.
83
90
  * @event
@@ -88,11 +95,12 @@ export declare class PageEvent<Model = unknown> extends Event {
88
95
  * @event
89
96
  */
90
97
  static readonly END = "endPage";
98
+ constructor(name: string, model: Model);
91
99
  }
92
100
  /**
93
101
  * An event emitted when markdown is being parsed. Allows other plugins to manipulate the result.
94
102
  *
95
- * @see {@link PARSE}
103
+ * @see {@link MarkdownEvent.PARSE}
96
104
  */
97
105
  export declare class MarkdownEvent extends Event {
98
106
  /**
@@ -103,12 +111,16 @@ export declare class MarkdownEvent extends Event {
103
111
  * The parsed output.
104
112
  */
105
113
  parsedText: string;
114
+ /**
115
+ * The page that this markdown is being parsed for.
116
+ */
117
+ readonly page: PageEvent;
106
118
  /**
107
119
  * Triggered on the renderer when this plugin parses a markdown string.
108
120
  * @event
109
121
  */
110
122
  static readonly PARSE = "parseMarkdown";
111
- constructor(name: string, originalText: string, parsedText: string);
123
+ constructor(name: string, page: PageEvent, originalText: string, parsedText: string);
112
124
  }
113
125
  /**
114
126
  * An event emitted when the search index is being prepared.
@@ -47,13 +47,11 @@ class RendererEvent extends events_1.Event {
47
47
  * @returns A newly created {@link PageEvent} instance.
48
48
  */
49
49
  createPageEvent(mapping) {
50
- const event = new PageEvent(PageEvent.BEGIN);
50
+ const event = new PageEvent(PageEvent.BEGIN, mapping.model);
51
51
  event.project = this.project;
52
52
  event.url = mapping.url;
53
- event.model = mapping.model;
54
- event.template = mapping.template;
55
53
  event.filename = Path.join(this.outputDirectory, mapping.url);
56
- return event;
54
+ return [mapping.template, event];
57
55
  }
58
56
  }
59
57
  /**
@@ -75,6 +73,15 @@ exports.RendererEvent = RendererEvent;
75
73
  * @see {@link Renderer.EVENT_END_PAGE}
76
74
  */
77
75
  class PageEvent extends events_1.Event {
76
+ constructor(name, model) {
77
+ super(name);
78
+ /**
79
+ * Links to content within this page that should be rendered in the page navigation.
80
+ * This is built when rendering the document content.
81
+ */
82
+ this.pageHeadings = [];
83
+ this.model = model;
84
+ }
78
85
  }
79
86
  /**
80
87
  * Triggered before a document will be rendered.
@@ -90,11 +97,12 @@ exports.PageEvent = PageEvent;
90
97
  /**
91
98
  * An event emitted when markdown is being parsed. Allows other plugins to manipulate the result.
92
99
  *
93
- * @see {@link PARSE}
100
+ * @see {@link MarkdownEvent.PARSE}
94
101
  */
95
102
  class MarkdownEvent extends events_1.Event {
96
- constructor(name, originalText, parsedText) {
103
+ constructor(name, page, originalText, parsedText) {
97
104
  super(name);
105
+ this.page = page;
98
106
  this.originalText = originalText;
99
107
  this.parsedText = parsedText;
100
108
  }
@@ -95,9 +95,7 @@ let JavascriptIndexPlugin = class JavascriptIndexPlugin extends components_1.Ren
95
95
  kind: reflection.kind,
96
96
  name: reflection.name,
97
97
  url: reflection.url,
98
- classes: this.owner.theme
99
- .getRenderContext()
100
- .getReflectionClasses(reflection),
98
+ classes: this.owner.theme.getReflectionClasses(reflection),
101
99
  };
102
100
  if (parent) {
103
101
  row.parent = parent.getFullName();
@@ -38,13 +38,21 @@ export interface RendererHooks {
38
38
  */
39
39
  "content.end": [DefaultThemeRenderContext];
40
40
  /**
41
- * Applied immediately before calling `context.navigation`.
41
+ * Applied immediately before calling `context.sidebar`.
42
42
  */
43
- "navigation.begin": [DefaultThemeRenderContext];
43
+ "sidebar.begin": [DefaultThemeRenderContext];
44
44
  /**
45
- * Applied immediately after calling `context.navigation`.
45
+ * Applied immediately after calling `context.sidebar`.
46
46
  */
47
- "navigation.end": [DefaultThemeRenderContext];
47
+ "sidebar.end": [DefaultThemeRenderContext];
48
+ /**
49
+ * Applied immediately before calling `context.pageSidebar`.
50
+ */
51
+ "pageSidebar.begin": [DefaultThemeRenderContext];
52
+ /**
53
+ * Applied immediately after calling `context.pageSidebar`.
54
+ */
55
+ "pageSidebar.end": [DefaultThemeRenderContext];
48
56
  }
49
57
  /**
50
58
  * The renderer processes a {@link ProjectReflection} using a {@link Theme} instance and writes
@@ -156,7 +156,7 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
156
156
  this.application.logger.verbose(`There are ${output.urls.length} pages to write.`);
157
157
  output.urls.forEach((mapping) => {
158
158
  (0, icon_1.clearSeenIconCache)();
159
- this.renderDocument(output.createPageEvent(mapping));
159
+ this.renderDocument(...output.createPageEvent(mapping));
160
160
  (0, type_1.validateStateIsClean)(mapping.url);
161
161
  });
162
162
  await Promise.all(this.postRenderAsyncJobs.map((job) => job(output)));
@@ -172,7 +172,7 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
172
172
  * @param page An event describing the current page.
173
173
  * @return TRUE if the page has been saved to disc, otherwise FALSE.
174
174
  */
175
- renderDocument(page) {
175
+ renderDocument(template, page) {
176
176
  const momento = this.hooks.saveMomento();
177
177
  this.trigger(events_1.PageEvent.BEGIN, page);
178
178
  if (page.isDefaultPrevented) {
@@ -180,7 +180,7 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
180
180
  return false;
181
181
  }
182
182
  if (page.model instanceof models_1.Reflection) {
183
- page.contents = this.theme.render(page);
183
+ page.contents = this.theme.render(page, template);
184
184
  }
185
185
  else {
186
186
  throw new Error("Should be unreachable");