typedoc 0.28.0-beta.2 → 0.28.0

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.
package/dist/index.d.ts CHANGED
@@ -37,7 +37,7 @@ export * from "./lib/models/index.js";
37
37
  /** @primaryExport */
38
38
  export * as Configuration from "./lib/utils/options/index.js";
39
39
  export { BaseRouter, CategoryRouter, DefaultTheme, DefaultThemeRenderContext, GroupRouter, IndexEvent, KindDirRouter, KindRouter, MarkdownEvent, PageEvent, PageKind, Renderer, RendererEvent, Slugger, StructureDirRouter, StructureRouter, Theme, } from "./lib/output/index.js";
40
- export type { Icons, NavigationElement, PageDefinition, PageHeading, RendererEvents, RendererHooks, RenderTemplate, Router, } from "./lib/output/index.js";
40
+ export type { Icons, NavigationElement, PageDefinition, PageHeading, RendererEvents, RendererHooks, RenderTemplate, Router, RouterTarget, } from "./lib/output/index.js";
41
41
  export { Outputs } from "./lib/output/output.js";
42
42
  export { ArgumentsReader, CommentStyle, EntryPointStrategy, normalizePath, Option, OptionDefaults, Options, PackageJsonReader, ParameterHint, ParameterType, TSConfigReader, TypeDocReader, ValidatingFileRegistry, } from "./lib/utils/index.js";
43
43
  export type { ArrayDeclarationOption, BooleanDeclarationOption, DeclarationOption, DeclarationOptionBase, DeclarationOptionToOptionType, DocumentationEntryPoint, FancyConsoleLogger, FlagsDeclarationOption, JsDocCompatibility, KeyToDeclaration, ManuallyValidatedOption, MapDeclarationOption, MixedDeclarationOption, NumberDeclarationOption, ObjectDeclarationOption, OptionsReader, OutputSpecification, ParameterTypeToOptionTypeMap, SortStrategy, StringDeclarationOption, TypeDocOptionMap, TypeDocOptions, TypeDocOptionValues, ValidationOptions, } from "./lib/utils/index.js";
@@ -415,7 +415,7 @@ export declare class ReflectionType extends Type {
415
415
  readonly type = "reflection";
416
416
  constructor(declaration: DeclarationReflection);
417
417
  protected getTypeString(): string;
418
- needsParenthesis(): boolean;
418
+ needsParenthesis(where: TypeContext): boolean;
419
419
  toObject(serializer: Serializer): JSONOutput.ReflectionType;
420
420
  }
421
421
  /**
@@ -917,7 +917,13 @@ export class ReflectionType extends Type {
917
917
  }
918
918
  return `{ ${parts.join("; ")} }`;
919
919
  }
920
- needsParenthesis() {
920
+ needsParenthesis(where) {
921
+ if (this.declaration.children || this.declaration.indexSignatures) {
922
+ return false;
923
+ }
924
+ if (this.declaration.signatures?.length === 1) {
925
+ return where === TypeContext.arrayElement || where === TypeContext.unionElement;
926
+ }
921
927
  return false;
922
928
  }
923
929
  toObject(serializer) {
@@ -1,5 +1,5 @@
1
1
  import { AbstractComponent } from "../utils/component.js";
2
- import type { ProjectReflection, Reflection } from "../models/index.js";
2
+ import type { ProjectReflection } from "../models/index.js";
3
3
  import type { Renderer } from "./renderer.js";
4
4
  import { PageEvent, RendererEvent } from "./events.js";
5
5
  export declare abstract class RendererComponent extends AbstractComponent<Renderer, {}> {
@@ -15,7 +15,7 @@ export declare abstract class ContextAwareRendererComponent extends RendererComp
15
15
  /**
16
16
  * The reflection that is currently processed.
17
17
  */
18
- protected page?: PageEvent<Reflection>;
18
+ protected page?: PageEvent;
19
19
  /**
20
20
  * The url of the document that is being currently generated.
21
21
  * Set when a page begins rendering.
@@ -49,5 +49,5 @@ export declare abstract class ContextAwareRendererComponent extends RendererComp
49
49
  *
50
50
  * @param page An event object describing the current render operation.
51
51
  */
52
- protected onBeginPage(page: PageEvent<Reflection>): void;
52
+ protected onBeginPage(page: PageEvent): void;
53
53
  }
@@ -1,6 +1,6 @@
1
1
  import type { ProjectReflection } from "../models/ProjectReflection.js";
2
- import type { DeclarationReflection, DocumentReflection, ReflectionKind } from "../models/index.js";
3
- import type { PageDefinition, PageKind } from "./router.js";
2
+ import { type DeclarationReflection, type DocumentReflection, Reflection, type ReflectionKind } from "../models/index.js";
3
+ import type { PageDefinition, PageKind, RouterTarget } from "./router.js";
4
4
  /**
5
5
  * An event emitted by the {@link Renderer} class at the very beginning and
6
6
  * ending of the entire rendering process.
@@ -47,7 +47,7 @@ export interface PageHeading {
47
47
  * @see {@link Renderer.EVENT_BEGIN_PAGE}
48
48
  * @see {@link Renderer.EVENT_END_PAGE}
49
49
  */
50
- export declare class PageEvent<out Model = unknown> {
50
+ export declare class PageEvent<out Model extends RouterTarget = RouterTarget> {
51
51
  /**
52
52
  * The project the renderer is currently processing.
53
53
  */
@@ -102,6 +102,7 @@ export declare class PageEvent<out Model = unknown> {
102
102
  */
103
103
  static readonly END = "endPage";
104
104
  constructor(model: Model);
105
+ isReflectionEvent(): this is PageEvent<Reflection>;
105
106
  }
106
107
  /**
107
108
  * An event emitted when markdown is being parsed. Allows other plugins to manipulate the result.
@@ -1,3 +1,4 @@
1
+ import { Reflection, } from "../models/index.js";
1
2
  /**
2
3
  * An event emitted by the {@link Renderer} class at the very beginning and
3
4
  * ending of the entire rendering process.
@@ -106,6 +107,9 @@ export class PageEvent {
106
107
  constructor(model) {
107
108
  this.model = model;
108
109
  }
110
+ isReflectionEvent() {
111
+ return this.model instanceof Reflection;
112
+ }
109
113
  }
110
114
  /**
111
115
  * An event emitted when markdown is being parsed. Allows other plugins to manipulate the result.
@@ -6,4 +6,4 @@ export { DefaultTheme, type NavigationElement, type RenderTemplate } from "./the
6
6
  export { DefaultThemeRenderContext } from "./themes/default/DefaultThemeRenderContext.js";
7
7
  export type { Icons } from "./themes/default/partials/icon.js";
8
8
  export { Slugger } from "./themes/default/Slugger.js";
9
- export { BaseRouter, CategoryRouter, GroupRouter, KindDirRouter, KindRouter, type PageDefinition, PageKind, type Router, StructureDirRouter, StructureRouter, } from "./router.js";
9
+ export { BaseRouter, CategoryRouter, GroupRouter, KindDirRouter, KindRouter, type PageDefinition, PageKind, type Router, type RouterTarget, StructureDirRouter, StructureRouter, } from "./router.js";
@@ -34,6 +34,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
34
34
  };
35
35
  import * as Path from "path";
36
36
  import lunr from "lunr";
37
+ import { Reflection } from "../../models/index.js";
37
38
  import { RendererComponent } from "../components.js";
38
39
  import { IndexEvent, RendererEvent } from "../events.js";
39
40
  import { Option, writeFile } from "../../utils/index.js";
@@ -112,8 +113,9 @@ let JavascriptIndexPlugin = (() => {
112
113
  const theme = this.owner.theme;
113
114
  const rows = [];
114
115
  const initialSearchResults = this.owner
115
- .router.getLinkableReflections()
116
- .filter((refl) => (refl.isDeclaration() || refl.isDocument()) &&
116
+ .router.getLinkTargets()
117
+ .filter((refl) => refl instanceof Reflection &&
118
+ (refl.isDeclaration() || refl.isDocument()) &&
117
119
  refl.name &&
118
120
  !refl.flags.isExternal);
119
121
  const indexEvent = new IndexEvent(initialSearchResults);
@@ -79,8 +79,8 @@ export interface RendererHooks {
79
79
  }
80
80
  export interface RendererEvents {
81
81
  beginRender: [RendererEvent];
82
- beginPage: [PageEvent<Reflection>];
83
- endPage: [PageEvent<Reflection>];
82
+ beginPage: [PageEvent];
83
+ endPage: [PageEvent];
84
84
  endRender: [RendererEvent];
85
85
  parseMarkdown: [MarkdownEvent];
86
86
  prepareIndex: [IndexEvent];
@@ -263,7 +263,7 @@ let Renderer = (() => {
263
263
  await this.runPreRenderJobs(output);
264
264
  this.application.logger.verbose(`There are ${pages.length} pages to write.`);
265
265
  for (const page of pages) {
266
- this.renderDocument(outputDirectory, page);
266
+ this.renderDocument(outputDirectory, page, project);
267
267
  }
268
268
  this.postRenderAsyncJobs.push(async (o) => await this.theme.postRender(o));
269
269
  await Promise.all(this.postRenderAsyncJobs.map((job) => job(output)));
@@ -286,13 +286,13 @@ let Renderer = (() => {
286
286
  * @param page An event describing the current page.
287
287
  * @return TRUE if the page has been saved to disc, otherwise FALSE.
288
288
  */
289
- renderDocument(outputDirectory, page) {
289
+ renderDocument(outputDirectory, page, project) {
290
290
  const momento = this.hooks.saveMomento();
291
291
  const event = new PageEvent(page.model);
292
292
  event.url = page.url;
293
293
  event.filename = path.join(outputDirectory, page.url);
294
294
  event.pageKind = page.kind;
295
- event.project = page.model.project;
295
+ event.project = project;
296
296
  this.trigger(PageEvent.BEGIN, event);
297
297
  event.contents = this.theme.render(event);
298
298
  this.trigger(PageEvent.END, event);
@@ -1,9 +1,12 @@
1
1
  import type { Application } from "../application.js";
2
- import { type ProjectReflection, type Reflection, ReflectionKind } from "../models/index.js";
2
+ import { ProjectReflection, Reflection, ReflectionKind } from "../models/index.js";
3
3
  import { type TypeDocOptionMap } from "../utils/index.js";
4
4
  import { Slugger } from "./themes/default/Slugger.js";
5
5
  /**
6
6
  * The type of page which should be rendered. This may be extended in the future.
7
+ *
8
+ * Note: TypeDoc any string may be used as the page kind. TypeDoc defines a few
9
+ * described by this object.
7
10
  * @enum
8
11
  */
9
12
  export declare const PageKind: {
@@ -12,11 +15,20 @@ export declare const PageKind: {
12
15
  readonly Document: "document";
13
16
  readonly Hierarchy: "hierarchy";
14
17
  };
15
- export type PageKind = (typeof PageKind)[keyof typeof PageKind];
16
- export interface PageDefinition {
18
+ export type PageKind = (typeof PageKind)[keyof typeof PageKind] | string & {};
19
+ /**
20
+ * A router target is something that may be linked to within a page. Notably,
21
+ * {@link Reflection} is compatible with this interface. TypeDoc supports non-reflection
22
+ * router targets, but does not currently create any.
23
+ */
24
+ export type RouterTarget = {
25
+ name: string;
26
+ parent: RouterTarget;
27
+ } | Reflection;
28
+ export interface PageDefinition<out Model extends RouterTarget = RouterTarget> {
17
29
  readonly url: string;
18
30
  readonly kind: PageKind;
19
- readonly model: Reflection;
31
+ readonly model: Model;
20
32
  }
21
33
  /**
22
34
  * Interface which routers must conform to.
@@ -28,36 +40,36 @@ export interface Router {
28
40
  */
29
41
  buildPages(project: ProjectReflection): PageDefinition[];
30
42
  /**
31
- * Can be used to check if the reflection can be linked to.
43
+ * Can be used to check if the target can be linked to.
32
44
  */
33
- hasUrl(reflection: Reflection): boolean;
45
+ hasUrl(target: RouterTarget): boolean;
34
46
  /**
35
- * Get a list of all reflections which can be linked to.
47
+ * Get a list of all targets which can be linked to.
36
48
  * This is used for creating the search index.
37
49
  */
38
- getLinkableReflections(): Reflection[];
50
+ getLinkTargets(): RouterTarget[];
39
51
  /**
40
- * Gets an anchor for this reflection within its containing page.
41
- * May be undefined if this reflection owns its own page.
52
+ * Gets an anchor for this target within its containing page.
53
+ * May be undefined if this target owns its own page.
42
54
  */
43
- getAnchor(refl: Reflection): string | undefined;
55
+ getAnchor(refl: RouterTarget): string | undefined;
44
56
  /**
45
- * Returns true if the reflection has its own page, false if embedded within
57
+ * Returns true if the target has its own page, false if embedded within
46
58
  * another page.
47
59
  */
48
- hasOwnDocument(refl: Reflection): boolean;
60
+ hasOwnDocument(refl: RouterTarget): boolean;
49
61
  /**
50
62
  * Should return a URL which when clicked on the page containing `from`
51
63
  * takes the user to the page/anchor containing `to`.
52
64
  */
53
- relativeUrl(from: Reflection, to: Reflection): string;
65
+ relativeUrl(from: RouterTarget, to: RouterTarget): string;
54
66
  /**
55
67
  * Should return a URL relative to the project base. This is used for
56
68
  * determining links to items in the assets folder.
57
69
  */
58
- baseRelativeUrl(from: Reflection, target: string): string;
70
+ baseRelativeUrl(from: RouterTarget, target: string): string;
59
71
  /**
60
- * Get the full URL to the reflection. In TypeDoc's default router this
72
+ * Get the full URL to the target. In TypeDoc's default router this
61
73
  * is equivalent to `relativeUrl(project, refl)`, but this might not be
62
74
  * the case for custom routers which place the project somewhere else
63
75
  * besides `index.html`.
@@ -65,13 +77,13 @@ export interface Router {
65
77
  * The URL returned by this by the frontend JS when building dynamic URLs
66
78
  * for the search, full hierarchy, and navigation components.
67
79
  */
68
- getFullUrl(refl: Reflection): string;
80
+ getFullUrl(refl: RouterTarget): string;
69
81
  /**
70
- * Responsible for getting a slugger for the given reflection. If a
71
- * reflection is not associated with a page, the slugger for the parent
72
- * reflection should be returned instead.
82
+ * Responsible for getting a slugger for the given target. If a
83
+ * target is not associated with a page, the slugger for the parent
84
+ * target should be returned instead.
73
85
  */
74
- getSlugger(reflection: Reflection): Slugger;
86
+ getSlugger(reflection: RouterTarget): Slugger;
75
87
  }
76
88
  /**
77
89
  * Base router class intended to make it easier to implement a router.
@@ -84,36 +96,36 @@ export declare abstract class BaseRouter implements Router {
84
96
  readonly application: Application;
85
97
  extension: string;
86
98
  protected usedFileNames: Set<string>;
87
- protected sluggers: Map<Reflection, Slugger>;
88
- protected fullUrls: Map<Reflection, string>;
89
- protected anchors: Map<Reflection, string>;
99
+ protected sluggers: Map<RouterTarget, Slugger>;
100
+ protected fullUrls: Map<RouterTarget, string>;
101
+ protected anchors: Map<RouterTarget, string>;
90
102
  protected accessor sluggerConfiguration: TypeDocOptionMap["sluggerConfiguration"];
91
103
  protected accessor includeHierarchySummary: boolean;
92
104
  constructor(application: Application);
93
105
  /**
94
- * Should return the base-relative desired file name for a reflection.
106
+ * Should return the base-relative desired file name for a router target.
95
107
  * This name may not be used exactly as TypeDoc will detect conflicts
96
108
  * and automatically introduce a unique identifier to the URL to resolve
97
109
  * them.
98
110
  */
99
- protected abstract getIdealBaseName(reflection: Reflection): string;
111
+ protected abstract getIdealBaseName(reflection: RouterTarget): string;
100
112
  buildPages(project: ProjectReflection): PageDefinition[];
101
- hasUrl(reflection: Reflection): boolean;
102
- getLinkableReflections(): Reflection[];
103
- getAnchor(refl: Reflection): string | undefined;
104
- hasOwnDocument(refl: Reflection): boolean;
105
- relativeUrl(from: Reflection, to: Reflection): string;
106
- baseRelativeUrl(from: Reflection, target: string): string;
107
- getFullUrl(refl: Reflection): string;
108
- getSlugger(reflection: Reflection): Slugger;
113
+ hasUrl(target: RouterTarget): boolean;
114
+ getLinkTargets(): RouterTarget[];
115
+ getAnchor(target: RouterTarget): string | undefined;
116
+ hasOwnDocument(target: RouterTarget): boolean;
117
+ relativeUrl(from: RouterTarget, to: RouterTarget): string;
118
+ baseRelativeUrl(from: RouterTarget, target: string): string;
119
+ getFullUrl(target: RouterTarget): string;
120
+ getSlugger(target: RouterTarget): Slugger;
109
121
  /**
110
122
  * Should the page kind to use if a reflection should have its own rendered
111
123
  * page in the output. Note that once `undefined` is returned, children of
112
124
  * that reflection will not have their own document.
113
125
  */
114
- protected getPageKind(reflection: Reflection): PageKind | undefined;
115
- protected buildChildPages(reflection: Reflection, outPages: PageDefinition[]): void;
116
- protected buildAnchors(reflection: Reflection, pageReflection: Reflection): void;
126
+ protected getPageKind(target: RouterTarget): PageKind | undefined;
127
+ protected buildChildPages(target: RouterTarget, outPages: PageDefinition[]): void;
128
+ protected buildAnchors(target: RouterTarget, pageTarget: RouterTarget): void;
117
129
  /** Strip non-url safe characters from the specified string. */
118
130
  protected getUrlSafeName(name: string): string;
119
131
  protected getFileName(baseName: string): string;
@@ -34,13 +34,16 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
34
34
  };
35
35
  import { CategoryPlugin } from "../converter/plugins/CategoryPlugin.js";
36
36
  import { GroupPlugin } from "../converter/plugins/GroupPlugin.js";
37
- import { ReflectionKind, } from "../models/index.js";
37
+ import { ProjectReflection, Reflection, ReflectionKind } from "../models/index.js";
38
38
  import { createNormalizedUrl } from "#node-utils";
39
39
  import { Option } from "../utils/index.js";
40
40
  import { Slugger } from "./themes/default/Slugger.js";
41
41
  import { getHierarchyRoots } from "./themes/lib.js";
42
42
  /**
43
43
  * The type of page which should be rendered. This may be extended in the future.
44
+ *
45
+ * Note: TypeDoc any string may be used as the page kind. TypeDoc defines a few
46
+ * described by this object.
44
47
  * @enum
45
48
  */
46
49
  export const PageKind = {
@@ -49,6 +52,18 @@ export const PageKind = {
49
52
  Document: "document",
50
53
  Hierarchy: "hierarchy",
51
54
  };
55
+ function getFullName(target) {
56
+ if (target instanceof ProjectReflection) {
57
+ return target.name;
58
+ }
59
+ const parts = [target.name];
60
+ let current = target;
61
+ while (!(current instanceof ProjectReflection)) {
62
+ parts.unshift(current.name);
63
+ current = current.parent;
64
+ }
65
+ return parts.join(".");
66
+ }
52
67
  /**
53
68
  * Base router class intended to make it easier to implement a router.
54
69
  *
@@ -128,24 +143,27 @@ let BaseRouter = (() => {
128
143
  }
129
144
  return pages;
130
145
  }
131
- hasUrl(reflection) {
132
- return this.fullUrls.has(reflection);
146
+ hasUrl(target) {
147
+ return this.fullUrls.has(target);
133
148
  }
134
- getLinkableReflections() {
149
+ getLinkTargets() {
135
150
  return Array.from(this.fullUrls.keys());
136
151
  }
137
- getAnchor(refl) {
138
- if (!this.anchors.has(refl)) {
139
- this.application.logger.verbose(`${refl.getFullName()} does not have an anchor but one was requested, this is a bug in the theme`);
152
+ getAnchor(target) {
153
+ if (!this.anchors.has(target)) {
154
+ this.application.logger.verbose(`${getFullName(target)} does not have an anchor but one was requested, this is a bug in the theme`);
140
155
  }
141
- return this.anchors.get(refl);
156
+ return this.anchors.get(target);
142
157
  }
143
- hasOwnDocument(refl) {
144
- return this.anchors.get(refl) === undefined && this.hasUrl(refl);
158
+ hasOwnDocument(target) {
159
+ return this.anchors.get(target) === undefined && this.hasUrl(target);
145
160
  }
146
161
  relativeUrl(from, to) {
147
162
  let slashes = 0;
148
163
  while (!this.hasOwnDocument(from)) {
164
+ // We know we must have a parent here as the Project is the only
165
+ // root level element without a parent, and the project always has
166
+ // an own document.
149
167
  from = from.parent;
150
168
  }
151
169
  const fromUrl = this.getFullUrl(from);
@@ -163,7 +181,7 @@ let BaseRouter = (() => {
163
181
  }
164
182
  }
165
183
  }
166
- if (equal && !to.isProject()) {
184
+ if (equal && !(to instanceof ProjectReflection)) {
167
185
  if (fromUrl === toUrl) {
168
186
  return "";
169
187
  }
@@ -180,26 +198,29 @@ let BaseRouter = (() => {
180
198
  }
181
199
  return "../".repeat(slashes) + target;
182
200
  }
183
- getFullUrl(refl) {
184
- const url = this.fullUrls.get(refl);
201
+ getFullUrl(target) {
202
+ const url = this.fullUrls.get(target);
185
203
  if (!url) {
186
- throw new Error(`Tried to get a URL of a reflection ${refl.getFullName()} which did not receive a URL`);
204
+ throw new Error(`Tried to get a URL of a router target ${getFullName(target)} which did not receive a URL`);
187
205
  }
188
206
  return url;
189
207
  }
190
- getSlugger(reflection) {
191
- if (this.sluggers.has(reflection)) {
192
- return this.sluggers.get(reflection);
208
+ getSlugger(target) {
209
+ if (this.sluggers.has(target)) {
210
+ return this.sluggers.get(target);
193
211
  }
194
212
  // A slugger should always be defined at least for the project
195
- return this.getSlugger(reflection.parent);
213
+ return this.getSlugger(target.parent);
196
214
  }
197
215
  /**
198
216
  * Should the page kind to use if a reflection should have its own rendered
199
217
  * page in the output. Note that once `undefined` is returned, children of
200
218
  * that reflection will not have their own document.
201
219
  */
202
- getPageKind(reflection) {
220
+ getPageKind(target) {
221
+ if (!(target instanceof Reflection)) {
222
+ return undefined;
223
+ }
203
224
  const pageReflectionKinds = ReflectionKind.Class |
204
225
  ReflectionKind.Interface |
205
226
  ReflectionKind.Enum |
@@ -209,38 +230,43 @@ let BaseRouter = (() => {
209
230
  ReflectionKind.Function |
210
231
  ReflectionKind.Variable;
211
232
  const documentReflectionKinds = ReflectionKind.Document;
212
- if (reflection.kindOf(pageReflectionKinds)) {
233
+ if (target.kindOf(pageReflectionKinds)) {
213
234
  return PageKind.Reflection;
214
235
  }
215
- if (reflection.kindOf(documentReflectionKinds)) {
236
+ if (target.kindOf(documentReflectionKinds)) {
216
237
  return PageKind.Document;
217
238
  }
218
239
  }
219
- buildChildPages(reflection, outPages) {
220
- const kind = this.getPageKind(reflection);
240
+ buildChildPages(target, outPages) {
241
+ const kind = this.getPageKind(target);
221
242
  if (kind) {
222
- const idealName = this.getIdealBaseName(reflection);
243
+ const idealName = this.getIdealBaseName(target);
223
244
  const actualName = this.getFileName(idealName);
224
- this.fullUrls.set(reflection, actualName);
225
- this.sluggers.set(reflection, new Slugger(this.sluggerConfiguration));
245
+ this.fullUrls.set(target, actualName);
246
+ this.sluggers.set(target, new Slugger(this.sluggerConfiguration));
226
247
  outPages.push({
227
248
  kind,
228
- model: reflection,
249
+ model: target,
229
250
  url: actualName,
230
251
  });
231
- reflection.traverse((child) => {
232
- this.buildChildPages(child, outPages);
233
- return true;
234
- });
252
+ if (target instanceof Reflection) {
253
+ target.traverse((child) => {
254
+ this.buildChildPages(child, outPages);
255
+ return true;
256
+ });
257
+ }
235
258
  }
236
259
  else {
237
- this.buildAnchors(reflection, reflection.parent);
260
+ this.buildAnchors(target, target.parent);
238
261
  }
239
262
  }
240
- buildAnchors(reflection, pageReflection) {
241
- if (!reflection.isDeclaration() &&
242
- !reflection.isSignature() &&
243
- !reflection.isTypeParameter()) {
263
+ buildAnchors(target, pageTarget) {
264
+ if (!(target instanceof Reflection) || !(pageTarget instanceof Reflection)) {
265
+ return;
266
+ }
267
+ if (!target.isDeclaration() &&
268
+ !target.isSignature() &&
269
+ !target.isTypeParameter()) {
244
270
  return;
245
271
  }
246
272
  // We support linking to reflections for types directly contained within an export
@@ -248,16 +274,16 @@ let BaseRouter = (() => {
248
274
  // for a property depending on whether or not it is deemed useful, and defining a link
249
275
  // which might not be used may result in a link being generated which isn't valid. #2808.
250
276
  // This should be kept in sync with the renderingChildIsUseful function.
251
- if (reflection.kindOf(ReflectionKind.TypeLiteral) &&
252
- (!reflection.parent?.kindOf(ReflectionKind.SomeExport) ||
253
- reflection.parent.type?.type !==
277
+ if (target.kindOf(ReflectionKind.TypeLiteral) &&
278
+ (!target.parent?.kindOf(ReflectionKind.SomeExport) ||
279
+ target.parent.type?.type !==
254
280
  "reflection")) {
255
281
  return;
256
282
  }
257
- if (!reflection.kindOf(ReflectionKind.TypeLiteral)) {
258
- let refl = reflection;
283
+ if (!target.kindOf(ReflectionKind.TypeLiteral)) {
284
+ let refl = target;
259
285
  const parts = [refl.name];
260
- while (refl.parent && refl.parent !== pageReflection) {
286
+ while (refl.parent && refl.parent !== pageTarget) {
261
287
  refl = refl.parent;
262
288
  // Avoid duplicate names for signatures and useless __type in anchors
263
289
  if (!refl.kindOf(ReflectionKind.TypeLiteral |
@@ -265,12 +291,12 @@ let BaseRouter = (() => {
265
291
  parts.unshift(refl.name);
266
292
  }
267
293
  }
268
- const anchor = this.getSlugger(pageReflection).slug(parts.join("."));
269
- this.fullUrls.set(reflection, this.fullUrls.get(pageReflection) + "#" + anchor);
270
- this.anchors.set(reflection, anchor);
294
+ const anchor = this.getSlugger(pageTarget).slug(parts.join("."));
295
+ this.fullUrls.set(target, this.fullUrls.get(pageTarget) + "#" + anchor);
296
+ this.anchors.set(target, anchor);
271
297
  }
272
- reflection.traverse((child) => {
273
- this.buildAnchors(child, pageReflection);
298
+ target.traverse((child) => {
299
+ this.buildAnchors(child, pageTarget);
274
300
  return true;
275
301
  });
276
302
  }
@@ -1,6 +1,5 @@
1
1
  import { RendererComponent } from "./components.js";
2
2
  import type { PageEvent, RendererEvent } from "./events.js";
3
- import type { Reflection } from "../models/index.js";
4
3
  /**
5
4
  * Base class of all themes.
6
5
  *
@@ -11,7 +10,7 @@ export declare abstract class Theme extends RendererComponent {
11
10
  /**
12
11
  * Renders the provided page to a string, which will be written to disk by the {@link Renderer}
13
12
  */
14
- abstract render(event: PageEvent<Reflection>): string;
13
+ abstract render(event: PageEvent): string;
15
14
  /**
16
15
  * Optional hook to call pre-render jobs
17
16
  */
@@ -39,7 +39,22 @@ import { Option } from "../../utils/index.js";
39
39
  import { highlight, isLoadedLanguage, isSupportedLanguage } from "../../utils/highlighter.js";
40
40
  import { assertNever, escapeHtml, i18n, JSX } from "#utils";
41
41
  import { anchorIcon } from "./default/partials/anchor-icon.js";
42
- import { ReflectionKind, } from "../../models/index.js";
42
+ import { Reflection, ReflectionKind, } from "../../models/index.js";
43
+ function getFriendlyFullName(target) {
44
+ if (target instanceof Reflection) {
45
+ return target.getFriendlyFullName();
46
+ }
47
+ if (target.parent) {
48
+ return target.name;
49
+ }
50
+ const parts = [target.name];
51
+ let current = target;
52
+ while (current.parent) {
53
+ parts.unshift(current.name);
54
+ current = current.parent;
55
+ }
56
+ return parts.join(".");
57
+ }
43
58
  /**
44
59
  * Implements markdown and relativeURL helpers for templates.
45
60
  * @internal
@@ -115,11 +130,11 @@ let MarkedPlugin = (() => {
115
130
  lang = lang || "typescript";
116
131
  lang = lang.toLowerCase();
117
132
  if (!isSupportedLanguage(lang)) {
118
- this.application.logger.warn(i18n.unsupported_highlight_language_0_not_highlighted_in_comment_for_1(lang, this.page?.model.getFriendlyFullName() ?? "(unknown)"));
133
+ this.application.logger.warn(i18n.unsupported_highlight_language_0_not_highlighted_in_comment_for_1(lang, getFriendlyFullName(this.page?.model || { name: "(unknown)" })));
119
134
  return text;
120
135
  }
121
136
  if (!isLoadedLanguage(lang)) {
122
- this.application.logger.warn(i18n.unloaded_language_0_not_highlighted_in_comment_for_1(lang, this.page?.model.getFriendlyFullName() ?? "(unknown)"));
137
+ this.application.logger.warn(i18n.unloaded_language_0_not_highlighted_in_comment_for_1(lang, getFriendlyFullName(this.page?.model || { name: "(unknown)" })));
123
138
  return text;
124
139
  }
125
140
  return highlight(text, lang);
@@ -258,7 +273,7 @@ let MarkedPlugin = (() => {
258
273
  for (const { source, target, link } of this.renderedRelativeLinks) {
259
274
  const slugger = this.owner.router.getSlugger(target);
260
275
  if (!slugger.hasAnchor(link.targetAnchor)) {
261
- this.application.logger.warn(i18n.reflection_0_links_to_1_but_anchor_does_not_exist_try_2(source.getFriendlyFullName(), link.text, slugger
276
+ this.application.logger.warn(i18n.reflection_0_links_to_1_but_anchor_does_not_exist_try_2(getFriendlyFullName(source), link.text, slugger
262
277
  .getSimilarAnchors(link.targetAnchor)
263
278
  .map((a) => link.text.replace(/#.*/, "#" + a))
264
279
  .join("\n\t")));
@@ -61,7 +61,7 @@ export declare class DefaultTheme extends Theme {
61
61
  * @param renderer The renderer this theme is attached to.
62
62
  */
63
63
  constructor(renderer: Renderer);
64
- render(page: PageEvent<Reflection>): string;
64
+ render(page: PageEvent): string;
65
65
  preRender(_event: RendererEvent): Promise<void>;
66
66
  private _navigationCache;
67
67
  /**
@@ -140,12 +140,19 @@ let DefaultTheme = (() => {
140
140
  this.router = renderer.router;
141
141
  }
142
142
  render(page) {
143
- const template = {
143
+ const templateMapping = {
144
144
  [PageKind.Index]: this.indexTemplate,
145
145
  [PageKind.Document]: this.documentTemplate,
146
146
  [PageKind.Hierarchy]: this.hierarchyTemplate,
147
147
  [PageKind.Reflection]: this.reflectionTemplate,
148
- }[page.pageKind];
148
+ };
149
+ const template = templateMapping[page.pageKind];
150
+ if (!template) {
151
+ throw new Error(`TypeDoc's DefaultTheme does not support the page kind ${page.pageKind}`);
152
+ }
153
+ if (!page.isReflectionEvent()) {
154
+ throw new Error(`TypeDoc's DefaultTheme requires that a page model be a reflection when rendering ${page.pageKind}`);
155
+ }
149
156
  const templateOutput = this.defaultLayoutTemplate(page, template);
150
157
  return "<!DOCTYPE html>" + JSX.renderElement(templateOutput) + "\n";
151
158
  }
@@ -67,7 +67,7 @@ export const defaultLayout = (context, template, props) => (JSX.createElement("h
67
67
  JSX.createElement("script", null,
68
68
  JSX.createElement(JSX.Raw, { html: 'document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";' }),
69
69
  JSX.createElement(JSX.Raw, { html: 'document.body.style.display="none";' }),
70
- JSX.createElement(JSX.Raw, { html: 'setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)' })),
70
+ JSX.createElement(JSX.Raw, { html: 'setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)' })),
71
71
  context.toolbar(props),
72
72
  JSX.createElement("div", { class: "container container-main" },
73
73
  JSX.createElement("div", { class: "col-content" },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typedoc",
3
3
  "description": "Create api documentation for TypeScript projects.",
4
- "version": "0.28.0-beta.2",
4
+ "version": "0.28.0",
5
5
  "homepage": "https://typedoc.org",
6
6
  "type": "module",
7
7
  "exports": {
@@ -31,7 +31,7 @@
31
31
  "pnpm": ">= 10"
32
32
  },
33
33
  "dependencies": {
34
- "@gerrit0/mini-shiki": "^3.0.0",
34
+ "@gerrit0/mini-shiki": "^3.2.1",
35
35
  "lunr": "^2.3.9",
36
36
  "markdown-it": "^14.1.0",
37
37
  "minimatch": "^9.0.5",
@@ -41,7 +41,7 @@
41
41
  "typescript": "5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x"
42
42
  },
43
43
  "devDependencies": {
44
- "@eslint/js": "^9.21.0",
44
+ "@eslint/js": "^9.22.0",
45
45
  "@types/lunr": "^2.3.7",
46
46
  "@types/markdown-it": "^14.1.2",
47
47
  "@types/mocha": "^10.0.10",
@@ -49,14 +49,14 @@
49
49
  "@typestrong/fs-fixture-builder": "github:TypeStrong/fs-fixture-builder#34113409e3a171e68ce5e2b55461ef5c35591cfe",
50
50
  "c8": "^10.1.3",
51
51
  "dprint": "^0.49.0",
52
- "esbuild": "^0.24.2",
53
- "eslint": "^9.21.0",
52
+ "esbuild": "^0.25.1",
53
+ "eslint": "^9.22.0",
54
54
  "mocha": "^11.1.0",
55
- "puppeteer": "^24.2.1",
55
+ "puppeteer": "^24.4.0",
56
56
  "semver": "^7.7.1",
57
57
  "tsx": "^4.19.3",
58
- "typescript": "5.8.1-rc",
59
- "typescript-eslint": "^8.24.1"
58
+ "typescript": "5.8.2",
59
+ "typescript-eslint": "^8.26.1"
60
60
  },
61
61
  "files": [
62
62
  "/bin",
package/static/style.css CHANGED
@@ -1076,9 +1076,8 @@
1076
1076
  .tsd-index-summary {
1077
1077
  margin-top: 1.5rem;
1078
1078
  margin-bottom: 0.75rem;
1079
- }
1080
- .tsd-index-heading {
1081
- margin: 0;
1079
+ display: flex;
1080
+ align-content: center;
1082
1081
  }
1083
1082
 
1084
1083
  .tsd-no-select {
@@ -1475,7 +1474,7 @@
1475
1474
  @media (max-width: 769px) {
1476
1475
  #tsd-toolbar-menu-trigger {
1477
1476
  display: inline-block;
1478
- /* temporary fix to vertically align, for compatibilty */
1477
+ /* temporary fix to vertically align, for compatibility */
1479
1478
  line-height: 2.5;
1480
1479
  }
1481
1480
  #tsd-toolbar-links {