typedoc 0.23.25 → 0.24.0-beta.1

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 (159) hide show
  1. package/bin/typedoc +1 -130
  2. package/dist/index.d.ts +3 -4
  3. package/dist/index.js +15 -5
  4. package/dist/lib/application-events.d.ts +1 -0
  5. package/dist/lib/application-events.js +1 -0
  6. package/dist/lib/application.d.ts +26 -10
  7. package/dist/lib/application.js +138 -65
  8. package/dist/lib/cli.d.ts +1 -0
  9. package/dist/lib/cli.js +129 -0
  10. package/dist/lib/converter/comments/declarationReference.d.ts +1 -1
  11. package/dist/lib/converter/comments/declarationReferenceResolver.js +11 -5
  12. package/dist/lib/converter/comments/discovery.d.ts +1 -1
  13. package/dist/lib/converter/comments/discovery.js +96 -76
  14. package/dist/lib/converter/comments/index.d.ts +1 -1
  15. package/dist/lib/converter/comments/index.js +37 -17
  16. package/dist/lib/converter/comments/linkResolver.d.ts +2 -3
  17. package/dist/lib/converter/comments/linkResolver.js +37 -132
  18. package/dist/lib/converter/context.d.ts +1 -1
  19. package/dist/lib/converter/context.js +27 -14
  20. package/dist/lib/converter/convert-expression.d.ts +1 -1
  21. package/dist/lib/converter/convert-expression.js +35 -15
  22. package/dist/lib/converter/converter.d.ts +1 -1
  23. package/dist/lib/converter/converter.js +35 -23
  24. package/dist/lib/converter/factories/index-signature.d.ts +1 -1
  25. package/dist/lib/converter/factories/index-signature.js +26 -3
  26. package/dist/lib/converter/factories/signature.d.ts +2 -2
  27. package/dist/lib/converter/factories/signature.js +76 -52
  28. package/dist/lib/converter/jsdoc.d.ts +1 -1
  29. package/dist/lib/converter/jsdoc.js +39 -17
  30. package/dist/lib/converter/plugins/CommentPlugin.d.ts +0 -2
  31. package/dist/lib/converter/plugins/CommentPlugin.js +7 -28
  32. package/dist/lib/converter/plugins/GroupPlugin.d.ts +1 -39
  33. package/dist/lib/converter/plugins/GroupPlugin.js +3 -61
  34. package/dist/lib/converter/plugins/ImplementsPlugin.d.ts +1 -4
  35. package/dist/lib/converter/plugins/ImplementsPlugin.js +49 -28
  36. package/dist/lib/converter/plugins/InheritDocPlugin.d.ts +0 -3
  37. package/dist/lib/converter/plugins/InheritDocPlugin.js +6 -7
  38. package/dist/lib/converter/plugins/LinkResolverPlugin.d.ts +2 -3
  39. package/dist/lib/converter/plugins/LinkResolverPlugin.js +12 -10
  40. package/dist/lib/converter/plugins/PackagePlugin.d.ts +5 -14
  41. package/dist/lib/converter/plugins/PackagePlugin.js +44 -56
  42. package/dist/lib/converter/plugins/SourcePlugin.js +31 -6
  43. package/dist/lib/converter/plugins/TypePlugin.d.ts +4 -10
  44. package/dist/lib/converter/plugins/TypePlugin.js +23 -13
  45. package/dist/lib/converter/symbols.d.ts +1 -1
  46. package/dist/lib/converter/symbols.js +153 -132
  47. package/dist/lib/converter/types.d.ts +1 -1
  48. package/dist/lib/converter/types.js +121 -95
  49. package/dist/lib/converter/utils/nodes.d.ts +1 -1
  50. package/dist/lib/converter/utils/nodes.js +24 -4
  51. package/dist/lib/converter/utils/symbols.d.ts +1 -1
  52. package/dist/lib/converter/utils/symbols.js +24 -4
  53. package/dist/lib/models/ReflectionCategory.d.ts +2 -1
  54. package/dist/lib/models/ReflectionCategory.js +12 -0
  55. package/dist/lib/models/ReflectionGroup.d.ts +3 -2
  56. package/dist/lib/models/ReflectionGroup.js +20 -0
  57. package/dist/lib/models/comments/comment.d.ts +12 -1
  58. package/dist/lib/models/comments/comment.js +80 -17
  59. package/dist/lib/models/reflections/ReflectionSymbolId.d.ts +29 -0
  60. package/dist/lib/models/reflections/ReflectionSymbolId.js +94 -0
  61. package/dist/lib/models/reflections/abstract.d.ts +12 -37
  62. package/dist/lib/models/reflections/abstract.js +27 -35
  63. package/dist/lib/models/reflections/container.d.ts +6 -10
  64. package/dist/lib/models/reflections/container.js +8 -1
  65. package/dist/lib/models/reflections/declaration.d.ts +19 -4
  66. package/dist/lib/models/reflections/declaration.js +54 -1
  67. package/dist/lib/models/reflections/index.d.ts +2 -0
  68. package/dist/lib/models/reflections/index.js +3 -1
  69. package/dist/lib/models/reflections/kind.d.ts +15 -1
  70. package/dist/lib/models/reflections/kind.js +43 -1
  71. package/dist/lib/models/reflections/parameter.d.ts +3 -1
  72. package/dist/lib/models/reflections/parameter.js +10 -0
  73. package/dist/lib/models/reflections/project.d.ts +32 -5
  74. package/dist/lib/models/reflections/project.js +84 -20
  75. package/dist/lib/models/reflections/reference.d.ts +5 -9
  76. package/dist/lib/models/reflections/reference.js +13 -29
  77. package/dist/lib/models/reflections/signature.d.ts +8 -1
  78. package/dist/lib/models/reflections/signature.js +14 -0
  79. package/dist/lib/models/reflections/type-parameter.d.ts +7 -4
  80. package/dist/lib/models/reflections/type-parameter.js +9 -3
  81. package/dist/lib/models/reflections/variant.d.ts +18 -0
  82. package/dist/lib/models/reflections/variant.js +2 -0
  83. package/dist/lib/models/sources/file.d.ts +2 -0
  84. package/dist/lib/models/sources/file.js +3 -0
  85. package/dist/lib/models/types.d.ts +24 -20
  86. package/dist/lib/models/types.js +132 -33
  87. package/dist/lib/output/plugins/JavascriptIndexPlugin.js +3 -7
  88. package/dist/lib/output/renderer.d.ts +21 -14
  89. package/dist/lib/output/renderer.js +25 -25
  90. package/dist/lib/output/themes/MarkedPlugin.js +2 -3
  91. package/dist/lib/output/themes/default/DefaultTheme.d.ts +2 -20
  92. package/dist/lib/output/themes/default/DefaultTheme.js +4 -75
  93. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +9 -8
  94. package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +54 -0
  95. package/dist/lib/output/themes/default/partials/header.js +2 -5
  96. package/dist/lib/output/themes/default/partials/index.js +2 -2
  97. package/dist/lib/output/themes/default/partials/member.getterSetter.d.ts +2 -2
  98. package/dist/lib/output/themes/default/partials/member.getterSetter.js +4 -1
  99. package/dist/lib/output/themes/default/partials/member.js +1 -1
  100. package/dist/lib/output/themes/default/partials/member.signatures.js +2 -1
  101. package/dist/lib/output/themes/default/partials/members.d.ts +1 -1
  102. package/dist/lib/output/themes/default/partials/members.js +3 -1
  103. package/dist/lib/output/themes/default/partials/navigation.js +6 -4
  104. package/dist/lib/output/themes/default/partials/parameter.js +1 -1
  105. package/dist/lib/output/themes/default/partials/type.js +4 -4
  106. package/dist/lib/output/themes/default/templates/reflection.js +1 -1
  107. package/dist/lib/output/themes/lib.d.ts +1 -0
  108. package/dist/lib/output/themes/lib.js +13 -3
  109. package/dist/lib/serialization/deserializer.d.ts +54 -0
  110. package/dist/lib/serialization/deserializer.js +212 -0
  111. package/dist/lib/serialization/events.d.ts +0 -15
  112. package/dist/lib/serialization/index.d.ts +2 -3
  113. package/dist/lib/serialization/index.js +4 -3
  114. package/dist/lib/serialization/schema.d.ts +23 -17
  115. package/dist/lib/serialization/serializer.d.ts +5 -5
  116. package/dist/lib/serialization/serializer.js +4 -15
  117. package/dist/lib/utils/array.d.ts +0 -1
  118. package/dist/lib/utils/array.js +1 -2
  119. package/dist/lib/utils/entry-point.d.ts +15 -4
  120. package/dist/lib/utils/entry-point.js +45 -28
  121. package/dist/lib/utils/enum.d.ts +4 -1
  122. package/dist/lib/utils/enum.js +2 -3
  123. package/dist/lib/utils/fs.d.ts +3 -1
  124. package/dist/lib/utils/fs.js +36 -73
  125. package/dist/lib/utils/index.d.ts +4 -3
  126. package/dist/lib/utils/index.js +3 -3
  127. package/dist/lib/utils/loggers.d.ts +5 -26
  128. package/dist/lib/utils/loggers.js +38 -42
  129. package/dist/lib/utils/map.d.ts +17 -0
  130. package/dist/lib/utils/map.js +49 -1
  131. package/dist/lib/utils/options/declaration.d.ts +20 -6
  132. package/dist/lib/utils/options/help.js +1 -1
  133. package/dist/lib/utils/options/options.d.ts +27 -18
  134. package/dist/lib/utils/options/options.js +68 -14
  135. package/dist/lib/utils/options/readers/arguments.d.ts +2 -1
  136. package/dist/lib/utils/options/readers/arguments.js +9 -2
  137. package/dist/lib/utils/options/readers/tsconfig.d.ts +3 -7
  138. package/dist/lib/utils/options/readers/tsconfig.js +35 -36
  139. package/dist/lib/utils/options/readers/typedoc.d.ts +4 -5
  140. package/dist/lib/utils/options/readers/typedoc.js +9 -21
  141. package/dist/lib/utils/options/sources/typedoc.js +18 -64
  142. package/dist/lib/utils/package-manifest.d.ts +1 -1
  143. package/dist/lib/utils/package-manifest.js +1 -2
  144. package/dist/lib/utils/paths.d.ts +2 -2
  145. package/dist/lib/utils/paths.js +2 -0
  146. package/dist/lib/utils/plugins.d.ts +1 -2
  147. package/dist/lib/utils/plugins.js +22 -106
  148. package/dist/lib/utils/sort.d.ts +1 -1
  149. package/dist/lib/utils/sort.js +8 -11
  150. package/dist/lib/utils/tsconfig.d.ts +4 -0
  151. package/dist/lib/utils/tsconfig.js +36 -0
  152. package/dist/lib/utils/tsutils.d.ts +3 -2
  153. package/dist/lib/utils/tsutils.js +46 -12
  154. package/dist/lib/validation/documentation.d.ts +1 -1
  155. package/dist/lib/validation/documentation.js +5 -16
  156. package/dist/lib/validation/exports.js +18 -21
  157. package/dist/lib/validation/links.js +1 -1
  158. package/package.json +18 -19
  159. package/static/main.js +0 -54
@@ -33,7 +33,6 @@ exports.JavascriptIndexPlugin = void 0;
33
33
  const Path = __importStar(require("path"));
34
34
  const lunr_1 = require("lunr");
35
35
  const models_1 = require("../../models");
36
- const plugins_1 = require("../../converter/plugins");
37
36
  const components_1 = require("../components");
38
37
  const events_1 = require("../events");
39
38
  const utils_1 = require("../../utils");
@@ -63,7 +62,6 @@ let JavascriptIndexPlugin = class JavascriptIndexPlugin extends components_1.Ren
63
62
  return;
64
63
  }
65
64
  const rows = [];
66
- const kinds = {};
67
65
  const initialSearchResults = Object.values(event.project.reflections).filter((refl) => {
68
66
  return (refl instanceof models_1.DeclarationReflection &&
69
67
  refl.url &&
@@ -93,14 +91,13 @@ let JavascriptIndexPlugin = class JavascriptIndexPlugin extends components_1.Ren
93
91
  if (parent instanceof models_1.ProjectReflection) {
94
92
  parent = undefined;
95
93
  }
96
- if (!kinds[reflection.kind]) {
97
- kinds[reflection.kind] = plugins_1.GroupPlugin.getKindSingular(reflection.kind);
98
- }
99
94
  const row = {
100
95
  kind: reflection.kind,
101
96
  name: reflection.name,
102
97
  url: reflection.url,
103
- classes: reflection.cssClasses,
98
+ classes: this.owner.theme
99
+ .getRenderContext()
100
+ .getReflectionClasses(reflection),
104
101
  };
105
102
  if (parent) {
106
103
  row.parent = parent.getFullName();
@@ -116,7 +113,6 @@ let JavascriptIndexPlugin = class JavascriptIndexPlugin extends components_1.Ren
116
113
  const index = builder.build();
117
114
  const jsonFileName = Path.join(event.outputDirectory, "assets", "search.js");
118
115
  const jsonData = JSON.stringify({
119
- kinds,
120
116
  rows,
121
117
  index,
122
118
  });
@@ -1,5 +1,6 @@
1
1
  import type { Application } from "../application";
2
2
  import type { Theme } from "./theme";
3
+ import { RendererEvent } from "./events";
3
4
  import type { ProjectReflection } from "../models/reflections/project";
4
5
  import { RendererComponent } from "./components";
5
6
  import { ChildableComponent } from "../utils/component";
@@ -89,6 +90,26 @@ export declare class Renderer extends ChildableComponent<Application, RendererCo
89
90
  static readonly EVENT_END = "endRender";
90
91
  /** @event */
91
92
  static readonly EVENT_PREPARE_INDEX = "prepareIndex";
93
+ /**
94
+ * A list of async jobs which must be completed *before* rendering output.
95
+ * They will be called after {@link RendererEvent.BEGIN} has fired, but before any files have been written.
96
+ *
97
+ * This may be used by plugins to register work that must be done to prepare output files. For example: asynchronously
98
+ * transform markdown to HTML.
99
+ *
100
+ * Note: This array is cleared after calling the contained functions on each {@link Renderer.render} call.
101
+ */
102
+ preRenderAsyncJobs: Array<(output: RendererEvent) => Promise<void>>;
103
+ /**
104
+ * A list of async jobs which must be completed after rendering output files but before generation is considered successful.
105
+ * These functions will be called after all documents have been written to the filesystem.
106
+ *
107
+ * This may be used by plugins to register work that must be done to finalize output files. For example: asynchronously
108
+ * generating an image referenced in a render hook.
109
+ *
110
+ * Note: This array is cleared after calling the contained functions on each {@link Renderer.render} call.
111
+ */
112
+ postRenderAsyncJobs: Array<(output: RendererEvent) => Promise<void>>;
92
113
  /**
93
114
  * The theme that is used to render the documentation.
94
115
  */
@@ -122,20 +143,6 @@ export declare class Renderer extends ChildableComponent<Application, RendererCo
122
143
  * @param theme
123
144
  */
124
145
  defineTheme(name: string, theme: new (renderer: Renderer) => Theme): void;
125
- /**
126
- * Adds a new resolver that the theme can use to try to figure out how to link to a symbol
127
- * declared by a third-party library which is not included in the documentation.
128
- * @param packageName the npm package name that this resolver can handle to limit which files it will be tried on.
129
- * If the resolver will create links for Node builtin types, it should be set to `@types/node`.
130
- * Links for builtin types live in the default lib files under `typescript`.
131
- * @param resolver a function that will be called to create links for a given symbol name in the registered path.
132
- * If the provided name is not contained within the docs, should return `undefined`.
133
- * @since 0.22.0
134
- * @deprecated
135
- * Deprecated since v0.23.14, use {@link Converter.addUnknownSymbolResolver | Converter.addUnknownSymbolResolver} instead.
136
- * This signature will be removed in 0.24 or possibly 0.25.
137
- */
138
- addUnknownSymbolResolver(packageName: string, resolver: (name: string) => string | undefined): void;
139
146
  /**
140
147
  * Render the given project reflection to the specified output directory.
141
148
  *
@@ -88,6 +88,26 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
88
88
  this.themes = new Map([
89
89
  ["default", DefaultTheme_1.DefaultTheme],
90
90
  ]);
91
+ /**
92
+ * A list of async jobs which must be completed *before* rendering output.
93
+ * They will be called after {@link RendererEvent.BEGIN} has fired, but before any files have been written.
94
+ *
95
+ * This may be used by plugins to register work that must be done to prepare output files. For example: asynchronously
96
+ * transform markdown to HTML.
97
+ *
98
+ * Note: This array is cleared after calling the contained functions on each {@link Renderer.render} call.
99
+ */
100
+ this.preRenderAsyncJobs = [];
101
+ /**
102
+ * A list of async jobs which must be completed after rendering output files but before generation is considered successful.
103
+ * These functions will be called after all documents have been written to the filesystem.
104
+ *
105
+ * This may be used by plugins to register work that must be done to finalize output files. For example: asynchronously
106
+ * generating an image referenced in a render hook.
107
+ *
108
+ * Note: This array is cleared after calling the contained functions on each {@link Renderer.render} call.
109
+ */
110
+ this.postRenderAsyncJobs = [];
91
111
  /**
92
112
  * Hooks which will be called when rendering pages.
93
113
  * Note:
@@ -111,29 +131,6 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
111
131
  }
112
132
  this.themes.set(name, theme);
113
133
  }
114
- /**
115
- * Adds a new resolver that the theme can use to try to figure out how to link to a symbol
116
- * declared by a third-party library which is not included in the documentation.
117
- * @param packageName the npm package name that this resolver can handle to limit which files it will be tried on.
118
- * If the resolver will create links for Node builtin types, it should be set to `@types/node`.
119
- * Links for builtin types live in the default lib files under `typescript`.
120
- * @param resolver a function that will be called to create links for a given symbol name in the registered path.
121
- * If the provided name is not contained within the docs, should return `undefined`.
122
- * @since 0.22.0
123
- * @deprecated
124
- * Deprecated since v0.23.14, use {@link Converter.addUnknownSymbolResolver | Converter.addUnknownSymbolResolver} instead.
125
- * This signature will be removed in 0.24 or possibly 0.25.
126
- */
127
- addUnknownSymbolResolver(packageName, resolver) {
128
- this.owner.converter.addUnknownSymbolResolver((ref) => {
129
- const path = ref.symbolReference?.path
130
- ?.map((path) => path.path)
131
- .join(".");
132
- if (ref.moduleSource === packageName && path) {
133
- return resolver(path);
134
- }
135
- });
136
- }
137
134
  /**
138
135
  * Render the given project reflection to the specified output directory.
139
136
  *
@@ -152,12 +149,17 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
152
149
  const output = new events_1.RendererEvent(events_1.RendererEvent.BEGIN, outputDirectory, project);
153
150
  output.urls = this.theme.getUrls(project);
154
151
  this.trigger(output);
152
+ await Promise.all(this.preRenderAsyncJobs.map((job) => job(output)));
153
+ this.preRenderAsyncJobs = [];
155
154
  if (!output.isDefaultPrevented) {
155
+ this.application.logger.verbose(`There are ${output.urls.length} pages to write.`);
156
156
  output.urls.forEach((mapping) => {
157
157
  (0, icon_1.clearSeenIconCache)();
158
158
  this.renderDocument(output.createPageEvent(mapping));
159
159
  (0, type_1.validateStateIsClean)(mapping.url);
160
160
  });
161
+ await Promise.all(this.postRenderAsyncJobs.map((job) => job(output)));
162
+ this.postRenderAsyncJobs = [];
161
163
  this.trigger(events_1.RendererEvent.END, output);
162
164
  }
163
165
  this.theme = void 0;
@@ -192,9 +194,7 @@ let Renderer = class Renderer extends component_1.ChildableComponent {
192
194
  }
193
195
  catch (error) {
194
196
  this.application.logger.error(`Could not write ${page.filename}`);
195
- return false;
196
197
  }
197
- return true;
198
198
  }
199
199
  /**
200
200
  * Ensure that a theme has been setup.
@@ -102,7 +102,7 @@ output file :
102
102
  if (this.includes) {
103
103
  text = text.replace(this.includePattern, (_match, path) => {
104
104
  path = Path.join(this.includes, path.trim());
105
- if (fs.existsSync(path) && fs.statSync(path).isFile()) {
105
+ if ((0, utils_1.isFile)(path)) {
106
106
  const contents = (0, utils_1.readFile)(path);
107
107
  return contents;
108
108
  }
@@ -115,8 +115,7 @@ output file :
115
115
  if (this.mediaDirectory) {
116
116
  text = text.replace(this.mediaPattern, (match, path) => {
117
117
  const fileName = Path.join(this.mediaDirectory, path);
118
- if (fs.existsSync(fileName) &&
119
- fs.statSync(fileName).isFile()) {
118
+ if ((0, utils_1.isFile)(fileName)) {
120
119
  return this.getRelativeUrl("media") + "/" + path;
121
120
  }
122
121
  else {
@@ -2,7 +2,7 @@ import { Theme } from "../../theme";
2
2
  import type { Renderer } from "../../renderer";
3
3
  import { Reflection, ProjectReflection, ContainerReflection, DeclarationReflection } from "../../../models";
4
4
  import { UrlMapping } from "../../models/UrlMapping";
5
- import { PageEvent } from "../../events";
5
+ import type { PageEvent } from "../../events";
6
6
  import type { MarkedPlugin } from "../../plugins";
7
7
  import { DefaultThemeRenderContext } from "./DefaultThemeRenderContext";
8
8
  import { JSX } from "../../../utils";
@@ -14,7 +14,7 @@ export declare class DefaultTheme extends Theme {
14
14
  /** @internal */
15
15
  markedPlugin: MarkedPlugin;
16
16
  private _renderContext?;
17
- getRenderContext(_pageEvent: PageEvent<any>): DefaultThemeRenderContext;
17
+ getRenderContext(): DefaultThemeRenderContext;
18
18
  reflectionTemplate: (pageEvent: PageEvent<ContainerReflection>) => JSX.Element;
19
19
  indexTemplate: (pageEvent: PageEvent<ProjectReflection>) => JSX.Element;
20
20
  defaultLayoutTemplate: (pageEvent: PageEvent<Reflection>) => JSX.Element;
@@ -38,12 +38,6 @@ export declare class DefaultTheme extends Theme {
38
38
  * should be rendered to which files.
39
39
  */
40
40
  getUrls(project: ProjectReflection): UrlMapping[];
41
- /**
42
- * Triggered before the renderer starts rendering a project.
43
- *
44
- * @param event An event object describing the current render operation.
45
- */
46
- private onRendererBegin;
47
41
  /**
48
42
  * Return a url for the given reflection.
49
43
  *
@@ -76,16 +70,4 @@ export declare class DefaultTheme extends Theme {
76
70
  * @param container The nearest reflection having an own document.
77
71
  */
78
72
  static applyAnchorUrl(reflection: Reflection, container: Reflection): void;
79
- /**
80
- * Generate the css classes for the given reflection and apply them to the
81
- * {@link DeclarationReflection.cssClasses} property.
82
- *
83
- * @param reflection The reflection whose cssClasses property should be generated.
84
- */
85
- static applyReflectionClasses(reflection: DeclarationReflection, filters: Record<string, boolean>): void;
86
- /**
87
- * Transform a space separated string into a string suitable to be used as a
88
- * css class, e.g. "constructor method" > "constructor-method".
89
- */
90
- static toStyleClass(str: string): string;
91
73
  }
@@ -4,7 +4,6 @@ exports.DefaultTheme = void 0;
4
4
  const theme_1 = require("../../theme");
5
5
  const models_1 = require("../../../models");
6
6
  const UrlMapping_1 = require("../../models/UrlMapping");
7
- const events_1 = require("../../events");
8
7
  const DefaultThemeRenderContext_1 = require("./DefaultThemeRenderContext");
9
8
  const utils_1 = require("../../../utils");
10
9
  /**
@@ -12,7 +11,7 @@ const utils_1 = require("../../../utils");
12
11
  * {@link Theme} implementation, this theme class will be used.
13
12
  */
14
13
  class DefaultTheme extends theme_1.Theme {
15
- getRenderContext(_pageEvent) {
14
+ getRenderContext() {
16
15
  if (!this._renderContext) {
17
16
  this._renderContext = new DefaultThemeRenderContext_1.DefaultThemeRenderContext(this, this.application.options);
18
17
  }
@@ -27,13 +26,13 @@ class DefaultTheme extends theme_1.Theme {
27
26
  constructor(renderer) {
28
27
  super(renderer);
29
28
  this.reflectionTemplate = (pageEvent) => {
30
- return this.getRenderContext(pageEvent).reflectionTemplate(pageEvent);
29
+ return this.getRenderContext().reflectionTemplate(pageEvent);
31
30
  };
32
31
  this.indexTemplate = (pageEvent) => {
33
- return this.getRenderContext(pageEvent).indexTemplate(pageEvent);
32
+ return this.getRenderContext().indexTemplate(pageEvent);
34
33
  };
35
34
  this.defaultLayoutTemplate = (pageEvent) => {
36
- return this.getRenderContext(pageEvent).defaultLayout(pageEvent);
35
+ return this.getRenderContext().defaultLayout(pageEvent);
37
36
  };
38
37
  /**
39
38
  * Mappings of reflections kinds to templates used by this theme.
@@ -76,7 +75,6 @@ class DefaultTheme extends theme_1.Theme {
76
75
  },
77
76
  ];
78
77
  this.markedPlugin = renderer.getComponent("marked");
79
- this.listenTo(renderer, events_1.RendererEvent.BEGIN, this.onRendererBegin, 1024);
80
78
  }
81
79
  /**
82
80
  * Map the models of the given project to the desired output files.
@@ -103,19 +101,6 @@ class DefaultTheme extends theme_1.Theme {
103
101
  });
104
102
  return urls;
105
103
  }
106
- /**
107
- * Triggered before the renderer starts rendering a project.
108
- *
109
- * @param event An event object describing the current render operation.
110
- */
111
- onRendererBegin(event) {
112
- const filters = this.application.options.getValue("visibilityFilters");
113
- for (const reflection of Object.values(event.project.reflections)) {
114
- if (reflection instanceof models_1.DeclarationReflection) {
115
- DefaultTheme.applyReflectionClasses(reflection, filters);
116
- }
117
- }
118
- }
119
104
  /**
120
105
  * Return a url for the given reflection.
121
106
  *
@@ -196,62 +181,6 @@ class DefaultTheme extends theme_1.Theme {
196
181
  return true;
197
182
  });
198
183
  }
199
- /**
200
- * Generate the css classes for the given reflection and apply them to the
201
- * {@link DeclarationReflection.cssClasses} property.
202
- *
203
- * @param reflection The reflection whose cssClasses property should be generated.
204
- */
205
- static applyReflectionClasses(reflection, filters) {
206
- const classes = [];
207
- classes.push(DefaultTheme.toStyleClass("tsd-kind-" + models_1.ReflectionKind[reflection.kind]));
208
- if (reflection.parent && reflection.parent instanceof models_1.DeclarationReflection) {
209
- classes.push(DefaultTheme.toStyleClass(`tsd-parent-kind-${models_1.ReflectionKind[reflection.parent.kind]}`));
210
- }
211
- // Filter classes should match up with the settings function in
212
- // partials/navigation.tsx.
213
- for (const key of Object.keys(filters)) {
214
- if (key === "inherited") {
215
- if (reflection.inheritedFrom) {
216
- classes.push("tsd-is-inherited");
217
- }
218
- }
219
- else if (key === "protected") {
220
- if (reflection.flags.isProtected) {
221
- classes.push("tsd-is-protected");
222
- }
223
- }
224
- else if (key === "private") {
225
- if (reflection.flags.isPrivate) {
226
- classes.push("tsd-is-private");
227
- }
228
- }
229
- else if (key === "external") {
230
- if (reflection.flags.isExternal) {
231
- classes.push("tsd-is-external");
232
- }
233
- }
234
- else if (key.startsWith("@")) {
235
- if (key === "@deprecated") {
236
- if (reflection.isDeprecated()) {
237
- classes.push(DefaultTheme.toStyleClass(`tsd-is-${key.substring(1)}`));
238
- }
239
- }
240
- else if (reflection.comment?.hasModifier(key) ||
241
- reflection.comment?.getTag(key)) {
242
- classes.push(DefaultTheme.toStyleClass(`tsd-is-${key.substring(1)}`));
243
- }
244
- }
245
- }
246
- reflection.cssClasses = classes.join(" ");
247
- }
248
- /**
249
- * Transform a space separated string into a string suitable to be used as a
250
- * css class, e.g. "constructor method" > "constructor-method".
251
- */
252
- static toStyleClass(str) {
253
- return str.replace(/(\w)([A-Z])/g, (_m, m1, m2) => m1 + "-" + m2).toLowerCase();
254
- }
255
184
  }
256
185
  exports.DefaultTheme = DefaultTheme;
257
186
  DefaultTheme.URL_PREFIX = /^(http|ftp)s?:\/\//;
@@ -1,12 +1,12 @@
1
1
  import type { RendererHooks } from "../..";
2
- import type { CommentDisplayPart, ReferenceType, Reflection } from "../../../models";
2
+ import { CommentDisplayPart, DeclarationReflection, ReferenceType, Reflection, ReflectionKind } from "../../../models";
3
3
  import type { NeverIfInternal, Options } from "../../../utils";
4
4
  import type { DefaultTheme } from "./DefaultTheme";
5
5
  export declare class DefaultThemeRenderContext {
6
6
  private theme;
7
7
  options: Options;
8
8
  constructor(theme: DefaultTheme, options: Options);
9
- icons: Record<"anchor" | import("../../../models").ReflectionKind | "search" | "checkbox" | "chevronDown" | "menu" | "chevronSmall", () => import("../../../utils/jsx.elements").JsxElement>;
9
+ icons: Record<"search" | "anchor" | ReflectionKind | "checkbox" | "chevronDown" | "menu" | "chevronSmall", () => import("../../../utils/jsx.elements").JsxElement>;
10
10
  hook: (name: keyof RendererHooks) => import("../../../utils/jsx.elements").JsxElement[];
11
11
  /** Avoid this in favor of urlTo if possible */
12
12
  relativeURL: (url: string | undefined) => string | undefined;
@@ -18,6 +18,7 @@ export declare class DefaultThemeRenderContext {
18
18
  * Will be removed in 0.24.
19
19
  */
20
20
  attemptExternalResolution: (type: NeverIfInternal<ReferenceType>) => string | undefined;
21
+ getReflectionClasses: (reflection: DeclarationReflection) => string;
21
22
  reflectionTemplate: (props: import("../..").PageEvent<import("../../../models").ContainerReflection>) => import("../../../utils/jsx.elements").JsxElement;
22
23
  indexTemplate: (props: import("../..").PageEvent<import("../../../models").ProjectReflection>) => import("../../../utils/jsx.elements").JsxElement;
23
24
  defaultLayout: (props: import("../..").PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement;
@@ -28,9 +29,9 @@ export declare class DefaultThemeRenderContext {
28
29
  header: (props: import("../..").PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement;
29
30
  hierarchy: (props: import("../../../models").DeclarationHierarchy | undefined) => import("../../../utils/jsx.elements").JsxElement | undefined;
30
31
  index: (props: import("../../../models").ContainerReflection) => import("../../../utils/jsx.elements").JsxElement;
31
- member: (props: import("../../../models").DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement;
32
- memberDeclaration: (props: import("../../../models").DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement;
33
- memberGetterSetter: (props: import("../../../models").DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement;
32
+ member: (props: DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement;
33
+ memberDeclaration: (props: DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement;
34
+ memberGetterSetter: (props: DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement;
34
35
  memberReference: (props: import("../../../models").ReferenceReflection) => import("../../../utils/jsx.elements").JsxElement;
35
36
  memberSignatureBody: (r_0: import("../../../models").SignatureReflection, r_1?: {
36
37
  hideSources?: boolean | undefined;
@@ -39,8 +40,8 @@ export declare class DefaultThemeRenderContext {
39
40
  hideName?: boolean | undefined;
40
41
  arrowStyle?: boolean | undefined;
41
42
  } | undefined) => import("../../../utils/jsx.elements").JsxElement;
42
- memberSignatures: (props: import("../../../models").DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement;
43
- memberSources: (props: import("../../../models").SignatureReflection | import("../../../models").DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement;
43
+ memberSignatures: (props: DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement;
44
+ memberSources: (props: import("../../../models").SignatureReflection | DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement;
44
45
  members: (props: import("../../../models").ContainerReflection) => import("../../../utils/jsx.elements").JsxElement;
45
46
  membersGroup: (group: import("../../../models").ReflectionGroup) => import("../../../utils/jsx.elements").JsxElement;
46
47
  navigation: (props: import("../..").PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement;
@@ -48,7 +49,7 @@ export declare class DefaultThemeRenderContext {
48
49
  settings: () => import("../../../utils/jsx.elements").JsxElement;
49
50
  primaryNavigation: (props: import("../..").PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement;
50
51
  secondaryNavigation: (props: import("../..").PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement | undefined;
51
- parameter: (props: import("../../../models").DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement;
52
+ parameter: (props: DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement;
52
53
  toolbar: (props: import("../..").PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement;
53
54
  type: (type: import("../../../models").Type | undefined) => import("../../../utils/jsx.elements").JsxElement;
54
55
  typeAndParent: (props: import("../../../models").Type) => import("../../../utils/jsx.elements").JsxElement;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DefaultThemeRenderContext = void 0;
4
+ const models_1 = require("../../../models");
4
5
  const lib_1 = require("../lib");
5
6
  const default_1 = require("./layouts/default");
6
7
  const partials_1 = require("./partials");
@@ -56,6 +57,10 @@ class DefaultThemeRenderContext {
56
57
  this.attemptExternalResolution = (type) => {
57
58
  return type.externalUrl;
58
59
  };
60
+ this.getReflectionClasses = (reflection) => {
61
+ const filters = this.options.getValue("visibilityFilters");
62
+ return getReflectionClasses(reflection, filters);
63
+ };
59
64
  this.reflectionTemplate = bind(reflection_1.reflectionTemplate, this);
60
65
  this.indexTemplate = bind(templates_1.indexTemplate, this);
61
66
  this.defaultLayout = bind(default_1.defaultLayout, this);
@@ -90,3 +95,52 @@ class DefaultThemeRenderContext {
90
95
  }
91
96
  }
92
97
  exports.DefaultThemeRenderContext = DefaultThemeRenderContext;
98
+ function getReflectionClasses(reflection, filters) {
99
+ const classes = [];
100
+ classes.push(toStyleClass("tsd-kind-" + models_1.ReflectionKind[reflection.kind]));
101
+ if (reflection.parent &&
102
+ reflection.parent instanceof models_1.DeclarationReflection) {
103
+ classes.push(toStyleClass(`tsd-parent-kind-${models_1.ReflectionKind[reflection.parent.kind]}`));
104
+ }
105
+ // Filter classes should match up with the settings function in
106
+ // partials/navigation.tsx.
107
+ for (const key of Object.keys(filters)) {
108
+ if (key === "inherited") {
109
+ if (reflection.inheritedFrom) {
110
+ classes.push("tsd-is-inherited");
111
+ }
112
+ }
113
+ else if (key === "protected") {
114
+ if (reflection.flags.isProtected) {
115
+ classes.push("tsd-is-protected");
116
+ }
117
+ }
118
+ else if (key === "private") {
119
+ if (reflection.flags.isPrivate) {
120
+ classes.push("tsd-is-private");
121
+ }
122
+ }
123
+ else if (key === "external") {
124
+ if (reflection.flags.isExternal) {
125
+ classes.push("tsd-is-external");
126
+ }
127
+ }
128
+ else if (key.startsWith("@")) {
129
+ if (key === "@deprecated") {
130
+ if (reflection.isDeprecated()) {
131
+ classes.push(toStyleClass(`tsd-is-${key.substring(1)}`));
132
+ }
133
+ }
134
+ else if (reflection.comment?.hasModifier(key) ||
135
+ reflection.comment?.getTag(key)) {
136
+ classes.push(toStyleClass(`tsd-is-${key.substring(1)}`));
137
+ }
138
+ }
139
+ }
140
+ return classes.join(" ");
141
+ }
142
+ function toStyleClass(str) {
143
+ return str
144
+ .replace(/(\w)([A-Z])/g, (_m, m1, m2) => m1 + "-" + m2)
145
+ .toLowerCase();
146
+ }
@@ -9,11 +9,8 @@ const header = (context, props) => {
9
9
  return (utils_1.JSX.createElement("div", { class: "tsd-page-title" },
10
10
  !!props.model.parent && utils_1.JSX.createElement("ul", { class: "tsd-breadcrumb" }, context.breadcrumb(props.model)),
11
11
  utils_1.JSX.createElement(HeadingLevel, null,
12
- props.model.kind !== models_1.ReflectionKind.Project && `${props.model.kindString ?? ""} `,
13
- props.model.name,
14
- props.model instanceof models_1.DeclarationReflection &&
15
- props.model.version !== undefined &&
16
- ` - v${props.model.version}`,
12
+ props.model.kind !== models_1.ReflectionKind.Project && `${models_1.ReflectionKind.singularString(props.model.kind)} `,
13
+ (0, lib_1.getDisplayName)(context, props.model),
17
14
  (0, lib_1.hasTypeParameters)(props.model) && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
18
15
  "<",
19
16
  (0, lib_1.join)(", ", props.model.typeParameters, (item) => item.name),
@@ -4,11 +4,11 @@ exports.index = void 0;
4
4
  const lib_1 = require("../../lib");
5
5
  const utils_1 = require("../../../../utils");
6
6
  const models_1 = require("../../../../models");
7
- function renderCategory({ urlTo, icons }, item, prependName = "") {
7
+ function renderCategory({ urlTo, icons, getReflectionClasses }, 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
- utils_1.JSX.createElement("a", { href: urlTo(item), class: (0, lib_1.classNames)({ "tsd-index-link": true, deprecated: item.isDeprecated() }, item.cssClasses) },
11
+ utils_1.JSX.createElement("a", { href: urlTo(item), class: (0, lib_1.classNames)({ "tsd-index-link": true, deprecated: item.isDeprecated() }, getReflectionClasses(item)) },
12
12
  icons[item.kind](),
13
13
  utils_1.JSX.createElement("span", null, (0, lib_1.renderName)(item))),
14
14
  "\n"))))));
@@ -1,4 +1,4 @@
1
- import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
2
- import { JSX } from "../../../../utils";
3
1
  import type { DeclarationReflection } from "../../../../models";
2
+ import { JSX } from "../../../../utils";
3
+ import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
4
4
  export declare const memberGetterSetter: (context: DefaultThemeRenderContext, props: DeclarationReflection) => JSX.Element;
@@ -2,8 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.memberGetterSetter = void 0;
4
4
  const utils_1 = require("../../../../utils");
5
+ const lib_1 = require("../../lib");
5
6
  const memberGetterSetter = (context, props) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
6
- utils_1.JSX.createElement("ul", { class: "tsd-signatures " + props.cssClasses },
7
+ utils_1.JSX.createElement("ul", { class: (0, lib_1.classNames)({
8
+ "tsd-signatures": true,
9
+ }, context.getReflectionClasses(props)) },
7
10
  !!props.getSignature && (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
8
11
  utils_1.JSX.createElement("li", { class: "tsd-signature", id: props.getSignature.anchor },
9
12
  utils_1.JSX.createElement("span", { class: "tsd-signature-symbol" }, "get"),
@@ -5,7 +5,7 @@ const lib_1 = require("../../lib");
5
5
  const utils_1 = require("../../../../utils");
6
6
  const models_1 = require("../../../../models");
7
7
  const anchor_icon_1 = require("./anchor-icon");
8
- const member = (context, props) => (utils_1.JSX.createElement("section", { class: "tsd-panel tsd-member " + props.cssClasses },
8
+ const member = (context, props) => (utils_1.JSX.createElement("section", { class: (0, lib_1.classNames)({ "tsd-panel": true, "tsd-member": true }, context.getReflectionClasses(props)) },
9
9
  utils_1.JSX.createElement("a", { id: props.anchor, class: "tsd-anchor" }),
10
10
  !!props.name && (utils_1.JSX.createElement("h3", { class: "tsd-anchor-link" },
11
11
  (0, lib_1.renderFlags)(props.flags, props.comment),
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.memberSignatures = void 0;
4
4
  const utils_1 = require("../../../../utils");
5
5
  const anchor_icon_1 = require("./anchor-icon");
6
+ const lib_1 = require("../../lib");
6
7
  const memberSignatures = (context, props) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
7
- utils_1.JSX.createElement("ul", { class: "tsd-signatures " + props.cssClasses }, props.signatures?.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
8
+ utils_1.JSX.createElement("ul", { class: (0, lib_1.classNames)({ "tsd-signatures": true }, context.getReflectionClasses(props)) }, props.signatures?.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
8
9
  utils_1.JSX.createElement("li", { class: "tsd-signature tsd-anchor-link", id: item.anchor },
9
10
  context.memberSignatureTitle(item),
10
11
  (0, anchor_icon_1.anchorIcon)(context, item.anchor)),
@@ -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 members(context: DefaultThemeRenderContext, props: ContainerReflection): JSX.Element;
@@ -2,9 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.members = void 0;
4
4
  const utils_1 = require("../../../../utils");
5
+ const models_1 = require("../../../../models");
6
+ const lib_1 = require("../../lib");
5
7
  function members(context, props) {
6
8
  if (props.categories && props.categories.length) {
7
- return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, props.categories.map((item) => !item.allChildrenHaveOwnDocument() && (utils_1.JSX.createElement("section", { class: "tsd-panel-group tsd-member-group " + props.cssClasses },
9
+ return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, props.categories.map((item) => !item.allChildrenHaveOwnDocument() && (utils_1.JSX.createElement("section", { class: (0, lib_1.classNames)({ "tsd-panel-group": true, "tsd-member-group": true }, props instanceof models_1.DeclarationReflection ? context.getReflectionClasses(props) : "") },
8
10
  utils_1.JSX.createElement("h2", null, item.title),
9
11
  item.children.map((item) => !item.hasOwnDocument && context.member(item)))))));
10
12
  }
@@ -90,8 +90,8 @@ function primaryNavigation(context, props) {
90
90
  if (childModules?.length) {
91
91
  childNav = utils_1.JSX.createElement("ul", null, childModules.map(link));
92
92
  }
93
- return (utils_1.JSX.createElement("li", { class: (0, lib_1.classNames)({ current, selected, deprecated: mod.isDeprecated() }, mod.cssClasses) },
94
- utils_1.JSX.createElement("a", { href: context.urlTo(mod) }, (0, lib_1.wbr)(`${mod.name}${mod.version !== undefined ? ` - v${mod.version}` : ""}`)),
93
+ return (utils_1.JSX.createElement("li", { class: (0, lib_1.classNames)({ current, selected, deprecated: mod.isDeprecated() }, context.getReflectionClasses(mod)) },
94
+ utils_1.JSX.createElement("a", { href: context.urlTo(mod) }, (0, lib_1.wbr)((0, lib_1.getDisplayName)(context, mod))),
95
95
  childNav));
96
96
  }
97
97
  }
@@ -108,7 +108,7 @@ function secondaryNavigation(context, props) {
108
108
  const pageNavigation = children
109
109
  .filter((child) => !child.kindOf(models_1.ReflectionKind.SomeModule))
110
110
  .map((child) => {
111
- return (utils_1.JSX.createElement("li", { class: (0, lib_1.classNames)({ deprecated: child.isDeprecated(), current: props.model === child }, child.cssClasses) },
111
+ return (utils_1.JSX.createElement("li", { class: (0, lib_1.classNames)({ deprecated: child.isDeprecated(), current: props.model === child }, context.getReflectionClasses(child)) },
112
112
  utils_1.JSX.createElement("a", { href: context.urlTo(child), class: "tsd-index-link" },
113
113
  context.icons[child.kind](),
114
114
  (0, lib_1.renderName)(child))));
@@ -121,7 +121,9 @@ function secondaryNavigation(context, props) {
121
121
  utils_1.JSX.createElement("li", { class: (0, lib_1.classNames)({
122
122
  deprecated: effectivePageParent.isDeprecated(),
123
123
  current: effectivePageParent === props.model,
124
- }, effectivePageParent.cssClasses) },
124
+ }, effectivePageParent instanceof models_1.DeclarationReflection
125
+ ? context.getReflectionClasses(effectivePageParent)
126
+ : "") },
125
127
  utils_1.JSX.createElement("a", { href: context.urlTo(effectivePageParent), class: "tsd-index-link" },
126
128
  context.icons[effectivePageParent.kind](),
127
129
  utils_1.JSX.createElement("span", null, (0, lib_1.renderName)(effectivePageParent))),
@@ -7,7 +7,7 @@ const models_1 = require("../../../../models");
7
7
  const parameter = (context, props) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
8
8
  utils_1.JSX.createElement("ul", { class: "tsd-parameters" },
9
9
  !!props.signatures && (utils_1.JSX.createElement("li", { class: "tsd-parameter-signature" },
10
- utils_1.JSX.createElement("ul", { class: "tsd-signatures " + props.cssClasses }, props.signatures.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
10
+ utils_1.JSX.createElement("ul", { class: (0, lib_1.classNames)({ "tsd-signatures": true }, context.getReflectionClasses(props)) }, props.signatures.map((item) => (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
11
11
  utils_1.JSX.createElement("li", { class: "tsd-signature", id: item.anchor }, context.memberSignatureTitle(item, {
12
12
  hideName: true,
13
13
  })),