typedoc 0.23.3 → 0.23.6

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 (38) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +2 -1
  3. package/dist/lib/converter/converter.js +19 -2
  4. package/dist/lib/converter/plugins/LinkResolverPlugin.js +5 -1
  5. package/dist/lib/converter/plugins/PackagePlugin.d.ts +2 -0
  6. package/dist/lib/converter/plugins/PackagePlugin.js +13 -2
  7. package/dist/lib/models/reflections/declaration.d.ts +9 -0
  8. package/dist/lib/output/events.d.ts +43 -0
  9. package/dist/lib/output/events.js +38 -1
  10. package/dist/lib/output/index.d.ts +1 -1
  11. package/dist/lib/output/index.js +2 -1
  12. package/dist/lib/output/plugins/JavascriptIndexPlugin.d.ts +2 -0
  13. package/dist/lib/output/plugins/JavascriptIndexPlugin.js +50 -18
  14. package/dist/lib/output/renderer.d.ts +6 -0
  15. package/dist/lib/output/renderer.js +6 -0
  16. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +4 -0
  17. package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +5 -0
  18. package/dist/lib/output/themes/default/partials/anchor-icon.d.ts +2 -1
  19. package/dist/lib/output/themes/default/partials/anchor-icon.js +1 -2
  20. package/dist/lib/output/themes/default/partials/header.d.ts +1 -1
  21. package/dist/lib/output/themes/default/partials/header.js +4 -0
  22. package/dist/lib/output/themes/default/partials/icon.d.ts +1 -3
  23. package/dist/lib/output/themes/default/partials/index.d.ts +1 -1
  24. package/dist/lib/output/themes/default/partials/index.js +12 -6
  25. package/dist/lib/output/themes/default/partials/member.js +1 -1
  26. package/dist/lib/output/themes/default/partials/navigation.d.ts +3 -0
  27. package/dist/lib/output/themes/default/partials/navigation.js +16 -14
  28. package/dist/lib/output/themes/default/partials/toolbar.js +2 -3
  29. package/dist/lib/serialization/components.d.ts +6 -1
  30. package/dist/lib/utils/entry-point.d.ts +2 -0
  31. package/dist/lib/utils/entry-point.js +19 -2
  32. package/dist/lib/utils/loggers.js +8 -6
  33. package/dist/lib/utils/options/declaration.d.ts +1 -0
  34. package/dist/lib/utils/options/sources/typedoc.js +5 -0
  35. package/dist/lib/utils/package-manifest.d.ts +15 -1
  36. package/dist/lib/utils/package-manifest.js +40 -4
  37. package/package.json +1 -1
  38. package/static/main.js +2 -2
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { resetReflectionID } from "./lib/models/reflections/abstract";
4
4
  export { normalizePath } from "./lib/utils/fs";
5
5
  export * from "./lib/models";
6
6
  export { Converter, Context, type CommentParserConfig } from "./lib/converter";
7
- export { Renderer, DefaultTheme, DefaultThemeRenderContext, UrlMapping, Theme, PageEvent, RendererEvent, MarkdownEvent, } from "./lib/output";
7
+ export { Renderer, DefaultTheme, DefaultThemeRenderContext, UrlMapping, Theme, PageEvent, RendererEvent, MarkdownEvent, IndexEvent, } from "./lib/output";
8
8
  export type { RenderTemplate, RendererHooks } from "./lib/output";
9
9
  export { ArgumentsReader, BindOption, CommentStyle, JSX, LogLevel, Logger, Options, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, EntryPointStrategy, EventHooks, MinimalSourceFile, } 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";
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.MinimalSourceFile = 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;
17
+ exports.TypeScript = exports.SerializeEvent = exports.Serializer = exports.JSONOutput = exports.MinimalSourceFile = 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.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;
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");
@@ -37,6 +37,7 @@ Object.defineProperty(exports, "Theme", { enumerable: true, get: function () { r
37
37
  Object.defineProperty(exports, "PageEvent", { enumerable: true, get: function () { return output_1.PageEvent; } });
38
38
  Object.defineProperty(exports, "RendererEvent", { enumerable: true, get: function () { return output_1.RendererEvent; } });
39
39
  Object.defineProperty(exports, "MarkdownEvent", { enumerable: true, get: function () { return output_1.MarkdownEvent; } });
40
+ Object.defineProperty(exports, "IndexEvent", { enumerable: true, get: function () { return output_1.IndexEvent; } });
40
41
  var utils_1 = require("./lib/utils");
41
42
  Object.defineProperty(exports, "ArgumentsReader", { enumerable: true, get: function () { return utils_1.ArgumentsReader; } });
42
43
  Object.defineProperty(exports, "BindOption", { enumerable: true, get: function () { return utils_1.BindOption; } });
@@ -20,6 +20,8 @@ const symbols_1 = require("./symbols");
20
20
  const paths_1 = require("../utils/paths");
21
21
  const enum_1 = require("../utils/enum");
22
22
  const comments_1 = require("./comments");
23
+ const parser_1 = require("./comments/parser");
24
+ const rawLexer_1 = require("./comments/rawLexer");
23
25
  /**
24
26
  * Compiles source files using TypeScript and converts compiler symbols to reflections.
25
27
  */
@@ -73,7 +75,7 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
73
75
  });
74
76
  entries.forEach((e) => {
75
77
  context.setActiveProgram(e.entryPoint.program);
76
- e.context = this.convertExports(context, e.entryPoint.sourceFile, entries.length === 1, e.entryPoint.displayName);
78
+ e.context = this.convertExports(context, e.entryPoint, entries.length === 1);
77
79
  });
78
80
  for (const { entryPoint, context } of entries) {
79
81
  // active program is already set on context
@@ -84,7 +86,9 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
84
86
  }
85
87
  context.setActiveProgram(undefined);
86
88
  }
87
- convertExports(context, node, singleEntryPoint, entryName) {
89
+ convertExports(context, entryPoint, singleEntryPoint) {
90
+ const node = entryPoint.sourceFile;
91
+ const entryName = entryPoint.displayName;
88
92
  const symbol = getSymbolForModuleLike(context, node);
89
93
  let moduleContext;
90
94
  const allExports = getExports(context, node, symbol);
@@ -104,6 +108,19 @@ let Converter = Converter_1 = class Converter extends component_1.ChildableCompo
104
108
  }
105
109
  else {
106
110
  const reflection = context.createDeclarationReflection(index_1.ReflectionKind.Module, symbol, void 0, entryName);
111
+ if (entryPoint.readmeFile) {
112
+ const readme = (0, utils_1.readFile)(entryPoint.readmeFile);
113
+ const comment = (0, parser_1.parseComment)((0, rawLexer_1.lexCommentString)(readme), context.converter.config, new utils_1.MinimalSourceFile(readme, entryPoint.readmeFile), context.logger);
114
+ if (comment.blockTags.length || comment.modifierTags.size) {
115
+ const ignored = [
116
+ ...comment.blockTags.map((tag) => tag.tag),
117
+ ...comment.modifierTags,
118
+ ];
119
+ context.logger.warn(`Block and modifier tags will be ignored within the readme:\n\t${ignored.join("\n\t")}`);
120
+ }
121
+ reflection.readme = comment.summary;
122
+ }
123
+ reflection.version = entryPoint.version;
107
124
  context.finalizeDeclarationReflection(reflection);
108
125
  moduleContext = context.withScope(reflection);
109
126
  }
@@ -14,8 +14,9 @@ const declarationReference_1 = require("../comments/declarationReference");
14
14
  const ts = require("typescript");
15
15
  const utils_1 = require("../../utils");
16
16
  const declarationReferenceResolver_1 = require("../comments/declarationReferenceResolver");
17
+ const models_1 = require("../../models");
17
18
  const urlPrefix = /^(http|ftp)s?:\/\//;
18
- const brackets = /\[\[([^\]]+)\]\]/g;
19
+ const brackets = /\[\[(?!include:)([^\]]+)\]\]/g;
19
20
  /**
20
21
  * A plugin that resolves `{@link Foo}` tags.
21
22
  */
@@ -113,6 +114,9 @@ let LinkResolverPlugin = LinkResolverPlugin_1 = class LinkResolverPlugin extends
113
114
  for (const tag of comment.blockTags) {
114
115
  tag.content = this.processParts(reflection, tag.content, warn);
115
116
  }
117
+ if (reflection instanceof models_1.DeclarationReflection && reflection.readme) {
118
+ reflection.readme = this.processParts(reflection, reflection.readme, warn);
119
+ }
116
120
  }
117
121
  processParts(reflection, parts, warn) {
118
122
  return parts.flatMap((part) => this.processPart(reflection, part, warn));
@@ -1,4 +1,5 @@
1
1
  import { ConverterComponent } from "../components";
2
+ import { EntryPointStrategy } from "../../utils";
2
3
  /**
3
4
  * A handler that tries to find the package.json and readme.md files of the
4
5
  * current project.
@@ -6,6 +7,7 @@ import { ConverterComponent } from "../components";
6
7
  export declare class PackagePlugin extends ConverterComponent {
7
8
  readme: string;
8
9
  includeVersion: boolean;
10
+ entryPointStrategy: EntryPointStrategy;
9
11
  /**
10
12
  * The file name of the found readme.md file.
11
13
  */
@@ -102,7 +102,11 @@ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent
102
102
  project.name = `${project.name} - v${packageInfo.version}`;
103
103
  }
104
104
  else {
105
- context.logger.warn("--includeVersion was specified, but package.json does not specify a version.");
105
+ // since not all monorepo specifies a meaningful version to the main package.json
106
+ // this warning should be optional
107
+ if (this.entryPointStrategy !== utils_1.EntryPointStrategy.Packages) {
108
+ context.logger.warn("--includeVersion was specified, but package.json does not specify a version.");
109
+ }
106
110
  }
107
111
  }
108
112
  }
@@ -112,7 +116,11 @@ let PackagePlugin = class PackagePlugin extends components_1.ConverterComponent
112
116
  project.name = "Documentation";
113
117
  }
114
118
  if (this.includeVersion) {
115
- context.logger.warn("--includeVersion was specified, but no package.json was found. Not adding package version to the documentation.");
119
+ // since not all monorepo specifies a meaningful version to the main package.json
120
+ // this warning should be optional
121
+ if (this.entryPointStrategy !== utils_1.EntryPointStrategy.Packages) {
122
+ context.logger.warn("--includeVersion was specified, but no package.json was found. Not adding package version to the documentation.");
123
+ }
116
124
  }
117
125
  }
118
126
  }
@@ -123,6 +131,9 @@ __decorate([
123
131
  __decorate([
124
132
  (0, utils_1.BindOption)("includeVersion")
125
133
  ], PackagePlugin.prototype, "includeVersion", void 0);
134
+ __decorate([
135
+ (0, utils_1.BindOption)("entryPointStrategy")
136
+ ], PackagePlugin.prototype, "entryPointStrategy", void 0);
126
137
  PackagePlugin = __decorate([
127
138
  (0, components_1.Component)({ name: "package" })
128
139
  ], PackagePlugin);
@@ -5,6 +5,7 @@ import { ContainerReflection } from "./container";
5
5
  import type { SignatureReflection } from "./signature";
6
6
  import type { TypeParameterReflection } from "./type-parameter";
7
7
  import type { Serializer, JSONOutput } from "../../serialization";
8
+ import type { CommentDisplayPart } from "../comments";
8
9
  /**
9
10
  * Stores hierarchical type data.
10
11
  *
@@ -109,6 +110,14 @@ export declare class DeclarationReflection extends ContainerReflection {
109
110
  * rendered in templates.
110
111
  */
111
112
  typeHierarchy?: DeclarationHierarchy;
113
+ /**
114
+ * The contents of the readme file of the module when found.
115
+ */
116
+ readme?: CommentDisplayPart[];
117
+ /**
118
+ * The version of the module when found.
119
+ */
120
+ version?: string;
112
121
  hasGetterOrSetter(): boolean;
113
122
  getAllSignatures(): SignatureReflection[];
114
123
  /** @internal */
@@ -1,6 +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
5
  /**
5
6
  * An event emitted by the {@link Renderer} class at the very beginning and
6
7
  * ending of the entire rendering process.
@@ -109,3 +110,45 @@ export declare class MarkdownEvent extends Event {
109
110
  static readonly PARSE = "parseMarkdown";
110
111
  constructor(name: string, originalText: string, parsedText: string);
111
112
  }
113
+ /**
114
+ * An event emitted when the search index is being prepared.
115
+ */
116
+ export declare class IndexEvent extends Event {
117
+ /**
118
+ * Triggered on the renderer when the search index is being prepared.
119
+ * @event
120
+ */
121
+ static readonly PREPARE_INDEX = "prepareIndex";
122
+ /**
123
+ * May be filtered by plugins to reduce the results available.
124
+ * Additional items *should not* be added to this array.
125
+ *
126
+ * If you remove an index from this array, you must also remove the
127
+ * same index from {@link searchFields}. The {@link removeResult} helper
128
+ * will do this for you.
129
+ */
130
+ searchResults: DeclarationReflection[];
131
+ /**
132
+ * Additional search fields to be used when creating the search index.
133
+ * `name` and `comment` may be specified to overwrite TypeDoc's search fields.
134
+ *
135
+ * Do not use `id` as a custom search field.
136
+ */
137
+ searchFields: Record<string, string>[];
138
+ /**
139
+ * Weights for the fields defined in `searchFields`. The default will weight
140
+ * `name` as 10x more important than comment content.
141
+ *
142
+ * If a field added to {@link searchFields} is not added to this object, it
143
+ * will **not** be searchable.
144
+ *
145
+ * Do not replace this object, instead, set new properties on it for custom search
146
+ * fields added by your plugin.
147
+ */
148
+ readonly searchFieldWeights: Record<string, number>;
149
+ /**
150
+ * Remove a search result by index.
151
+ */
152
+ removeResult(index: number): void;
153
+ constructor(name: string, searchResults: DeclarationReflection[]);
154
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MarkdownEvent = exports.PageEvent = exports.RendererEvent = void 0;
3
+ exports.IndexEvent = exports.MarkdownEvent = exports.PageEvent = exports.RendererEvent = void 0;
4
4
  const Path = require("path");
5
5
  const events_1 = require("../utils/events");
6
6
  /**
@@ -82,3 +82,40 @@ exports.MarkdownEvent = MarkdownEvent;
82
82
  * @event
83
83
  */
84
84
  MarkdownEvent.PARSE = "parseMarkdown";
85
+ /**
86
+ * An event emitted when the search index is being prepared.
87
+ */
88
+ class IndexEvent extends events_1.Event {
89
+ constructor(name, searchResults) {
90
+ super(name);
91
+ /**
92
+ * Weights for the fields defined in `searchFields`. The default will weight
93
+ * `name` as 10x more important than comment content.
94
+ *
95
+ * If a field added to {@link searchFields} is not added to this object, it
96
+ * will **not** be searchable.
97
+ *
98
+ * Do not replace this object, instead, set new properties on it for custom search
99
+ * fields added by your plugin.
100
+ */
101
+ this.searchFieldWeights = {
102
+ name: 10,
103
+ comment: 1,
104
+ };
105
+ this.searchResults = searchResults;
106
+ this.searchFields = Array.from({ length: this.searchResults.length }, () => ({}));
107
+ }
108
+ /**
109
+ * Remove a search result by index.
110
+ */
111
+ removeResult(index) {
112
+ this.searchResults.splice(index, 1);
113
+ this.searchFields.splice(index, 1);
114
+ }
115
+ }
116
+ exports.IndexEvent = IndexEvent;
117
+ /**
118
+ * Triggered on the renderer when the search index is being prepared.
119
+ * @event
120
+ */
121
+ IndexEvent.PREPARE_INDEX = "prepareIndex";
@@ -1,4 +1,4 @@
1
- export { PageEvent, RendererEvent, MarkdownEvent } from "./events";
1
+ export { PageEvent, RendererEvent, MarkdownEvent, IndexEvent } from "./events";
2
2
  export { UrlMapping } from "./models/UrlMapping";
3
3
  export type { RenderTemplate } from "./models/UrlMapping";
4
4
  export { Renderer } from "./renderer";
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Theme = exports.Renderer = exports.UrlMapping = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = void 0;
3
+ exports.DefaultThemeRenderContext = exports.DefaultTheme = exports.Theme = exports.Renderer = exports.UrlMapping = exports.IndexEvent = exports.MarkdownEvent = exports.RendererEvent = exports.PageEvent = void 0;
4
4
  var events_1 = require("./events");
5
5
  Object.defineProperty(exports, "PageEvent", { enumerable: true, get: function () { return events_1.PageEvent; } });
6
6
  Object.defineProperty(exports, "RendererEvent", { enumerable: true, get: function () { return events_1.RendererEvent; } });
7
7
  Object.defineProperty(exports, "MarkdownEvent", { enumerable: true, get: function () { return events_1.MarkdownEvent; } });
8
+ Object.defineProperty(exports, "IndexEvent", { enumerable: true, get: function () { return events_1.IndexEvent; } });
8
9
  var UrlMapping_1 = require("./models/UrlMapping");
9
10
  Object.defineProperty(exports, "UrlMapping", { enumerable: true, get: function () { return UrlMapping_1.UrlMapping; } });
10
11
  var renderer_1 = require("./renderer");
@@ -5,6 +5,7 @@ import { RendererComponent } from "../components";
5
5
  * The resulting javascript file can be used to build a simple search function.
6
6
  */
7
7
  export declare class JavascriptIndexPlugin extends RendererComponent {
8
+ searchComments: boolean;
8
9
  /**
9
10
  * Create a new JavascriptIndexPlugin instance.
10
11
  */
@@ -15,4 +16,5 @@ export declare class JavascriptIndexPlugin extends RendererComponent {
15
16
  * @param event An event object describing the current render operation.
16
17
  */
17
18
  private onRendererBegin;
19
+ private getCommentSearchText;
18
20
  }
@@ -41,20 +41,32 @@ let JavascriptIndexPlugin = class JavascriptIndexPlugin extends components_1.Ren
41
41
  }
42
42
  const rows = [];
43
43
  const kinds = {};
44
- for (const reflection of event.project.getReflectionsByKind(models_1.ReflectionKind.All)) {
45
- if (!(reflection instanceof models_1.DeclarationReflection)) {
46
- continue;
47
- }
48
- if (!reflection.url ||
49
- !reflection.name ||
50
- reflection.flags.isExternal) {
44
+ const initialSearchResults = Object.values(event.project.reflections).filter((refl) => {
45
+ return (refl instanceof models_1.DeclarationReflection &&
46
+ refl.url &&
47
+ refl.name &&
48
+ !refl.flags.isExternal);
49
+ });
50
+ const indexEvent = new events_1.IndexEvent(events_1.IndexEvent.PREPARE_INDEX, initialSearchResults);
51
+ this.owner.trigger(indexEvent);
52
+ if (indexEvent.isDefaultPrevented) {
53
+ return;
54
+ }
55
+ const builder = new lunr_1.Builder();
56
+ builder.pipeline.add(lunr_1.trimmer);
57
+ builder.ref("id");
58
+ for (const [key, boost] of Object.entries(indexEvent.searchFieldWeights)) {
59
+ builder.field(key, { boost });
60
+ }
61
+ for (const reflection of indexEvent.searchResults) {
62
+ if (!reflection.url) {
51
63
  continue;
52
64
  }
53
- let parent = reflection.parent;
54
65
  const boost = reflection.relevanceBoost ?? 1;
55
66
  if (boost <= 0) {
56
67
  continue;
57
68
  }
69
+ let parent = reflection.parent;
58
70
  if (parent instanceof models_1.ProjectReflection) {
59
71
  parent = undefined;
60
72
  }
@@ -62,26 +74,22 @@ let JavascriptIndexPlugin = class JavascriptIndexPlugin extends components_1.Ren
62
74
  kinds[reflection.kind] = plugins_1.GroupPlugin.getKindSingular(reflection.kind);
63
75
  }
64
76
  const row = {
65
- id: rows.length,
66
77
  kind: reflection.kind,
67
78
  name: reflection.name,
68
79
  url: reflection.url,
69
80
  classes: reflection.cssClasses,
70
81
  };
71
- if (boost !== 1) {
72
- row.boost = boost;
73
- }
74
82
  if (parent) {
75
83
  row.parent = parent.getFullName();
76
84
  }
85
+ builder.add({
86
+ name: reflection.name,
87
+ comment: this.getCommentSearchText(reflection),
88
+ ...indexEvent.searchFields[rows.length],
89
+ id: rows.length,
90
+ }, { boost });
77
91
  rows.push(row);
78
92
  }
79
- const builder = new lunr_1.Builder();
80
- builder.pipeline.add(lunr_1.trimmer);
81
- builder.ref("id");
82
- builder.field("name", { boost: 10 });
83
- builder.field("parent");
84
- rows.forEach((row) => builder.add(row));
85
93
  const index = builder.build();
86
94
  const jsonFileName = Path.join(event.outputDirectory, "assets", "search.js");
87
95
  const jsonData = JSON.stringify({
@@ -91,7 +99,31 @@ let JavascriptIndexPlugin = class JavascriptIndexPlugin extends components_1.Ren
91
99
  });
92
100
  (0, utils_1.writeFileSync)(jsonFileName, `window.searchData = JSON.parse(${JSON.stringify(jsonData)});`);
93
101
  }
102
+ getCommentSearchText(reflection) {
103
+ if (!this.searchComments)
104
+ return;
105
+ const comments = [];
106
+ if (reflection.comment)
107
+ comments.push(reflection.comment);
108
+ reflection.signatures?.forEach((s) => s.comment && comments.push(s.comment));
109
+ reflection.getSignature?.comment &&
110
+ comments.push(reflection.getSignature.comment);
111
+ reflection.setSignature?.comment &&
112
+ comments.push(reflection.setSignature.comment);
113
+ if (!comments.length) {
114
+ return;
115
+ }
116
+ return comments
117
+ .flatMap((c) => {
118
+ return [...c.summary, ...c.blockTags.flatMap((t) => t.content)];
119
+ })
120
+ .map((part) => part.text)
121
+ .join("\n");
122
+ }
94
123
  };
124
+ __decorate([
125
+ (0, utils_1.BindOption)("searchInComments")
126
+ ], JavascriptIndexPlugin.prototype, "searchComments", void 0);
95
127
  JavascriptIndexPlugin = __decorate([
96
128
  (0, components_1.Component)({ name: "javascript-index" })
97
129
  ], JavascriptIndexPlugin);
@@ -73,6 +73,10 @@ export interface RendererHooks {
73
73
  * * {@link Renderer.EVENT_END}<br>
74
74
  * Triggered after the renderer has written all documents. The listener receives
75
75
  * an instance of {@link RendererEvent}.
76
+ *
77
+ * * {@link Renderer.EVENT_PREPARE_INDEX}<br>
78
+ * Triggered when the JavascriptIndexPlugin is preparing the search index. Listeners receive
79
+ * an instance of {@link IndexEvent}.
76
80
  */
77
81
  export declare class Renderer extends ChildableComponent<Application, RendererComponent> {
78
82
  private themes;
@@ -85,6 +89,8 @@ export declare class Renderer extends ChildableComponent<Application, RendererCo
85
89
  static readonly EVENT_BEGIN = "beginRender";
86
90
  /** @event */
87
91
  static readonly EVENT_END = "endRender";
92
+ /** @event */
93
+ static readonly EVENT_PREPARE_INDEX = "prepareIndex";
88
94
  /**
89
95
  * The theme that is used to render the documentation.
90
96
  */
@@ -53,6 +53,10 @@ const icon_1 = require("./themes/default/partials/icon");
53
53
  * * {@link Renderer.EVENT_END}<br>
54
54
  * Triggered after the renderer has written all documents. The listener receives
55
55
  * an instance of {@link RendererEvent}.
56
+ *
57
+ * * {@link Renderer.EVENT_PREPARE_INDEX}<br>
58
+ * Triggered when the JavascriptIndexPlugin is preparing the search index. Listeners receive
59
+ * an instance of {@link IndexEvent}.
56
60
  */
57
61
  let Renderer = class Renderer extends component_1.ChildableComponent {
58
62
  constructor() {
@@ -257,6 +261,8 @@ Renderer.EVENT_END_PAGE = events_1.PageEvent.END;
257
261
  Renderer.EVENT_BEGIN = events_1.RendererEvent.BEGIN;
258
262
  /** @event */
259
263
  Renderer.EVENT_END = events_1.RendererEvent.END;
264
+ /** @event */
265
+ Renderer.EVENT_PREPARE_INDEX = events_1.IndexEvent.PREPARE_INDEX;
260
266
  __decorate([
261
267
  (0, utils_1.BindOption)("theme")
262
268
  ], Renderer.prototype, "themeName", void 0);
@@ -6,6 +6,7 @@ export declare class DefaultThemeRenderContext {
6
6
  private theme;
7
7
  options: Options;
8
8
  constructor(theme: DefaultTheme, options: Options);
9
+ icons: Record<"search" | "anchor" | import("../../../models").ReflectionKind | "checkbox" | "chevronDown" | "menu" | "chevronSmall", () => import("../../../utils/jsx.elements").JsxElement>;
9
10
  hook: (name: keyof RendererHooks) => import("../../../utils/jsx.elements").JsxElement[];
10
11
  /** Avoid this in favor of urlTo if possible */
11
12
  relativeURL: (url: string | undefined) => string | undefined;
@@ -38,6 +39,9 @@ export declare class DefaultThemeRenderContext {
38
39
  members: (props: import("../../../models").ContainerReflection) => import("../../../utils/jsx.elements").JsxElement;
39
40
  membersGroup: (group: import("../../../models").ReflectionGroup) => import("../../../utils/jsx.elements").JsxElement;
40
41
  navigation: (props: import("../..").PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement;
42
+ settings: () => import("../../../utils/jsx.elements").JsxElement;
43
+ primaryNavigation: (props: import("../..").PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement;
44
+ secondaryNavigation: (props: import("../..").PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement | undefined;
41
45
  parameter: (props: import("../../../models").DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement;
42
46
  toolbar: (props: import("../..").PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement;
43
47
  type: (type: import("../../../models").Type | undefined) => import("../../../utils/jsx.elements").JsxElement;
@@ -9,6 +9,7 @@ const comment_1 = require("./partials/comment");
9
9
  const footer_1 = require("./partials/footer");
10
10
  const header_1 = require("./partials/header");
11
11
  const hierarchy_1 = require("./partials/hierarchy");
12
+ const icon_1 = require("./partials/icon");
12
13
  const member_1 = require("./partials/member");
13
14
  const member_declaration_1 = require("./partials/member.declaration");
14
15
  const member_getterSetter_1 = require("./partials/member.getterSetter");
@@ -33,6 +34,7 @@ function bind(fn, first) {
33
34
  class DefaultThemeRenderContext {
34
35
  constructor(theme, options) {
35
36
  this.theme = theme;
37
+ this.icons = icon_1.icons;
36
38
  this.hook = (name) => this.theme.owner.hooks.emit(name, this);
37
39
  /** Avoid this in favor of urlTo if possible */
38
40
  this.relativeURL = (url) => {
@@ -66,6 +68,9 @@ class DefaultThemeRenderContext {
66
68
  this.members = bind(members_1.members, this);
67
69
  this.membersGroup = bind(members_group_1.membersGroup, this);
68
70
  this.navigation = bind(navigation_1.navigation, this);
71
+ this.settings = bind(navigation_1.settings, this);
72
+ this.primaryNavigation = bind(navigation_1.primaryNavigation, this);
73
+ this.secondaryNavigation = bind(navigation_1.secondaryNavigation, this);
69
74
  this.parameter = bind(parameter_1.parameter, this);
70
75
  this.toolbar = bind(toolbar_1.toolbar, this);
71
76
  this.type = bind(type_1.type, this);
@@ -1,2 +1,3 @@
1
1
  import { JSX } from "../../../../utils";
2
- export declare const anchorIcon: (anchor: string | undefined) => JSX.Element;
2
+ import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
3
+ export declare const anchorIcon: (context: DefaultThemeRenderContext, anchor: string | undefined) => JSX.Element;
@@ -2,6 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.anchorIcon = void 0;
4
4
  const utils_1 = require("../../../../utils");
5
- const icon_1 = require("./icon");
6
- const anchorIcon = (anchor) => (utils_1.JSX.createElement("a", { href: `#${anchor}`, "aria-label": "Permalink", class: "tsd-anchor-icon" }, icon_1.icons.anchor()));
5
+ const anchorIcon = (context, anchor) => (utils_1.JSX.createElement("a", { href: `#${anchor}`, "aria-label": "Permalink", class: "tsd-anchor-icon" }, context.icons.anchor()));
7
6
  exports.anchorIcon = anchorIcon;
@@ -1,5 +1,5 @@
1
1
  import { JSX } from "../../../../utils";
2
2
  import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
3
3
  import type { PageEvent } from "../../../events";
4
- import type { Reflection } from "../../../../models";
4
+ import { Reflection } from "../../../../models";
5
5
  export declare const header: (context: DefaultThemeRenderContext, props: PageEvent<Reflection>) => JSX.Element;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.header = void 0;
4
4
  const lib_1 = require("../../lib");
5
5
  const utils_1 = require("../../../../utils");
6
+ const models_1 = require("../../../../models");
6
7
  const header = (context, props) => {
7
8
  const HeadingLevel = props.model.isProject() ? "h2" : "h1";
8
9
  return (utils_1.JSX.createElement("div", { class: "tsd-page-title" },
@@ -10,6 +11,9 @@ const header = (context, props) => {
10
11
  utils_1.JSX.createElement(HeadingLevel, null,
11
12
  props.model.kindString !== "Project" && `${props.model.kindString ?? ""} `,
12
13
  props.model.name,
14
+ props.model instanceof models_1.DeclarationReflection &&
15
+ props.model.version !== undefined &&
16
+ ` - v${props.model.version}`,
13
17
  (0, lib_1.hasTypeParameters)(props.model) && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
14
18
  "<",
15
19
  (0, lib_1.join)(", ", props.model.typeParameters, (item) => item.name),
@@ -1,6 +1,4 @@
1
1
  import { ReflectionKind } from "../../../../models";
2
2
  import { JSX } from "../../../../utils";
3
- declare type UtilityIcons = Record<"chevronDown" | "checkbox" | "menu" | "search" | "chevronSmall" | "anchor", () => JSX.Element>;
4
3
  export declare function clearSeenIconCache(): void;
5
- export declare const icons: Record<ReflectionKind, () => JSX.Element> & UtilityIcons;
6
- export {};
4
+ export declare const icons: Record<ReflectionKind | "chevronDown" | "checkbox" | "menu" | "search" | "chevronSmall" | "anchor", () => JSX.Element>;
@@ -1,4 +1,4 @@
1
1
  import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
2
2
  import { JSX } from "../../../../utils";
3
- import type { ContainerReflection } from "../../../../models";
3
+ import { ContainerReflection } from "../../../../models";
4
4
  export declare function index(context: DefaultThemeRenderContext, props: ContainerReflection): JSX.Element;
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.index = void 0;
4
4
  const lib_1 = require("../../lib");
5
5
  const utils_1 = require("../../../../utils");
6
- const icon_1 = require("./icon");
7
- function renderCategory({ urlTo }, item, prependName = "") {
6
+ const models_1 = require("../../../../models");
7
+ function renderCategory({ urlTo, icons }, item, prependName = "") {
8
8
  return (utils_1.JSX.createElement("section", { class: "tsd-index-section" },
9
9
  utils_1.JSX.createElement("h3", { class: "tsd-index-heading" }, prependName ? `${prependName} - ${item.title}` : item.title),
10
10
  utils_1.JSX.createElement("div", { class: "tsd-index-list" }, item.children.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
11
11
  utils_1.JSX.createElement("a", { href: urlTo(item), class: (0, lib_1.classNames)({ "tsd-index-link": true, deprecated: item.isDeprecated() }, item.cssClasses) },
12
- icon_1.icons[item.kind](),
12
+ icons[item.kind](),
13
13
  utils_1.JSX.createElement("span", null, item.name ? (0, lib_1.wbr)(item.name) : utils_1.JSX.createElement("em", null, (0, lib_1.wbr)(item.kindString)))),
14
14
  "\n"))))));
15
15
  }
@@ -28,7 +28,7 @@ function index(context, props) {
28
28
  content = (utils_1.JSX.createElement("details", { class: "tsd-index-content tsd-index-accordion", open: true },
29
29
  utils_1.JSX.createElement("summary", { class: "tsd-accordion-summary tsd-index-summary" },
30
30
  utils_1.JSX.createElement("h5", { class: "tsd-index-heading uppercase", role: "button", "aria-expanded": "false", tabIndex: 0 },
31
- icon_1.icons.chevronSmall(),
31
+ context.icons.chevronSmall(),
32
32
  " Index")),
33
33
  utils_1.JSX.createElement("div", { class: "tsd-accordion-details" }, content)));
34
34
  }
@@ -37,7 +37,13 @@ function index(context, props) {
37
37
  utils_1.JSX.createElement("h3", { class: "tsd-index-heading uppercase" }, "Index"),
38
38
  content));
39
39
  }
40
- return (utils_1.JSX.createElement("section", { class: "tsd-panel-group tsd-index-group" },
41
- utils_1.JSX.createElement("section", { class: "tsd-panel tsd-index-panel" }, content)));
40
+ return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
41
+ props instanceof models_1.DeclarationReflection &&
42
+ props.kind === models_1.ReflectionKind.Module &&
43
+ props.readme?.length !== 0 && (utils_1.JSX.createElement("section", { class: "tsd-panel-group" },
44
+ utils_1.JSX.createElement("section", { class: "tsd-panel tsd-typography" },
45
+ utils_1.JSX.createElement(utils_1.Raw, { html: context.markdown((0, lib_1.displayPartsToMarkdown)(props.readme || [], context.urlTo)) })))),
46
+ utils_1.JSX.createElement("section", { class: "tsd-panel-group tsd-index-group" },
47
+ utils_1.JSX.createElement("section", { class: "tsd-panel tsd-index-panel" }, content))));
42
48
  }
43
49
  exports.index = index;
@@ -10,7 +10,7 @@ const member = (context, props) => (utils_1.JSX.createElement("section", { class
10
10
  !!props.name && (utils_1.JSX.createElement("h3", { class: "tsd-anchor-link" },
11
11
  (0, lib_1.renderFlags)(props.flags, props.comment),
12
12
  utils_1.JSX.createElement("span", { class: (0, lib_1.classNames)({ deprecated: props.isDeprecated() }) }, (0, lib_1.wbr)(props.name)),
13
- (0, anchor_icon_1.anchorIcon)(props.anchor))),
13
+ (0, anchor_icon_1.anchorIcon)(context, props.anchor))),
14
14
  props.signatures
15
15
  ? context.memberSignatures(props)
16
16
  : props.hasGetterOrSetter()
@@ -3,3 +3,6 @@ import { JSX } from "../../../../utils";
3
3
  import type { PageEvent } from "../../../events";
4
4
  import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
5
5
  export declare function navigation(context: DefaultThemeRenderContext, props: PageEvent<Reflection>): JSX.Element;
6
+ export declare function settings(context: DefaultThemeRenderContext): JSX.Element;
7
+ export declare function primaryNavigation(context: DefaultThemeRenderContext, props: PageEvent<Reflection>): JSX.Element;
8
+ export declare function secondaryNavigation(context: DefaultThemeRenderContext, props: PageEvent<Reflection>): JSX.Element | undefined;