typedoc 0.28.0-beta.1 → 0.28.0-beta.2

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 (61) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/lib/converter/context.d.ts +16 -6
  3. package/dist/lib/converter/context.js +39 -3
  4. package/dist/lib/converter/factories/signature.js +1 -1
  5. package/dist/lib/converter/factories/symbol-id.js +1 -0
  6. package/dist/lib/converter/plugins/MergeModuleWithPlugin.js +1 -1
  7. package/dist/lib/converter/plugins/SourcePlugin.js +1 -1
  8. package/dist/lib/converter/symbols.js +14 -4
  9. package/dist/lib/converter/types.js +16 -21
  10. package/dist/lib/models/ContainerReflection.d.ts +2 -2
  11. package/dist/lib/models/ContainerReflection.js +28 -4
  12. package/dist/lib/models/ProjectReflection.d.ts +1 -1
  13. package/dist/lib/models/ProjectReflection.js +1 -1
  14. package/dist/lib/models/ReflectionSymbolId.d.ts +10 -0
  15. package/dist/lib/models/ReflectionSymbolId.js +10 -0
  16. package/dist/lib/output/formatter.d.ts +1 -0
  17. package/dist/lib/output/formatter.js +3 -0
  18. package/dist/lib/output/plugins/JavascriptIndexPlugin.js +4 -0
  19. package/dist/lib/output/renderer.d.ts +0 -5
  20. package/dist/lib/output/renderer.js +3 -40
  21. package/dist/lib/output/theme.d.ts +9 -1
  22. package/dist/lib/output/theme.js +8 -0
  23. package/dist/lib/output/themes/MarkedPlugin.js +2 -2
  24. package/dist/lib/output/themes/default/DefaultTheme.d.ts +11 -5
  25. package/dist/lib/output/themes/default/DefaultTheme.js +275 -208
  26. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +47 -40
  27. package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +9 -0
  28. package/dist/lib/output/themes/default/partials/anchor-icon.d.ts +1 -2
  29. package/dist/lib/output/themes/default/partials/anchor-icon.js +2 -9
  30. package/dist/lib/output/themes/default/partials/breadcrumb.js +2 -2
  31. package/dist/lib/output/themes/default/partials/comment.js +2 -3
  32. package/dist/lib/output/themes/default/partials/index.js +4 -6
  33. package/dist/lib/output/themes/default/partials/member.declaration.js +1 -1
  34. package/dist/lib/output/themes/default/partials/member.js +3 -5
  35. package/dist/lib/output/themes/default/partials/member.signature.body.js +2 -2
  36. package/dist/lib/output/themes/default/partials/member.signatures.js +2 -3
  37. package/dist/lib/output/themes/default/partials/members.js +2 -4
  38. package/dist/lib/output/themes/default/partials/moduleReflection.js +6 -10
  39. package/dist/lib/output/themes/default/partials/navigation.js +5 -7
  40. package/dist/lib/output/themes/default/partials/reflectionPreview.js +8 -0
  41. package/dist/lib/output/themes/default/partials/typeDetails.d.ts +5 -5
  42. package/dist/lib/output/themes/default/partials/typeDetails.js +99 -53
  43. package/dist/lib/output/themes/default/partials/typeParameters.js +2 -3
  44. package/dist/lib/output/themes/default/templates/hierarchy.js +3 -5
  45. package/dist/lib/output/themes/default/templates/reflection.js +7 -3
  46. package/dist/lib/output/themes/lib.js +8 -4
  47. package/dist/lib/utils/highlighter.d.ts +1 -0
  48. package/dist/lib/utils/highlighter.js +16 -2
  49. package/dist/lib/utils/index.d.ts +1 -0
  50. package/dist/lib/utils/index.js +1 -0
  51. package/dist/lib/utils/options/defaults.js +2 -0
  52. package/dist/lib/utils/options/tsdoc-defaults.d.ts +1 -1
  53. package/dist/lib/utils/options/tsdoc-defaults.js +4 -0
  54. package/dist/lib/utils-common/jsx.elements.d.ts +16 -0
  55. package/dist/lib/utils-common/path.js +4 -1
  56. package/package.json +1 -1
  57. package/static/main.js +4 -4
  58. package/static/style.css +24 -17
  59. package/tsdoc.json +16 -0
  60. package/dist/lib/converter/factories/types.d.ts +0 -4
  61. package/dist/lib/converter/factories/types.js +0 -13
@@ -227,7 +227,7 @@ let MarkedPlugin = (() => {
227
227
  url = context.relativeURL(`media/${fileName}`);
228
228
  }
229
229
  }
230
- if (url) {
230
+ if (typeof url !== "undefined") {
231
231
  if (part.targetAnchor) {
232
232
  url += "#" + part.targetAnchor;
233
233
  if (typeof refl === "object") {
@@ -311,7 +311,7 @@ let MarkedPlugin = (() => {
311
311
  text: content,
312
312
  level,
313
313
  });
314
- return `<a id="${slug}" class="tsd-anchor"></a><${token.tag} class="tsd-anchor-link">`;
314
+ return `<${token.tag} id="${slug}" class="tsd-anchor-link">`;
315
315
  };
316
316
  this.parser.renderer.rules["heading_close"] = (tokens, idx) => {
317
317
  return `${JSX.renderElement(anchorIcon(this.renderContext, this.lastHeaderSlug))}</${tokens[idx].tag}>`;
@@ -1,7 +1,7 @@
1
1
  import { Theme } from "../../theme.js";
2
2
  import type { Renderer } from "../../renderer.js";
3
3
  import { type ContainerReflection, type DocumentReflection, type ProjectReflection, type Reflection, ReflectionKind } from "../../../models/index.js";
4
- import type { PageEvent } from "../../events.js";
4
+ import type { PageEvent, RendererEvent } from "../../events.js";
5
5
  import type { MarkedPlugin } from "../../plugins/index.js";
6
6
  import { DefaultThemeRenderContext } from "./DefaultThemeRenderContext.js";
7
7
  import { type Icons } from "./partials/icon.js";
@@ -13,6 +13,7 @@ export interface NavigationElement {
13
13
  kind?: ReflectionKind;
14
14
  class?: string;
15
15
  children?: NavigationElement[];
16
+ icon?: string | number;
16
17
  }
17
18
  /**
18
19
  * @param data the reflection to render
@@ -39,6 +40,10 @@ export declare class DefaultTheme extends Theme {
39
40
  */
40
41
  icons: Icons;
41
42
  ContextClass: typeof DefaultThemeRenderContext;
43
+ private accessor lightTheme;
44
+ private accessor darkTheme;
45
+ private accessor highlightLanguages;
46
+ private accessor ignoredHighlightLanguages;
42
47
  getRenderContext(pageEvent: PageEvent<Reflection>): DefaultThemeRenderContext;
43
48
  documentTemplate: (pageEvent: PageEvent<DocumentReflection>) => JSX.Element;
44
49
  reflectionTemplate: (pageEvent: PageEvent<ContainerReflection>) => JSX.Element;
@@ -46,17 +51,18 @@ export declare class DefaultTheme extends Theme {
46
51
  hierarchyTemplate: (pageEvent: PageEvent<ProjectReflection>) => JSX.Element;
47
52
  defaultLayoutTemplate: (pageEvent: PageEvent<Reflection>, template: RenderTemplate<PageEvent<Reflection>>) => JSX.Element;
48
53
  getReflectionClasses(reflection: Reflection): string;
54
+ /**
55
+ * This is used so that themes may define multiple icons for modified icons (e.g. method, and inherited method)
56
+ */
57
+ getReflectionIcon(reflection: Reflection): keyof this["icons"] & (string | number);
49
58
  /**
50
59
  * Create a new DefaultTheme instance.
51
60
  *
52
61
  * @param renderer The renderer this theme is attached to.
53
62
  */
54
63
  constructor(renderer: Renderer);
55
- /**
56
- * @param reflection The reflection the url should be generated for.
57
- */
58
- getFileName(reflection: Reflection): string;
59
64
  render(page: PageEvent<Reflection>): string;
65
+ preRender(_event: RendererEvent): Promise<void>;
60
66
  private _navigationCache;
61
67
  /**
62
68
  * If implementing a custom theme, it is recommended to override {@link buildNavigation} instead.
@@ -1,3 +1,37 @@
1
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
2
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
3
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
4
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
5
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
6
+ var _, done = false;
7
+ for (var i = decorators.length - 1; i >= 0; i--) {
8
+ var context = {};
9
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
10
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
11
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
12
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
13
+ if (kind === "accessor") {
14
+ if (result === void 0) continue;
15
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
16
+ if (_ = accept(result.get)) descriptor.get = _;
17
+ if (_ = accept(result.set)) descriptor.set = _;
18
+ if (_ = accept(result.init)) initializers.unshift(_);
19
+ }
20
+ else if (_ = accept(result)) {
21
+ if (kind === "field") initializers.unshift(_);
22
+ else descriptor[key] = _;
23
+ }
24
+ }
25
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
26
+ done = true;
27
+ };
28
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
29
+ var useValue = arguments.length > 2;
30
+ for (var i = 0; i < initializers.length; i++) {
31
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
32
+ }
33
+ return useValue ? value : void 0;
34
+ };
1
35
  import { Theme } from "../../theme.js";
2
36
  import { ReferenceReflection, ReflectionCategory, ReflectionGroup, ReflectionKind, } from "../../../models/index.js";
3
37
  import { DefaultThemeRenderContext } from "./DefaultThemeRenderContext.js";
@@ -5,233 +39,266 @@ import { getIcons } from "./partials/icon.js";
5
39
  import { filterMap, JSX } from "#utils";
6
40
  import { classNames, getDisplayName, toStyleClass } from "../lib.js";
7
41
  import { PageKind } from "../../router.js";
8
- import { createNormalizedUrl } from "#node-utils";
9
- export class DefaultTheme extends Theme {
10
- // Note: This will always contain lowercased names to avoid issues with
11
- // case-insensitive file systems.
12
- usedFileNames = new Set();
13
- /** @internal */
14
- markedPlugin;
15
- router;
16
- /**
17
- * The icons which will actually be rendered. The source of truth lives on the theme, and
18
- * the {@link DefaultThemeRenderContext.icons} member will produce references to these.
19
- *
20
- * These icons will be written twice. Once to an `icons.svg` file in the assets directory
21
- * which will be referenced by icons on the context, and once to an `icons.js` file so that
22
- * references to the icons can be dynamically embedded within the page for use by the search
23
- * dropdown and when loading the page on `file://` urls.
24
- *
25
- * Custom themes may overwrite this entire object or individual properties on it to customize
26
- * the icons used within the page, however TypeDoc currently assumes that all icons are svg
27
- * elements, so custom themes must also use svg elements.
28
- */
29
- icons;
30
- ContextClass = DefaultThemeRenderContext;
31
- getRenderContext(pageEvent) {
32
- return new this.ContextClass(this.router, this, pageEvent, this.application.options);
33
- }
34
- documentTemplate = (pageEvent) => {
35
- return this.getRenderContext(pageEvent).documentTemplate(pageEvent);
36
- };
37
- reflectionTemplate = (pageEvent) => {
38
- return this.getRenderContext(pageEvent).reflectionTemplate(pageEvent);
39
- };
40
- indexTemplate = (pageEvent) => {
41
- return this.getRenderContext(pageEvent).indexTemplate(pageEvent);
42
- };
43
- hierarchyTemplate = (pageEvent) => {
44
- return this.getRenderContext(pageEvent).hierarchyTemplate(pageEvent);
45
- };
46
- defaultLayoutTemplate = (pageEvent, template) => {
47
- return this.getRenderContext(pageEvent).defaultLayout(template, pageEvent);
48
- };
49
- getReflectionClasses(reflection) {
50
- const filters = this.application.options.getValue("visibilityFilters");
51
- return getReflectionClasses(reflection, filters);
52
- }
53
- /**
54
- * Create a new DefaultTheme instance.
55
- *
56
- * @param renderer The renderer this theme is attached to.
57
- */
58
- constructor(renderer) {
59
- super(renderer);
60
- this.icons = getIcons();
61
- this.markedPlugin = renderer.markedPlugin;
62
- this.router = renderer.router;
63
- }
64
- /**
65
- * @param reflection The reflection the url should be generated for.
66
- */
67
- getFileName(reflection) {
68
- const parts = [createNormalizedUrl(reflection.name)];
69
- while (reflection.parent && !reflection.parent.isProject()) {
70
- reflection = reflection.parent;
71
- parts.unshift(createNormalizedUrl(reflection.name));
42
+ import { loadHighlighter, Option } from "#node-utils";
43
+ let DefaultTheme = (() => {
44
+ let _classSuper = Theme;
45
+ let _lightTheme_decorators;
46
+ let _lightTheme_initializers = [];
47
+ let _lightTheme_extraInitializers = [];
48
+ let _darkTheme_decorators;
49
+ let _darkTheme_initializers = [];
50
+ let _darkTheme_extraInitializers = [];
51
+ let _highlightLanguages_decorators;
52
+ let _highlightLanguages_initializers = [];
53
+ let _highlightLanguages_extraInitializers = [];
54
+ let _ignoredHighlightLanguages_decorators;
55
+ let _ignoredHighlightLanguages_initializers = [];
56
+ let _ignoredHighlightLanguages_extraInitializers = [];
57
+ return class DefaultTheme extends _classSuper {
58
+ static {
59
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
60
+ _lightTheme_decorators = [Option("lightHighlightTheme")];
61
+ _darkTheme_decorators = [Option("darkHighlightTheme")];
62
+ _highlightLanguages_decorators = [Option("highlightLanguages")];
63
+ _ignoredHighlightLanguages_decorators = [Option("ignoredHighlightLanguages")];
64
+ __esDecorate(this, null, _lightTheme_decorators, { kind: "accessor", name: "lightTheme", static: false, private: false, access: { has: obj => "lightTheme" in obj, get: obj => obj.lightTheme, set: (obj, value) => { obj.lightTheme = value; } }, metadata: _metadata }, _lightTheme_initializers, _lightTheme_extraInitializers);
65
+ __esDecorate(this, null, _darkTheme_decorators, { kind: "accessor", name: "darkTheme", static: false, private: false, access: { has: obj => "darkTheme" in obj, get: obj => obj.darkTheme, set: (obj, value) => { obj.darkTheme = value; } }, metadata: _metadata }, _darkTheme_initializers, _darkTheme_extraInitializers);
66
+ __esDecorate(this, null, _highlightLanguages_decorators, { kind: "accessor", name: "highlightLanguages", static: false, private: false, access: { has: obj => "highlightLanguages" in obj, get: obj => obj.highlightLanguages, set: (obj, value) => { obj.highlightLanguages = value; } }, metadata: _metadata }, _highlightLanguages_initializers, _highlightLanguages_extraInitializers);
67
+ __esDecorate(this, null, _ignoredHighlightLanguages_decorators, { kind: "accessor", name: "ignoredHighlightLanguages", static: false, private: false, access: { has: obj => "ignoredHighlightLanguages" in obj, get: obj => obj.ignoredHighlightLanguages, set: (obj, value) => { obj.ignoredHighlightLanguages = value; } }, metadata: _metadata }, _ignoredHighlightLanguages_initializers, _ignoredHighlightLanguages_extraInitializers);
68
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
72
69
  }
73
- const baseName = parts.join(".");
74
- const lowerBaseName = baseName.toLocaleLowerCase();
75
- if (this.usedFileNames.has(lowerBaseName)) {
76
- let index = 1;
77
- while (this.usedFileNames.has(`${lowerBaseName}-${index}`)) {
78
- ++index;
79
- }
80
- this.usedFileNames.add(`${lowerBaseName}-${index}`);
81
- return `${baseName}-${index}.html`;
70
+ // Note: This will always contain lowercased names to avoid issues with
71
+ // case-insensitive file systems.
72
+ usedFileNames = new Set();
73
+ /** @internal */
74
+ markedPlugin;
75
+ router;
76
+ /**
77
+ * The icons which will actually be rendered. The source of truth lives on the theme, and
78
+ * the {@link DefaultThemeRenderContext.icons} member will produce references to these.
79
+ *
80
+ * These icons will be written twice. Once to an `icons.svg` file in the assets directory
81
+ * which will be referenced by icons on the context, and once to an `icons.js` file so that
82
+ * references to the icons can be dynamically embedded within the page for use by the search
83
+ * dropdown and when loading the page on `file://` urls.
84
+ *
85
+ * Custom themes may overwrite this entire object or individual properties on it to customize
86
+ * the icons used within the page, however TypeDoc currently assumes that all icons are svg
87
+ * elements, so custom themes must also use svg elements.
88
+ */
89
+ icons;
90
+ ContextClass = DefaultThemeRenderContext;
91
+ #lightTheme_accessor_storage = __runInitializers(this, _lightTheme_initializers, void 0);
92
+ get lightTheme() { return this.#lightTheme_accessor_storage; }
93
+ set lightTheme(value) { this.#lightTheme_accessor_storage = value; }
94
+ #darkTheme_accessor_storage = (__runInitializers(this, _lightTheme_extraInitializers), __runInitializers(this, _darkTheme_initializers, void 0));
95
+ get darkTheme() { return this.#darkTheme_accessor_storage; }
96
+ set darkTheme(value) { this.#darkTheme_accessor_storage = value; }
97
+ #highlightLanguages_accessor_storage = (__runInitializers(this, _darkTheme_extraInitializers), __runInitializers(this, _highlightLanguages_initializers, void 0));
98
+ get highlightLanguages() { return this.#highlightLanguages_accessor_storage; }
99
+ set highlightLanguages(value) { this.#highlightLanguages_accessor_storage = value; }
100
+ #ignoredHighlightLanguages_accessor_storage = (__runInitializers(this, _highlightLanguages_extraInitializers), __runInitializers(this, _ignoredHighlightLanguages_initializers, void 0));
101
+ get ignoredHighlightLanguages() { return this.#ignoredHighlightLanguages_accessor_storage; }
102
+ set ignoredHighlightLanguages(value) { this.#ignoredHighlightLanguages_accessor_storage = value; }
103
+ getRenderContext(pageEvent) {
104
+ return new this.ContextClass(this.router, this, pageEvent, this.application.options);
82
105
  }
83
- this.usedFileNames.add(lowerBaseName);
84
- return `${baseName}.html`;
85
- }
86
- render(page) {
87
- const template = {
88
- [PageKind.Index]: this.indexTemplate,
89
- [PageKind.Document]: this.documentTemplate,
90
- [PageKind.Hierarchy]: this.hierarchyTemplate,
91
- [PageKind.Reflection]: this.reflectionTemplate,
92
- }[page.pageKind];
93
- const templateOutput = this.defaultLayoutTemplate(page, template);
94
- return "<!DOCTYPE html>" + JSX.renderElement(templateOutput) + "\n";
95
- }
96
- _navigationCache;
97
- /**
98
- * If implementing a custom theme, it is recommended to override {@link buildNavigation} instead.
99
- */
100
- getNavigation(project) {
101
- // This is ok because currently TypeDoc wipes out the theme after each render.
102
- // Might need to change in the future, but it's fine for now.
103
- if (this._navigationCache) {
104
- return this._navigationCache;
106
+ documentTemplate = (__runInitializers(this, _ignoredHighlightLanguages_extraInitializers), (pageEvent) => {
107
+ return this.getRenderContext(pageEvent).documentTemplate(pageEvent);
108
+ });
109
+ reflectionTemplate = (pageEvent) => {
110
+ return this.getRenderContext(pageEvent).reflectionTemplate(pageEvent);
111
+ };
112
+ indexTemplate = (pageEvent) => {
113
+ return this.getRenderContext(pageEvent).indexTemplate(pageEvent);
114
+ };
115
+ hierarchyTemplate = (pageEvent) => {
116
+ return this.getRenderContext(pageEvent).hierarchyTemplate(pageEvent);
117
+ };
118
+ defaultLayoutTemplate = (pageEvent, template) => {
119
+ return this.getRenderContext(pageEvent).defaultLayout(template, pageEvent);
120
+ };
121
+ getReflectionClasses(reflection) {
122
+ const filters = this.application.options.getValue("visibilityFilters");
123
+ return getReflectionClasses(reflection, filters);
105
124
  }
106
- return (this._navigationCache = this.buildNavigation(project));
107
- }
108
- buildNavigation(project) {
109
- // eslint-disable-next-line @typescript-eslint/no-this-alias
110
- const theme = this;
111
- const router = this.router;
112
- const opts = this.application.options.getValue("navigation");
113
- const leaves = this.application.options.getValue("navigationLeaves");
114
- return getNavigationElements(project) || [];
115
- function toNavigation(element) {
116
- if (opts.excludeReferences && element instanceof ReferenceReflection) {
117
- return;
125
+ /**
126
+ * This is used so that themes may define multiple icons for modified icons (e.g. method, and inherited method)
127
+ */
128
+ getReflectionIcon(reflection) {
129
+ return reflection.kind;
130
+ }
131
+ /**
132
+ * Create a new DefaultTheme instance.
133
+ *
134
+ * @param renderer The renderer this theme is attached to.
135
+ */
136
+ constructor(renderer) {
137
+ super(renderer);
138
+ this.icons = getIcons();
139
+ this.markedPlugin = renderer.markedPlugin;
140
+ this.router = renderer.router;
141
+ }
142
+ render(page) {
143
+ const template = {
144
+ [PageKind.Index]: this.indexTemplate,
145
+ [PageKind.Document]: this.documentTemplate,
146
+ [PageKind.Hierarchy]: this.hierarchyTemplate,
147
+ [PageKind.Reflection]: this.reflectionTemplate,
148
+ }[page.pageKind];
149
+ const templateOutput = this.defaultLayoutTemplate(page, template);
150
+ return "<!DOCTYPE html>" + JSX.renderElement(templateOutput) + "\n";
151
+ }
152
+ async preRender(_event) {
153
+ await loadHighlighter(this.lightTheme, this.darkTheme,
154
+ // Checked in option validation
155
+ this.highlightLanguages, this.ignoredHighlightLanguages);
156
+ }
157
+ _navigationCache;
158
+ /**
159
+ * If implementing a custom theme, it is recommended to override {@link buildNavigation} instead.
160
+ */
161
+ getNavigation(project) {
162
+ // This is ok because currently TypeDoc wipes out the theme after each render.
163
+ // Might need to change in the future, but it's fine for now.
164
+ if (this._navigationCache) {
165
+ return this._navigationCache;
118
166
  }
119
- const children = getNavigationElements(element);
120
- if (element instanceof ReflectionCategory || element instanceof ReflectionGroup) {
121
- if (!children?.length) {
167
+ return (this._navigationCache = this.buildNavigation(project));
168
+ }
169
+ buildNavigation(project) {
170
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
171
+ const theme = this;
172
+ const router = this.router;
173
+ const opts = this.application.options.getValue("navigation");
174
+ const leaves = this.application.options.getValue("navigationLeaves");
175
+ return getNavigationElements(project) || [];
176
+ function toNavigation(element) {
177
+ if (opts.excludeReferences && element instanceof ReferenceReflection) {
122
178
  return;
123
179
  }
180
+ const children = getNavigationElements(element);
181
+ if (element instanceof ReflectionCategory || element instanceof ReflectionGroup) {
182
+ if (!children?.length) {
183
+ return;
184
+ }
185
+ return {
186
+ text: element.title,
187
+ children,
188
+ };
189
+ }
190
+ const icon = theme.getReflectionIcon(element) === element.kind
191
+ ? undefined
192
+ : theme.getReflectionIcon(element);
124
193
  return {
125
- text: element.title,
126
- children,
194
+ text: getDisplayName(element),
195
+ path: router.getFullUrl(element),
196
+ kind: element.kind & ReflectionKind.Project ? undefined : element.kind,
197
+ class: classNames({ deprecated: element.isDeprecated() }, theme.getReflectionClasses(element)),
198
+ children: children?.length ? children : undefined,
199
+ icon,
127
200
  };
128
201
  }
129
- return {
130
- text: getDisplayName(element),
131
- path: router.getFullUrl(element),
132
- kind: element.kind & ReflectionKind.Project ? undefined : element.kind,
133
- class: classNames({ deprecated: element.isDeprecated() }, theme.getReflectionClasses(element)),
134
- children: children?.length ? children : undefined,
135
- };
136
- }
137
- function getNavigationElements(parent) {
138
- if (parent instanceof ReflectionCategory) {
139
- return filterMap(parent.children, toNavigation);
140
- }
141
- if (parent instanceof ReflectionGroup) {
142
- if (shouldShowCategories(parent.owningReflection, opts) && parent.categories) {
143
- return filterMap(parent.categories, toNavigation);
202
+ function getNavigationElements(parent) {
203
+ if (parent instanceof ReflectionCategory) {
204
+ return filterMap(parent.children, toNavigation);
144
205
  }
145
- return filterMap(parent.children, toNavigation);
146
- }
147
- if (leaves.includes(parent.getFullName())) {
148
- return;
149
- }
150
- if (!parent.kindOf(ReflectionKind.MayContainDocuments)) {
151
- return;
152
- }
153
- if (parent.isDocument()) {
154
- return filterMap(parent.children, toNavigation);
155
- }
156
- if (!parent.kindOf(ReflectionKind.SomeModule | ReflectionKind.Project)) {
157
- // Tricky: Non-module children don't show up in the navigation pane,
158
- // but any documents added by them should.
159
- return filterMap(parent.documents, toNavigation);
160
- }
161
- if (parent.categories && shouldShowCategories(parent, opts)) {
162
- return filterMapWithNoneCollection(parent.categories);
163
- }
164
- if (parent.groups && shouldShowGroups(parent, opts)) {
165
- return filterMapWithNoneCollection(parent.groups);
166
- }
167
- if (opts.includeFolders && parent.childrenIncludingDocuments?.some((child) => child.name.includes("/"))) {
168
- return deriveModuleFolders(parent.childrenIncludingDocuments);
206
+ if (parent instanceof ReflectionGroup) {
207
+ if (shouldShowCategories(parent.owningReflection, opts) && parent.categories) {
208
+ return filterMap(parent.categories, toNavigation);
209
+ }
210
+ return filterMap(parent.children, toNavigation);
211
+ }
212
+ if (leaves.includes(parent.getFullName())) {
213
+ return;
214
+ }
215
+ if (!parent.kindOf(ReflectionKind.MayContainDocuments)) {
216
+ return;
217
+ }
218
+ if (parent.isDocument()) {
219
+ return filterMap(parent.children, toNavigation);
220
+ }
221
+ if (!parent.kindOf(ReflectionKind.SomeModule | ReflectionKind.Project)) {
222
+ // Tricky: Non-module children don't show up in the navigation pane,
223
+ // but any documents added by them should.
224
+ return filterMap(parent.documents, toNavigation);
225
+ }
226
+ if (parent.categories && shouldShowCategories(parent, opts)) {
227
+ return filterMapWithNoneCollection(parent.categories);
228
+ }
229
+ if (parent.groups && shouldShowGroups(parent, opts)) {
230
+ return filterMapWithNoneCollection(parent.groups);
231
+ }
232
+ if (opts.includeFolders && parent.childrenIncludingDocuments?.some((child) => child.name.includes("/"))) {
233
+ return deriveModuleFolders(parent.childrenIncludingDocuments);
234
+ }
235
+ return filterMap(parent.childrenIncludingDocuments, toNavigation);
169
236
  }
170
- return filterMap(parent.childrenIncludingDocuments, toNavigation);
171
- }
172
- function filterMapWithNoneCollection(reflection) {
173
- const none = reflection.find((x) => x.title.toLocaleLowerCase() === "none");
174
- const others = reflection.filter((x) => x.title.toLocaleLowerCase() !== "none");
175
- const mappedOthers = filterMap(others, toNavigation);
176
- if (none) {
177
- const noneMappedChildren = filterMap(none.children, toNavigation);
178
- return [...noneMappedChildren, ...mappedOthers];
237
+ function filterMapWithNoneCollection(reflection) {
238
+ const none = reflection.find((x) => x.title.toLocaleLowerCase() === "none");
239
+ const others = reflection.filter((x) => x.title.toLocaleLowerCase() !== "none");
240
+ const mappedOthers = filterMap(others, toNavigation);
241
+ if (none) {
242
+ const noneMappedChildren = filterMap(none.children, toNavigation);
243
+ return [...noneMappedChildren, ...mappedOthers];
244
+ }
245
+ return mappedOthers;
179
246
  }
180
- return mappedOthers;
181
- }
182
- function deriveModuleFolders(children) {
183
- const result = [];
184
- const resolveOrCreateParents = (path, root = result) => {
185
- if (path.length > 1) {
186
- const inner = root.find((el) => el.text === path[0]);
187
- if (inner) {
188
- inner.children ||= [];
189
- return resolveOrCreateParents(path.slice(1), inner.children);
247
+ function deriveModuleFolders(children) {
248
+ const result = [];
249
+ const resolveOrCreateParents = (path, root = result) => {
250
+ if (path.length > 1) {
251
+ const inner = root.find((el) => el.text === path[0]);
252
+ if (inner) {
253
+ inner.children ||= [];
254
+ return resolveOrCreateParents(path.slice(1), inner.children);
255
+ }
256
+ else {
257
+ root.push({
258
+ text: path[0],
259
+ children: [],
260
+ });
261
+ return resolveOrCreateParents(path.slice(1), root[root.length - 1].children);
262
+ }
190
263
  }
191
- else {
192
- root.push({
193
- text: path[0],
194
- children: [],
195
- });
196
- return resolveOrCreateParents(path.slice(1), root[root.length - 1].children);
264
+ return root;
265
+ };
266
+ // Note: This might end up putting a module within another module if we document
267
+ // both foo/index.ts and foo/bar.ts.
268
+ for (const child of children.filter((c) => router.hasOwnDocument(c))) {
269
+ const nav = toNavigation(child);
270
+ if (nav) {
271
+ const parts = child.name.split("/");
272
+ const collection = resolveOrCreateParents(parts);
273
+ nav.text = parts[parts.length - 1];
274
+ collection.push(nav);
197
275
  }
198
276
  }
199
- return root;
200
- };
201
- // Note: This might end up putting a module within another module if we document
202
- // both foo/index.ts and foo/bar.ts.
203
- for (const child of children.filter((c) => router.hasOwnDocument(c))) {
204
- const nav = toNavigation(child);
205
- if (nav) {
206
- const parts = child.name.split("/");
207
- const collection = resolveOrCreateParents(parts);
208
- nav.text = parts[parts.length - 1];
209
- collection.push(nav);
210
- }
211
- }
212
- // Now merge single-possible-paths together so we don't have folders in our navigation
213
- // which contain only another single folder.
214
- if (opts.compactFolders) {
215
- const queue = [...result];
216
- while (queue.length) {
217
- const review = queue.shift();
218
- queue.push(...(review.children || []));
219
- if (review.kind || review.path)
220
- continue;
221
- if (review.children?.length === 1) {
222
- const copyFrom = review.children[0];
223
- const fullName = `${review.text}/${copyFrom.text}`;
224
- delete review.children;
225
- Object.assign(review, copyFrom);
226
- review.text = fullName;
227
- queue.push(review);
277
+ // Now merge single-possible-paths together so we don't have folders in our navigation
278
+ // which contain only another single folder.
279
+ if (opts.compactFolders) {
280
+ const queue = [...result];
281
+ while (queue.length) {
282
+ const review = queue.shift();
283
+ queue.push(...(review.children || []));
284
+ if (review.kind || review.path)
285
+ continue;
286
+ if (review.children?.length === 1) {
287
+ const copyFrom = review.children[0];
288
+ const fullName = `${review.text}/${copyFrom.text}`;
289
+ delete review.children;
290
+ Object.assign(review, copyFrom);
291
+ review.text = fullName;
292
+ queue.push(review);
293
+ }
228
294
  }
229
295
  }
296
+ return result;
230
297
  }
231
- return result;
232
298
  }
233
- }
234
- }
299
+ };
300
+ })();
301
+ export { DefaultTheme };
235
302
  function getReflectionClasses(reflection, filters) {
236
303
  const classes = new Set();
237
304
  // Filter classes should match up with the settings function in