typedoc 0.26.2 → 0.26.4

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 (39) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/lib/application.js +1 -1
  3. package/dist/lib/converter/comments/textParser.js +12 -6
  4. package/dist/lib/converter/plugins/CommentPlugin.js +2 -4
  5. package/dist/lib/converter/plugins/LinkResolverPlugin.js +5 -3
  6. package/dist/lib/internationalization/locales/jp.cjs +2 -2
  7. package/dist/lib/internationalization/locales/jp.d.cts +1 -320
  8. package/dist/lib/internationalization/locales/ko.d.cts +1 -230
  9. package/dist/lib/internationalization/locales/zh.cjs +2 -2
  10. package/dist/lib/internationalization/locales/zh.d.cts +1 -320
  11. package/dist/lib/internationalization/translatable.d.ts +6 -4
  12. package/dist/lib/internationalization/translatable.js +4 -2
  13. package/dist/lib/models/FileRegistry.js +6 -4
  14. package/dist/lib/output/events.d.ts +20 -7
  15. package/dist/lib/output/events.js +20 -0
  16. package/dist/lib/output/index.d.ts +1 -1
  17. package/dist/lib/output/themes/default/DefaultTheme.js +25 -16
  18. package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +3 -2
  19. package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +0 -2
  20. package/dist/lib/output/themes/default/partials/member.reference.d.ts +1 -1
  21. package/dist/lib/output/themes/default/partials/member.reference.js +10 -4
  22. package/dist/lib/output/themes/default/partials/members.d.ts +1 -1
  23. package/dist/lib/output/themes/default/partials/members.js +39 -9
  24. package/dist/lib/output/themes/default/partials/navigation.js +27 -7
  25. package/dist/lib/utils/array.d.ts +1 -1
  26. package/dist/lib/utils/array.js +1 -1
  27. package/dist/lib/utils/enum.d.ts +3 -3
  28. package/dist/lib/utils/minimalSourceFile.d.ts +1 -1
  29. package/dist/lib/utils/minimalSourceFile.js +9 -1
  30. package/dist/lib/utils/options/declaration.d.ts +1 -1
  31. package/dist/lib/utils/options/tsdoc-defaults.d.ts +1 -1
  32. package/dist/lib/utils/options/tsdoc-defaults.js +2 -1
  33. package/dist/lib/validation/links.js +45 -27
  34. package/package.json +7 -7
  35. package/static/main.js +4 -4
  36. package/static/style.css +10 -0
  37. package/tsdoc.json +4 -0
  38. package/dist/lib/output/themes/default/partials/members.group.d.ts +0 -4
  39. package/dist/lib/output/themes/default/partials/members.group.js +0 -25
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ValidatingFileRegistry = exports.FileRegistry = void 0;
4
4
  const path_1 = require("path");
5
5
  const utils_1 = require("../utils");
6
- const fs_1 = require("fs");
7
6
  class FileRegistry {
8
7
  constructor() {
9
8
  this.nextId = 1;
@@ -50,6 +49,9 @@ class FileRegistry {
50
49
  const absolute = this.mediaToPath.get(id);
51
50
  if (!absolute)
52
51
  return;
52
+ if (this.names.has(id)) {
53
+ return this.names.get(id);
54
+ }
53
55
  const file = (0, path_1.basename)(absolute);
54
56
  if (!this.nameUsage.has(file)) {
55
57
  this.nameUsage.set(file, 1);
@@ -111,7 +113,7 @@ exports.FileRegistry = FileRegistry;
111
113
  class ValidatingFileRegistry extends FileRegistry {
112
114
  register(sourcePath, relativePath) {
113
115
  const absolute = (0, path_1.resolve)((0, path_1.dirname)(sourcePath), relativePath);
114
- if (!(0, fs_1.existsSync)(absolute)) {
116
+ if (!(0, utils_1.isFile)(absolute)) {
115
117
  return;
116
118
  }
117
119
  return this.registerAbsolute(absolute);
@@ -119,8 +121,8 @@ class ValidatingFileRegistry extends FileRegistry {
119
121
  fromObject(de, obj) {
120
122
  for (const [key, val] of Object.entries(obj.entries)) {
121
123
  const absolute = (0, utils_1.normalizePath)((0, path_1.resolve)(de.projectRoot, val));
122
- if (!(0, fs_1.existsSync)(absolute)) {
123
- de.logger.warn(de.logger.i18n.saved_relative_path_0_resolved_from_1_does_not_exist(val, de.projectRoot));
124
+ if (!(0, utils_1.isFile)(absolute)) {
125
+ de.logger.warn(de.logger.i18n.saved_relative_path_0_resolved_from_1_is_not_a_file(val, de.projectRoot));
124
126
  continue;
125
127
  }
126
128
  de.oldFileIdToNewFileId[+key] = this.registerAbsolute(absolute);
@@ -43,6 +43,13 @@ export declare class RendererEvent {
43
43
  */
44
44
  createPageEvent<Model>(mapping: UrlMapping<Model>): [RenderTemplate<PageEvent<Model>>, PageEvent<Model>];
45
45
  }
46
+ export interface PageHeading {
47
+ link: string;
48
+ text: string;
49
+ level?: number;
50
+ kind?: ReflectionKind;
51
+ classes?: string;
52
+ }
46
53
  /**
47
54
  * An event emitted by the {@link Renderer} class before and after the
48
55
  * markup of a page is rendered.
@@ -77,13 +84,19 @@ export declare class PageEvent<out Model = unknown> extends Event {
77
84
  * Links to content within this page that should be rendered in the page navigation.
78
85
  * This is built when rendering the document content.
79
86
  */
80
- pageHeadings: Array<{
81
- link: string;
82
- text: string;
83
- level?: number;
84
- kind?: ReflectionKind;
85
- classes?: string;
86
- }>;
87
+ pageHeadings: PageHeading[];
88
+ /**
89
+ * Sections of the page, generally set by `@group`s
90
+ */
91
+ pageSections: {
92
+ title: string;
93
+ headings: PageHeading[];
94
+ }[];
95
+ /**
96
+ * Start a new section of the page. Sections are collapsible within
97
+ * the "On This Page" sidebar.
98
+ */
99
+ startNewSection(title: string): void;
87
100
  /**
88
101
  * Triggered before a document will be rendered.
89
102
  * @event
@@ -71,6 +71,17 @@ RendererEvent.END = "endRender";
71
71
  * @see {@link Renderer.EVENT_END_PAGE}
72
72
  */
73
73
  class PageEvent extends Event {
74
+ /**
75
+ * Start a new section of the page. Sections are collapsible within
76
+ * the "On This Page" sidebar.
77
+ */
78
+ startNewSection(title) {
79
+ this.pageHeadings = [];
80
+ this.pageSections.push({
81
+ title,
82
+ headings: this.pageHeadings,
83
+ });
84
+ }
74
85
  constructor(name, model) {
75
86
  super(name);
76
87
  /**
@@ -78,6 +89,15 @@ class PageEvent extends Event {
78
89
  * This is built when rendering the document content.
79
90
  */
80
91
  this.pageHeadings = [];
92
+ /**
93
+ * Sections of the page, generally set by `@group`s
94
+ */
95
+ this.pageSections = [
96
+ {
97
+ title: "",
98
+ headings: this.pageHeadings,
99
+ },
100
+ ];
81
101
  this.model = model;
82
102
  }
83
103
  }
@@ -1,4 +1,4 @@
1
- export { PageEvent, RendererEvent, MarkdownEvent, IndexEvent } from "./events";
1
+ export { PageEvent, RendererEvent, MarkdownEvent, IndexEvent, type PageHeading, } from "./events";
2
2
  export { UrlMapping } from "./models/UrlMapping";
3
3
  export type { RenderTemplate } from "./models/UrlMapping";
4
4
  export { Renderer, type RendererEvents } from "./renderer";
@@ -228,7 +228,7 @@ class DefaultTheme extends theme_1.Theme {
228
228
  }
229
229
  render(page, template) {
230
230
  const templateOutput = this.defaultLayoutTemplate(page, template);
231
- return "<!DOCTYPE html>" + utils_1.JSX.renderElement(templateOutput);
231
+ return "<!DOCTYPE html>" + utils_1.JSX.renderElement(templateOutput) + "\n";
232
232
  }
233
233
  /**
234
234
  * If implementing a custom theme, it is recommended to override {@link buildNavigation} instead.
@@ -248,29 +248,36 @@ class DefaultTheme extends theme_1.Theme {
248
248
  const leaves = this.application.options.getValue("navigationLeaves");
249
249
  return getNavigationElements(project) || [];
250
250
  function toNavigation(element) {
251
+ const children = getNavigationElements(element);
251
252
  if (element instanceof models_1.ReflectionCategory || element instanceof models_1.ReflectionGroup) {
253
+ if (!children?.length) {
254
+ return;
255
+ }
252
256
  return {
253
257
  text: element.title,
254
- children: getNavigationElements(element),
258
+ children,
255
259
  };
256
260
  }
261
+ if (!element.hasOwnDocument) {
262
+ return;
263
+ }
257
264
  return {
258
265
  text: (0, lib_1.getDisplayName)(element),
259
266
  path: element.url,
260
267
  kind: element.kind,
261
268
  class: (0, lib_1.classNames)({ deprecated: element.isDeprecated() }, theme.getReflectionClasses(element)),
262
- children: getNavigationElements(element),
269
+ children: children?.length ? children : undefined,
263
270
  };
264
271
  }
265
272
  function getNavigationElements(parent) {
266
273
  if (parent instanceof models_1.ReflectionCategory) {
267
- return parent.children.map(toNavigation);
274
+ return (0, utils_1.filterMap)(parent.children, toNavigation);
268
275
  }
269
276
  if (parent instanceof models_1.ReflectionGroup) {
270
277
  if (shouldShowCategories(parent.owningReflection, opts) && parent.categories) {
271
- return parent.categories.map(toNavigation);
278
+ return (0, utils_1.filterMap)(parent.categories, toNavigation);
272
279
  }
273
- return parent.children.map(toNavigation);
280
+ return (0, utils_1.filterMap)(parent.children, toNavigation);
274
281
  }
275
282
  if (leaves.includes(parent.getFullName())) {
276
283
  return;
@@ -279,23 +286,23 @@ class DefaultTheme extends theme_1.Theme {
279
286
  return;
280
287
  }
281
288
  if (parent.isDocument()) {
282
- return parent.children?.map(toNavigation);
289
+ return (0, utils_1.filterMap)(parent.children, toNavigation);
283
290
  }
284
291
  if (!parent.kindOf(models_1.ReflectionKind.SomeModule | models_1.ReflectionKind.Project)) {
285
292
  // Tricky: Non-module children don't show up in the navigation pane,
286
293
  // but any documents added by them should.
287
- return parent.documents?.map(toNavigation);
294
+ return (0, utils_1.filterMap)(parent.documents, toNavigation);
288
295
  }
289
296
  if (parent.categories && shouldShowCategories(parent, opts)) {
290
- return parent.categories.map(toNavigation);
297
+ return (0, utils_1.filterMap)(parent.categories, toNavigation);
291
298
  }
292
299
  if (parent.groups && shouldShowGroups(parent, opts)) {
293
- return parent.groups.map(toNavigation);
300
+ return (0, utils_1.filterMap)(parent.groups, toNavigation);
294
301
  }
295
302
  if (opts.includeFolders && parent.childrenIncludingDocuments?.some((child) => child.name.includes("/"))) {
296
303
  return deriveModuleFolders(parent.childrenIncludingDocuments);
297
304
  }
298
- return parent.childrenIncludingDocuments?.map(toNavigation);
305
+ return (0, utils_1.filterMap)(parent.childrenIncludingDocuments, toNavigation);
299
306
  }
300
307
  function deriveModuleFolders(children) {
301
308
  const result = [];
@@ -318,12 +325,14 @@ class DefaultTheme extends theme_1.Theme {
318
325
  };
319
326
  // Note: This might end up putting a module within another module if we document
320
327
  // both foo/index.ts and foo/bar.ts.
321
- for (const child of children) {
322
- const parts = child.name.split("/");
323
- const collection = resolveOrCreateParents(parts);
328
+ for (const child of children.filter((c) => c.hasOwnDocument)) {
324
329
  const nav = toNavigation(child);
325
- nav.text = parts[parts.length - 1];
326
- collection.push(nav);
330
+ if (nav) {
331
+ const parts = child.name.split("/");
332
+ const collection = resolveOrCreateParents(parts);
333
+ nav.text = parts[parts.length - 1];
334
+ collection.push(nav);
335
+ }
327
336
  }
328
337
  // Now merge single-possible-paths together so we don't have folders in our navigation
329
338
  // which contain only another single folder.
@@ -5,7 +5,7 @@ import { type NeverIfInternal, type Options } from "../../../utils";
5
5
  import type { DefaultTheme } from "./DefaultTheme";
6
6
  import { type icons } from "./partials/icon";
7
7
  export declare class DefaultThemeRenderContext {
8
- private theme;
8
+ readonly theme: DefaultTheme;
9
9
  page: PageEvent<Reflection>;
10
10
  private _refIcons;
11
11
  options: Options;
@@ -63,7 +63,8 @@ export declare class DefaultThemeRenderContext {
63
63
  memberSignatures: (props: DeclarationReflection) => import("../../../utils/jsx.elements").JsxElement;
64
64
  memberSources: (props: DeclarationReflection | import("../../../models").SignatureReflection) => import("../../../utils/jsx.elements").JsxElement;
65
65
  members: (props: import("../../../models").ContainerReflection) => import("../../../utils/jsx.elements").JsxElement;
66
- membersGroup: (group: import("../../../models").ReflectionGroup) => import("../../../utils/jsx.elements").JsxElement;
66
+ /** @deprecated Since 0.26.3 members does group/category flattening internally */
67
+ membersGroup?: Function;
67
68
  sidebar: (props: PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement;
68
69
  pageSidebar: (props: PageEvent<Reflection>) => import("../../../utils/jsx.elements").JsxElement;
69
70
  sidebarLinks: () => import("../../../utils/jsx.elements").JsxElement | null;
@@ -18,7 +18,6 @@ const member_signature_title_1 = require("./partials/member.signature.title");
18
18
  const member_signatures_1 = require("./partials/member.signatures");
19
19
  const member_sources_1 = require("./partials/member.sources");
20
20
  const members_1 = require("./partials/members");
21
- const members_group_1 = require("./partials/members.group");
22
21
  const navigation_1 = require("./partials/navigation");
23
22
  const parameter_1 = require("./partials/parameter");
24
23
  const reflectionPreview_1 = require("./partials/reflectionPreview");
@@ -87,7 +86,6 @@ class DefaultThemeRenderContext {
87
86
  this.memberSignatures = bind(member_signatures_1.memberSignatures, this);
88
87
  this.memberSources = bind(member_sources_1.memberSources, this);
89
88
  this.members = bind(members_1.members, this);
90
- this.membersGroup = bind(members_group_1.membersGroup, this);
91
89
  this.sidebar = bind(navigation_1.sidebar, this);
92
90
  this.pageSidebar = bind(navigation_1.pageSidebar, this);
93
91
  this.sidebarLinks = bind(navigation_1.sidebarLinks, this);
@@ -1,4 +1,4 @@
1
1
  import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
2
2
  import { JSX } from "../../../../utils";
3
3
  import type { ReferenceReflection } from "../../../../models";
4
- export declare const memberReference: ({ urlTo, i18n }: DefaultThemeRenderContext, props: ReferenceReflection) => JSX.Element;
4
+ export declare const memberReference: ({ urlTo, i18n, commentSummary, commentTags }: DefaultThemeRenderContext, props: ReferenceReflection) => JSX.Element;
@@ -2,23 +2,29 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.memberReference = void 0;
4
4
  const utils_1 = require("../../../../utils");
5
- const memberReference = ({ urlTo, i18n }, props) => {
5
+ const memberReference = ({ urlTo, i18n, commentSummary, commentTags }, props) => {
6
6
  const referenced = props.tryGetTargetReflectionDeep();
7
7
  if (!referenced) {
8
8
  return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
9
9
  i18n.theme_re_exports(),
10
10
  " ",
11
- props.name));
11
+ props.name,
12
+ commentSummary(props),
13
+ commentTags(props)));
12
14
  }
13
15
  if (props.name === referenced.name) {
14
16
  return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
15
17
  i18n.theme_re_exports(),
16
18
  " ",
17
- utils_1.JSX.createElement("a", { href: urlTo(referenced) }, referenced.name)));
19
+ utils_1.JSX.createElement("a", { href: urlTo(referenced) }, referenced.name),
20
+ commentSummary(props),
21
+ commentTags(props)));
18
22
  }
19
23
  return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null,
20
24
  i18n.theme_renames_and_re_exports(),
21
25
  " ",
22
- utils_1.JSX.createElement("a", { href: urlTo(referenced) }, referenced.name)));
26
+ utils_1.JSX.createElement("a", { href: urlTo(referenced) }, referenced.name),
27
+ commentSummary(props),
28
+ commentTags(props)));
23
29
  };
24
30
  exports.memberReference = memberReference;
@@ -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 type { ContainerReflection } from "../../../../models";
4
4
  export declare function members(context: DefaultThemeRenderContext, props: ContainerReflection): JSX.Element;
@@ -2,17 +2,47 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.members = members;
4
4
  const utils_1 = require("../../../../utils");
5
- const models_1 = require("../../../../models");
6
- const lib_1 = require("../../lib");
5
+ function getMemberSections(parent) {
6
+ if (parent.categories?.length) {
7
+ return (0, utils_1.filterMap)(parent.categories, (cat) => {
8
+ if (!cat.allChildrenHaveOwnDocument()) {
9
+ return {
10
+ title: cat.title,
11
+ children: cat.children.filter((child) => !child.hasOwnDocument),
12
+ };
13
+ }
14
+ });
15
+ }
16
+ if (parent.groups?.length) {
17
+ return parent.groups.flatMap((group) => {
18
+ if (group.categories?.length) {
19
+ return (0, utils_1.filterMap)(group.categories, (cat) => {
20
+ if (!cat.allChildrenHaveOwnDocument()) {
21
+ return {
22
+ title: `${group.title} - ${cat.title}`,
23
+ children: cat.children.filter((child) => !child.hasOwnDocument),
24
+ };
25
+ }
26
+ });
27
+ }
28
+ return {
29
+ title: group.title,
30
+ children: group.children.filter((child) => !child.hasOwnDocument),
31
+ };
32
+ });
33
+ }
34
+ return [];
35
+ }
7
36
  function members(context, props) {
8
- if (props.categories && props.categories.length) {
9
- return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, props.categories.map((item) => !item.allChildrenHaveOwnDocument() && (utils_1.JSX.createElement("details", { class: (0, lib_1.classNames)({ "tsd-panel-group": true, "tsd-member-group": true, "tsd-accordion": true }, props instanceof models_1.DeclarationReflection ? context.getReflectionClasses(props) : "") },
10
- utils_1.JSX.createElement("summary", { class: "tsd-accordion-summary", "data-key": "section-" + item.title },
37
+ const sections = getMemberSections(props).filter((sect) => sect.children.length);
38
+ return (utils_1.JSX.createElement(utils_1.JSX.Fragment, null, sections.map(({ title, children }) => {
39
+ context.page.startNewSection(title);
40
+ return (utils_1.JSX.createElement("details", { class: "tsd-panel-group tsd-member-group tsd-accordion", open: true },
41
+ utils_1.JSX.createElement("summary", { class: "tsd-accordion-summary", "data-key": "section-" + title },
11
42
  utils_1.JSX.createElement("h2", null,
12
43
  context.icons.chevronDown(),
13
44
  " ",
14
- item.title)),
15
- utils_1.JSX.createElement("section", null, item.children.map((item) => !item.hasOwnDocument && context.member(item))))))));
16
- }
17
- return utils_1.JSX.createElement(utils_1.JSX.Fragment, null, props.groups?.map((item) => !item.allChildrenHaveOwnDocument() && context.membersGroup(item)));
45
+ title)),
46
+ utils_1.JSX.createElement("section", null, children.map((item) => context.member(item)))));
47
+ })));
18
48
  }
@@ -86,7 +86,7 @@ function pageSidebar(context, props) {
86
86
  context.settings(),
87
87
  context.pageNavigation(props)));
88
88
  }
89
- function pageNavigation(context, props) {
89
+ function buildSectionNavigation(context, headings) {
90
90
  const levels = [[]];
91
91
  function finalizeLevel(finishedHandlingHeadings) {
92
92
  const level = levels.pop();
@@ -97,8 +97,12 @@ function pageNavigation(context, props) {
97
97
  const built = (utils_1.JSX.createElement("ul", null, level.map((l) => (utils_1.JSX.createElement("li", null, l)))));
98
98
  levels[levels.length - 1].push(built);
99
99
  }
100
- for (const heading of props.pageHeadings) {
101
- const inferredLevel = heading.level ? heading.level + 1 : 1;
100
+ for (const heading of headings) {
101
+ const inferredLevel = heading.level
102
+ ? heading.level + 2 // regular heading
103
+ : heading.kind
104
+ ? 2 // reflection
105
+ : 1; // group/category
102
106
  while (inferredLevel < levels.length) {
103
107
  finalizeLevel(false);
104
108
  }
@@ -113,15 +117,31 @@ function pageNavigation(context, props) {
113
117
  while (levels.length > 1) {
114
118
  finalizeLevel(true);
115
119
  }
116
- if (!levels[0].length) {
117
- return utils_1.JSX.createElement(utils_1.JSX.Fragment, null);
118
- }
119
120
  levels.unshift([]);
120
121
  finalizeLevel(true);
122
+ return levels[0];
123
+ }
124
+ function pageNavigation(context, props) {
125
+ if (!props.pageSections.some((sect) => sect.headings.length)) {
126
+ return utils_1.JSX.createElement(utils_1.JSX.Fragment, null);
127
+ }
128
+ const sections = [];
129
+ for (const section of props.pageSections) {
130
+ if (section.title) {
131
+ sections.push(utils_1.JSX.createElement("details", { open: true, class: "tsd-accordion tsd-page-navigation-section" },
132
+ utils_1.JSX.createElement("summary", { class: "tsd-accordion-summary", "data-key": `tsd-otp-${section.title}` },
133
+ context.icons.chevronDown(),
134
+ section.title),
135
+ utils_1.JSX.createElement("div", null, buildSectionNavigation(context, section.headings))));
136
+ }
137
+ else {
138
+ sections.push(buildSectionNavigation(context, section.headings));
139
+ }
140
+ }
121
141
  return (utils_1.JSX.createElement("details", { open: true, class: "tsd-accordion tsd-page-navigation" },
122
142
  utils_1.JSX.createElement("summary", { class: "tsd-accordion-summary" },
123
143
  utils_1.JSX.createElement("h3", null,
124
144
  context.icons.chevronDown(),
125
145
  context.i18n.theme_on_this_page())),
126
- utils_1.JSX.createElement("div", { class: "tsd-accordion-details" }, levels[0])));
146
+ utils_1.JSX.createElement("div", { class: "tsd-accordion-details" }, sections)));
127
147
  }
@@ -48,6 +48,6 @@ export declare function partition<T>(iter: Iterable<T>, predicate: (item: T) =>
48
48
  export declare function zip<T extends Iterable<any>[]>(...args: T): Iterable<{
49
49
  [K in keyof T]: T[K] extends Iterable<infer U> ? U : T[K];
50
50
  }>;
51
- export declare function filterMap<T, U>(iter: Iterable<T>, fn: (item: T) => U | undefined): U[];
51
+ export declare function filterMap<T, U>(iter: Iterable<T> | undefined, fn: (item: T) => U | undefined): U[];
52
52
  export declare function firstDefined<T, U>(array: readonly T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined;
53
53
  export declare function filter<T>(array: readonly T[] | undefined, predicate: (value: T, index: number, array: readonly T[]) => boolean): readonly T[];
@@ -119,7 +119,7 @@ function* zip(...args) {
119
119
  }
120
120
  function filterMap(iter, fn) {
121
121
  const result = [];
122
- for (const item of iter) {
122
+ for (const item of iter || []) {
123
123
  const newItem = fn(item);
124
124
  if (newItem !== void 0) {
125
125
  result.push(newItem);
@@ -4,6 +4,6 @@ export declare function hasAllFlags(flags: number, check: number): boolean;
4
4
  export declare function hasAnyFlag(flags: number, check: number): boolean;
5
5
  export declare function debugFlags(Enum: {}, flags: number): string[];
6
6
  export declare function getEnumKeys(Enum: {}): string[];
7
- export type EnumKeys<E extends {}> = keyof {
8
- [K in keyof E as number extends E[K] ? K : never]: 1;
9
- };
7
+ export type EnumKeys<E extends {}> = {
8
+ [K in keyof E]: number extends E[K] ? K : never;
9
+ }[keyof E] & {};
@@ -1,7 +1,7 @@
1
1
  import type { LineAndCharacter, SourceFileLike } from "typescript";
2
2
  export declare class MinimalSourceFile implements SourceFileLike {
3
- readonly text: string;
4
3
  readonly fileName: string;
4
+ readonly text: string;
5
5
  constructor(text: string, fileName: string);
6
6
  getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
7
7
  }
@@ -8,8 +8,16 @@ const array_1 = require("./array");
8
8
  const lineStarts = new WeakMap();
9
9
  class MinimalSourceFile {
10
10
  constructor(text, fileName) {
11
- this.text = text;
12
11
  this.fileName = fileName;
12
+ // This is unfortunate, but the yaml library we use relies on the source
13
+ // text using LF line endings https://github.com/eemeli/yaml/issues/127.
14
+ // If we don't do this, in a simple document which includes a single key
15
+ // like:
16
+ // ---<CR><LF>
17
+ // title: Windows line endings<CR><LF>
18
+ // ---<CR><LF>
19
+ // we'll end up with a parsed title of "Windows line endings\r"
20
+ this.text = text.replaceAll("\r\n", "\n");
13
21
  lineStarts.set(this, [0]);
14
22
  }
15
23
  getLineAndCharacterOfPosition(pos) {
@@ -73,7 +73,7 @@ export interface TypeDocOptionMap {
73
73
  externalPattern: string[];
74
74
  excludeExternals: boolean;
75
75
  excludeNotDocumented: boolean;
76
- excludeNotDocumentedKinds: Array<keyof typeof ReflectionKind>;
76
+ excludeNotDocumentedKinds: ReflectionKind.KindString[];
77
77
  excludeInternal: boolean;
78
78
  excludePrivate: boolean;
79
79
  excludeProtected: boolean;
@@ -1,5 +1,5 @@
1
1
  export declare const tsdocBlockTags: readonly ["@defaultValue", "@deprecated", "@example", "@param", "@privateRemarks", "@remarks", "@returns", "@see", "@throws", "@typeParam"];
2
- export declare const blockTags: readonly ["@defaultValue", "@deprecated", "@example", "@param", "@privateRemarks", "@remarks", "@returns", "@see", "@throws", "@typeParam", "@author", "@callback", "@category", "@categoryDescription", "@default", "@document", "@group", "@groupDescription", "@import", "@inheritDoc", "@jsx", "@license", "@module", "@prop", "@property", "@return", "@satisfies", "@template", "@type", "@typedef"];
2
+ export declare const blockTags: readonly ["@defaultValue", "@deprecated", "@example", "@param", "@privateRemarks", "@remarks", "@returns", "@see", "@throws", "@typeParam", "@author", "@callback", "@category", "@categoryDescription", "@default", "@document", "@group", "@groupDescription", "@import", "@inheritDoc", "@jsx", "@license", "@module", "@prop", "@property", "@return", "@satisfies", "@since", "@template", "@type", "@typedef"];
3
3
  export declare const tsdocInlineTags: readonly ["@link", "@inheritDoc", "@label"];
4
4
  export declare const inlineTags: readonly ["@link", "@inheritDoc", "@label", "@linkcode", "@linkplain"];
5
5
  export declare const tsdocModifierTags: readonly ["@alpha", "@beta", "@eventProperty", "@experimental", "@internal", "@override", "@packageDocumentation", "@public", "@readonly", "@sealed", "@virtual"];
@@ -33,8 +33,9 @@ exports.blockTags = [
33
33
  "@property",
34
34
  "@return",
35
35
  "@satisfies",
36
+ "@since",
36
37
  "@template", // Alias for @typeParam
37
- "@type", // Because TypeScript is important!
38
+ "@type",
38
39
  "@typedef",
39
40
  ];
40
41
  exports.tsdocInlineTags = ["@link", "@inheritDoc", "@label"];
@@ -9,7 +9,7 @@ function getBrokenPartLinks(parts) {
9
9
  if (part.kind === "inline-tag" &&
10
10
  linkTags.includes(part.tag) &&
11
11
  !part.target) {
12
- links.push(part.text);
12
+ links.push(part.text.trim());
13
13
  }
14
14
  }
15
15
  return links;
@@ -25,42 +25,60 @@ function getBrokenLinks(comment) {
25
25
  }
26
26
  function validateLinks(project, logger) {
27
27
  for (const id in project.reflections) {
28
- const reflection = project.reflections[id];
29
- if (reflection.isProject() || reflection.isDeclaration()) {
30
- for (const broken of getBrokenPartLinks(reflection.readme || [])) {
31
- // #2360, "@" is a future reserved character in TSDoc component paths
32
- // If a link starts with it, and doesn't include a module source indicator "!"
33
- // then the user probably is trying to link to a package containing "@" with an absolute link.
34
- if (broken.startsWith("@") && !broken.includes("!")) {
35
- logger.warn(logger.i18n.failed_to_resolve_link_to_0_in_readme_for_1_may_have_meant_2(broken, reflection.getFriendlyFullName(), broken.replace(/[.#~]/, "!")));
36
- }
37
- else {
38
- logger.warn(logger.i18n.failed_to_resolve_link_to_0_in_readme_for_1(broken, reflection.getFriendlyFullName()));
39
- }
28
+ checkReflection(project.reflections[id], logger);
29
+ }
30
+ if (!(project.id in project.reflections)) {
31
+ checkReflection(project, logger);
32
+ }
33
+ }
34
+ function checkReflection(reflection, logger) {
35
+ if (reflection.isProject() || reflection.isDeclaration()) {
36
+ for (const broken of getBrokenPartLinks(reflection.readme || [])) {
37
+ // #2360, "@" is a future reserved character in TSDoc component paths
38
+ // If a link starts with it, and doesn't include a module source indicator "!"
39
+ // then the user probably is trying to link to a package containing "@" with an absolute link.
40
+ if (broken.startsWith("@") && !broken.includes("!")) {
41
+ logger.warn(logger.i18n.failed_to_resolve_link_to_0_in_readme_for_1_may_have_meant_2(broken, reflection.getFriendlyFullName(), broken.replace(/[.#~]/, "!")));
42
+ }
43
+ else {
44
+ logger.warn(logger.i18n.failed_to_resolve_link_to_0_in_readme_for_1(broken, reflection.getFriendlyFullName()));
40
45
  }
41
46
  }
42
- for (const broken of getBrokenLinks(reflection.comment)) {
47
+ }
48
+ if (reflection.isDocument()) {
49
+ for (const broken of getBrokenPartLinks(reflection.content)) {
43
50
  // #2360, "@" is a future reserved character in TSDoc component paths
44
51
  // If a link starts with it, and doesn't include a module source indicator "!"
45
52
  // then the user probably is trying to link to a package containing "@" with an absolute link.
46
53
  if (broken.startsWith("@") && !broken.includes("!")) {
47
- logger.warn(logger.i18n.failed_to_resolve_link_to_0_in_comment_for_1_may_have_meant_2(broken, reflection.getFriendlyFullName(), broken.replace(/[.#~]/, "!")));
54
+ logger.warn(logger.i18n.failed_to_resolve_link_to_0_in_document_1_may_have_meant_2(broken, reflection.getFriendlyFullName(), broken.replace(/[.#~]/, "!")));
48
55
  }
49
56
  else {
50
- logger.warn(logger.i18n.failed_to_resolve_link_to_0_in_comment_for_1(broken, reflection.getFriendlyFullName()));
57
+ logger.warn(logger.i18n.failed_to_resolve_link_to_0_in_document_1(broken, reflection.getFriendlyFullName()));
51
58
  }
52
59
  }
53
- if (reflection.isDeclaration() &&
54
- reflection.kindOf(models_1.ReflectionKind.TypeAlias) &&
55
- reflection.type?.type === "union" &&
56
- reflection.type.elementSummaries) {
57
- for (const broken of reflection.type.elementSummaries.flatMap(getBrokenPartLinks)) {
58
- if (broken.startsWith("@") && !broken.includes("!")) {
59
- logger.warn(logger.i18n.failed_to_resolve_link_to_0_in_comment_for_1_may_have_meant_2(broken, reflection.getFriendlyFullName(), broken.replace(/[.#~]/, "!")));
60
- }
61
- else {
62
- logger.warn(logger.i18n.failed_to_resolve_link_to_0_in_comment_for_1(broken, reflection.getFriendlyFullName()));
63
- }
60
+ }
61
+ for (const broken of getBrokenLinks(reflection.comment)) {
62
+ // #2360, "@" is a future reserved character in TSDoc component paths
63
+ // If a link starts with it, and doesn't include a module source indicator "!"
64
+ // then the user probably is trying to link to a package containing "@" with an absolute link.
65
+ if (broken.startsWith("@") && !broken.includes("!")) {
66
+ logger.warn(logger.i18n.failed_to_resolve_link_to_0_in_comment_for_1_may_have_meant_2(broken, reflection.getFriendlyFullName(), broken.replace(/[.#~]/, "!")));
67
+ }
68
+ else {
69
+ logger.warn(logger.i18n.failed_to_resolve_link_to_0_in_comment_for_1(broken, reflection.getFriendlyFullName()));
70
+ }
71
+ }
72
+ if (reflection.isDeclaration() &&
73
+ reflection.kindOf(models_1.ReflectionKind.TypeAlias) &&
74
+ reflection.type?.type === "union" &&
75
+ reflection.type.elementSummaries) {
76
+ for (const broken of reflection.type.elementSummaries.flatMap(getBrokenPartLinks)) {
77
+ if (broken.startsWith("@") && !broken.includes("!")) {
78
+ logger.warn(logger.i18n.failed_to_resolve_link_to_0_in_comment_for_1_may_have_meant_2(broken, reflection.getFriendlyFullName(), broken.replace(/[.#~]/, "!")));
79
+ }
80
+ else {
81
+ logger.warn(logger.i18n.failed_to_resolve_link_to_0_in_comment_for_1(broken, reflection.getFriendlyFullName()));
64
82
  }
65
83
  }
66
84
  }