@apify/docusaurus-plugin-typedoc-api 3.0.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.
Files changed (165) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +290 -0
  3. package/assets/styles-8ad572ec.css +303 -0
  4. package/lib/components/AnchorLink.js +22 -0
  5. package/lib/components/AnchorLink.js.map +1 -0
  6. package/lib/components/ApiChangelog.js +28 -0
  7. package/lib/components/ApiChangelog.js.map +1 -0
  8. package/lib/components/ApiDataContext.js +16 -0
  9. package/lib/components/ApiDataContext.js.map +1 -0
  10. package/lib/components/ApiIndex.js +80 -0
  11. package/lib/components/ApiIndex.js.map +1 -0
  12. package/lib/components/ApiItem.js +86 -0
  13. package/lib/components/ApiItem.js.map +1 -0
  14. package/lib/components/ApiItemLayout.js +69 -0
  15. package/lib/components/ApiItemLayout.js.map +1 -0
  16. package/lib/components/ApiPage.js +69 -0
  17. package/lib/components/ApiPage.js.map +1 -0
  18. package/lib/components/Breadcrumb.js +38 -0
  19. package/lib/components/Breadcrumb.js.map +1 -0
  20. package/lib/components/Comment.js +56 -0
  21. package/lib/components/Comment.js.map +1 -0
  22. package/lib/components/CommentBadges.js +35 -0
  23. package/lib/components/CommentBadges.js.map +1 -0
  24. package/lib/components/DefaultValue.js +49 -0
  25. package/lib/components/DefaultValue.js.map +1 -0
  26. package/lib/components/Flags.js +27 -0
  27. package/lib/components/Flags.js.map +1 -0
  28. package/lib/components/Footer.js +18 -0
  29. package/lib/components/Footer.js.map +1 -0
  30. package/lib/components/Hierarchy.js +27 -0
  31. package/lib/components/Hierarchy.js.map +1 -0
  32. package/lib/components/Icon.js +27 -0
  33. package/lib/components/Icon.js.map +1 -0
  34. package/lib/components/Index.js +87 -0
  35. package/lib/components/Index.js.map +1 -0
  36. package/lib/components/Markdown.js +204 -0
  37. package/lib/components/Markdown.js.map +1 -0
  38. package/lib/components/Member.js +68 -0
  39. package/lib/components/Member.js.map +1 -0
  40. package/lib/components/MemberDeclaration.js +64 -0
  41. package/lib/components/MemberDeclaration.js.map +1 -0
  42. package/lib/components/MemberGetterSetter.js +61 -0
  43. package/lib/components/MemberGetterSetter.js.map +1 -0
  44. package/lib/components/MemberReference.js +38 -0
  45. package/lib/components/MemberReference.js.map +1 -0
  46. package/lib/components/MemberSignatureBody.js +91 -0
  47. package/lib/components/MemberSignatureBody.js.map +1 -0
  48. package/lib/components/MemberSignatureTitle.js +52 -0
  49. package/lib/components/MemberSignatureTitle.js.map +1 -0
  50. package/lib/components/MemberSignatures.js +61 -0
  51. package/lib/components/MemberSignatures.js.map +1 -0
  52. package/lib/components/MemberSources.js +33 -0
  53. package/lib/components/MemberSources.js.map +1 -0
  54. package/lib/components/Members.js +51 -0
  55. package/lib/components/Members.js.map +1 -0
  56. package/lib/components/MembersGroup.js +39 -0
  57. package/lib/components/MembersGroup.js.map +1 -0
  58. package/lib/components/Parameter.js +145 -0
  59. package/lib/components/Parameter.js.map +1 -0
  60. package/lib/components/Reflection.js +112 -0
  61. package/lib/components/Reflection.js.map +1 -0
  62. package/lib/components/SourceLink.js +37 -0
  63. package/lib/components/SourceLink.js.map +1 -0
  64. package/lib/components/Type.js +341 -0
  65. package/lib/components/Type.js.map +1 -0
  66. package/lib/components/TypeAndParent.js +27 -0
  67. package/lib/components/TypeAndParent.js.map +1 -0
  68. package/lib/components/TypeParameters.js +36 -0
  69. package/lib/components/TypeParameters.js.map +1 -0
  70. package/lib/components/TypeParametersGeneric.js +27 -0
  71. package/lib/components/TypeParametersGeneric.js.map +1 -0
  72. package/lib/components/VersionBanner.js +39 -0
  73. package/lib/components/VersionBanner.js.map +1 -0
  74. package/lib/hooks/useBreadcrumbs.js +9 -0
  75. package/lib/hooks/useBreadcrumbs.js.map +1 -0
  76. package/lib/hooks/useGitRefName.js +9 -0
  77. package/lib/hooks/useGitRefName.js.map +1 -0
  78. package/lib/hooks/useMinimalLayout.js +9 -0
  79. package/lib/hooks/useMinimalLayout.js.map +1 -0
  80. package/lib/hooks/useReflection.js +19 -0
  81. package/lib/hooks/useReflection.js.map +1 -0
  82. package/lib/hooks/useReflectionMap.js +9 -0
  83. package/lib/hooks/useReflectionMap.js.map +1 -0
  84. package/lib/index.js +320 -0
  85. package/lib/index.js.map +1 -0
  86. package/lib/markdownLoader.js +11 -0
  87. package/lib/markdownLoader.js.map +1 -0
  88. package/lib/plugin/data.js +332 -0
  89. package/lib/plugin/data.js.map +1 -0
  90. package/lib/plugin/sidebar.js +105 -0
  91. package/lib/plugin/sidebar.js.map +1 -0
  92. package/lib/plugin/structure/0.23.js +48 -0
  93. package/lib/plugin/structure/0.23.js.map +1 -0
  94. package/lib/plugin/url.js +49 -0
  95. package/lib/plugin/url.js.map +1 -0
  96. package/lib/plugin/version.js +83 -0
  97. package/lib/plugin/version.js.map +1 -0
  98. package/lib/types.js +2 -0
  99. package/lib/types.js.map +1 -0
  100. package/lib/utils/hierarchy.js +35 -0
  101. package/lib/utils/hierarchy.js.map +1 -0
  102. package/lib/utils/icons.js +124 -0
  103. package/lib/utils/icons.js.map +1 -0
  104. package/lib/utils/links.js +10 -0
  105. package/lib/utils/links.js.map +1 -0
  106. package/lib/utils/markdown.js +69 -0
  107. package/lib/utils/markdown.js.map +1 -0
  108. package/lib/utils/visibility.js +25 -0
  109. package/lib/utils/visibility.js.map +1 -0
  110. package/package.json +57 -0
  111. package/src/components/AnchorLink.tsx +14 -0
  112. package/src/components/ApiChangelog.tsx +26 -0
  113. package/src/components/ApiDataContext.ts +17 -0
  114. package/src/components/ApiIndex.tsx +109 -0
  115. package/src/components/ApiItem.tsx +110 -0
  116. package/src/components/ApiItemLayout.tsx +96 -0
  117. package/src/components/ApiPage.tsx +78 -0
  118. package/src/components/Breadcrumb.tsx +41 -0
  119. package/src/components/Comment.tsx +74 -0
  120. package/src/components/CommentBadges.tsx +40 -0
  121. package/src/components/DefaultValue.tsx +48 -0
  122. package/src/components/Flags.tsx +29 -0
  123. package/src/components/Footer.tsx +13 -0
  124. package/src/components/Hierarchy.tsx +27 -0
  125. package/src/components/Icon.tsx +20 -0
  126. package/src/components/Index.tsx +109 -0
  127. package/src/components/Markdown.tsx +241 -0
  128. package/src/components/Member.tsx +64 -0
  129. package/src/components/MemberDeclaration.tsx +67 -0
  130. package/src/components/MemberGetterSetter.tsx +69 -0
  131. package/src/components/MemberReference.tsx +43 -0
  132. package/src/components/MemberSignatureBody.tsx +121 -0
  133. package/src/components/MemberSignatureTitle.tsx +65 -0
  134. package/src/components/MemberSignatures.tsx +64 -0
  135. package/src/components/MemberSources.tsx +42 -0
  136. package/src/components/Members.tsx +62 -0
  137. package/src/components/MembersGroup.tsx +47 -0
  138. package/src/components/Parameter.tsx +165 -0
  139. package/src/components/README.md +9 -0
  140. package/src/components/Reflection.tsx +136 -0
  141. package/src/components/SourceLink.tsx +46 -0
  142. package/src/components/Type.tsx +377 -0
  143. package/src/components/TypeAndParent.tsx +26 -0
  144. package/src/components/TypeParameters.tsx +37 -0
  145. package/src/components/TypeParametersGeneric.tsx +25 -0
  146. package/src/components/VersionBanner.tsx +44 -0
  147. package/src/components/styles.css +303 -0
  148. package/src/hooks/useBreadcrumbs.ts +6 -0
  149. package/src/hooks/useGitRefName.ts +6 -0
  150. package/src/hooks/useMinimalLayout.ts +6 -0
  151. package/src/hooks/useReflection.ts +18 -0
  152. package/src/hooks/useReflectionMap.ts +7 -0
  153. package/src/index.ts +420 -0
  154. package/src/markdownLoader.ts +10 -0
  155. package/src/plugin/data.ts +389 -0
  156. package/src/plugin/sidebar.ts +139 -0
  157. package/src/plugin/structure/0.23.ts +58 -0
  158. package/src/plugin/url.ts +49 -0
  159. package/src/plugin/version.ts +118 -0
  160. package/src/types.ts +165 -0
  161. package/src/utils/hierarchy.ts +46 -0
  162. package/src/utils/icons.ts +103 -0
  163. package/src/utils/links.ts +10 -0
  164. package/src/utils/markdown.ts +82 -0
  165. package/src/utils/visibility.ts +31 -0
@@ -0,0 +1,96 @@
1
+ // This file is based on `DocItem` upstream, but since we aren't using markdown,
2
+ // we had to duplicate it. Keep this file in sync as much as possible!
3
+ // https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-theme-classic/src/theme/DocItem/index.tsx
4
+
5
+ import React from 'react';
6
+ import type { PropNavigation } from '@docusaurus/plugin-content-docs';
7
+ import { ThemeClassNames, useWindowSize } from '@docusaurus/theme-common';
8
+ import DocBreadcrumbs from '@theme/DocBreadcrumbs';
9
+ import type { Props as DocItemProps } from '@theme/DocItem';
10
+ import DocPaginator from '@theme/DocPaginator';
11
+ import DocVersionBadge from '@theme/DocVersionBadge';
12
+ import Heading from '@theme/Heading';
13
+ import MDXContent from '@theme/MDXContent';
14
+ import TOC from '@theme/TOC';
15
+ import TOCCollapsible from '@theme/TOCCollapsible';
16
+ import { useBreadcrumbs } from '../hooks/useBreadcrumbs';
17
+ import type { TOCItem } from '../types';
18
+ import { VersionBanner } from './VersionBanner';
19
+
20
+ export interface ApiItemLayoutProps extends Pick<DocItemProps, 'route'> {
21
+ children: React.ReactNode;
22
+ heading: React.ReactNode;
23
+ toc: readonly TOCItem[];
24
+ pageMetadata?: React.ReactNode;
25
+ pagingMetadata?: PropNavigation;
26
+ name: string;
27
+ module?: string;
28
+ }
29
+
30
+ export default function ApiItemLayout({
31
+ children,
32
+ heading,
33
+ pageMetadata,
34
+ pagingMetadata,
35
+ toc,
36
+ name,
37
+ module,
38
+ }: ApiItemLayoutProps) {
39
+ const windowSize = useWindowSize();
40
+ const breadcrumbs = useBreadcrumbs();
41
+
42
+ // Table of contents
43
+ const canRenderTOC = toc.length > 0;
44
+ const renderTocDesktop = canRenderTOC && (windowSize === 'desktop' || windowSize === 'ssr');
45
+
46
+ return (
47
+ <>
48
+ {pageMetadata}
49
+
50
+ <div className="row">
51
+ <div className="col apiItemCol">
52
+ <VersionBanner />
53
+
54
+ <div className="apiItemContainer">
55
+ <article>
56
+ {breadcrumbs && <DocBreadcrumbs />}
57
+
58
+ <DocVersionBadge />
59
+
60
+ {canRenderTOC && (
61
+ <TOCCollapsible
62
+ className={`${ThemeClassNames.docs.docTocMobile ?? ''} apiTocMobile`}
63
+ maxHeadingLevel={6}
64
+ minHeadingLevel={1}
65
+ toc={toc}
66
+ />
67
+ )}
68
+
69
+ <div className={`${ThemeClassNames.docs.docMarkdown ?? ''} markdown`}>
70
+ <header>
71
+ <Heading as="h1">{heading}</Heading>
72
+ {module && <code className="tsd-header-member-fullname">{`${module}.${name}`}</code>}
73
+ </header>
74
+
75
+ <MDXContent>{children}</MDXContent>
76
+ </div>
77
+ </article>
78
+
79
+ {pagingMetadata && <DocPaginator {...pagingMetadata} />}
80
+ </div>
81
+ </div>
82
+
83
+ {renderTocDesktop && (
84
+ <div className="col col--3">
85
+ <TOC
86
+ className={ThemeClassNames.docs.docTocDesktop}
87
+ maxHeadingLevel={6}
88
+ minHeadingLevel={1}
89
+ toc={toc}
90
+ />
91
+ </div>
92
+ )}
93
+ </div>
94
+ </>
95
+ );
96
+ }
@@ -0,0 +1,78 @@
1
+ /* eslint-disable no-param-reassign */
2
+
3
+ import '@vscode/codicons/dist/codicon.css';
4
+ import './styles.css';
5
+ import React, { useMemo } from 'react';
6
+ import type { JSONOutput } from 'typedoc';
7
+ import DocPage, { type Props as DocPageProps } from '@theme/DocPage';
8
+ import type { ApiOptions, DeclarationReflectionMap, PackageReflectionGroup } from '../types';
9
+ import { ApiDataContext } from './ApiDataContext';
10
+
11
+ function isObject(value: unknown): value is JSONOutput.Reflection {
12
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
13
+ }
14
+
15
+ function deepMapReflections(
16
+ data: JSONOutput.Reflection,
17
+ map: DeclarationReflectionMap,
18
+ parent?: JSONOutput.Reflection,
19
+ ) {
20
+ Object.entries(data).forEach(([key, value]) => {
21
+ if (key === 'id') {
22
+ const hasType = 'type' in data;
23
+
24
+ // Dont overwrite with reference nodes
25
+ if (!hasType || (hasType && (data as unknown as { type: string }).type !== 'reference')) {
26
+ map[Number(value)] = data;
27
+
28
+ if (parent) {
29
+ data.parentId = parent.id;
30
+ }
31
+ }
32
+ } else if (Array.isArray(value)) {
33
+ value.forEach((val) => {
34
+ if (isObject(val)) {
35
+ deepMapReflections(val, map, data);
36
+ }
37
+ });
38
+ } else if (isObject(value)) {
39
+ deepMapReflections(value, map, data);
40
+ }
41
+ });
42
+
43
+ return map;
44
+ }
45
+
46
+ function mapPackagesToReflection(packages: PackageReflectionGroup[]): DeclarationReflectionMap {
47
+ const map: DeclarationReflectionMap = {};
48
+
49
+ packages.forEach((pkg) => {
50
+ pkg.entryPoints.forEach((entry) => {
51
+ deepMapReflections(entry.reflection, map);
52
+ });
53
+ });
54
+
55
+ return map;
56
+ }
57
+
58
+ export interface ApiPageProps extends DocPageProps {
59
+ options: ApiOptions;
60
+ packages: PackageReflectionGroup[];
61
+ }
62
+
63
+ function ApiPage({ options, packages, ...props }: ApiPageProps) {
64
+ const value = useMemo(
65
+ () => ({ options, reflections: mapPackagesToReflection(packages) }),
66
+ [options, packages],
67
+ );
68
+
69
+ return (
70
+ <ApiDataContext.Provider value={value}>
71
+ <div className="apiPage">
72
+ <DocPage {...props} />
73
+ </div>
74
+ </ApiDataContext.Provider>
75
+ );
76
+ }
77
+
78
+ export default ApiPage;
@@ -0,0 +1,41 @@
1
+ // https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/breadcrumb.hbs
2
+
3
+ import React from 'react';
4
+ import type { JSONOutput } from 'typedoc';
5
+ import Link from '@docusaurus/Link';
6
+ import { useReflection } from '../hooks/useReflection';
7
+
8
+ export interface BreadcrumbProps {
9
+ reflection: JSONOutput.Reflection;
10
+ root?: boolean;
11
+ }
12
+
13
+ export function Breadcrumb({ reflection, root = true }: BreadcrumbProps) {
14
+ const parent = useReflection(reflection.parentId);
15
+ let content: React.ReactNode = null;
16
+
17
+ if (parent) {
18
+ content = (
19
+ <>
20
+ <Breadcrumb reflection={parent} root={false} />
21
+ <li>
22
+ {reflection.permalink ? (
23
+ <Link to={reflection.permalink}>{reflection.name}</Link>
24
+ ) : (
25
+ <span>{reflection.name}</span>
26
+ )}
27
+ </li>
28
+ </>
29
+ );
30
+ } else if (reflection.permalink) {
31
+ content = (
32
+ <li>
33
+ <Link to={reflection.permalink}>{reflection.name}</Link>
34
+ </li>
35
+ );
36
+ } else {
37
+ return null;
38
+ }
39
+
40
+ return root ? <ul className="tsd-breadcrumb">{content}</ul> : <>{content}</>;
41
+ }
@@ -0,0 +1,74 @@
1
+ // https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/comment.hbs
2
+
3
+ import React from 'react';
4
+ import type { JSONOutput } from 'typedoc';
5
+ import { Markdown } from './Markdown';
6
+
7
+ export interface CommentProps {
8
+ comment?: JSONOutput.Comment;
9
+ root?: boolean;
10
+ hideTags?: string[];
11
+ }
12
+
13
+ export function hasComment(comment?: JSONOutput.Comment): boolean {
14
+ if (!comment) {
15
+ return false;
16
+ }
17
+
18
+ return Boolean(
19
+ comment.summary?.some((x) => x.kind !== 'text' || x.text !== '') ||
20
+ (comment.blockTags && comment.blockTags?.length > 0),
21
+ );
22
+ }
23
+
24
+ export function displayPartsToMarkdown(parts: JSONOutput.CommentDisplayPart[]): string {
25
+ return parts
26
+ .map((part) => {
27
+ if (part.kind === 'inline-tag') {
28
+ return `{${part.tag} ${part.text}}`;
29
+ }
30
+
31
+ return part.text;
32
+ })
33
+ .join('');
34
+ }
35
+
36
+ export function Comment({ comment, root, hideTags = [] }: CommentProps) {
37
+ if (!comment || !hasComment(comment)) {
38
+ return null;
39
+ }
40
+
41
+ const blockTags =
42
+ comment.blockTags?.filter((tag) => {
43
+ if (hideTags.includes(tag.tag)) {
44
+ return false;
45
+ }
46
+
47
+ return tag.tag !== '@default';
48
+ }) ?? [];
49
+
50
+ return (
51
+ <div className={`tsd-comment tsd-typography ${root ? 'tsd-comment-root' : ''}`}>
52
+ {!!comment.summary && (
53
+ <div className="lead">
54
+ <Markdown content={displayPartsToMarkdown(comment.summary)} />
55
+ </div>
56
+ )}
57
+
58
+ {blockTags.length > 0 && (
59
+ <dl className="tsd-comment-tags">
60
+ {blockTags.map((tag) => (
61
+ <React.Fragment key={tag.tag}>
62
+ <dt>
63
+ <strong>{tag.tag}</strong>
64
+ </dt>
65
+ <dd>
66
+ <Markdown content={displayPartsToMarkdown(tag.content)} />
67
+ </dd>
68
+ </React.Fragment>
69
+ ))}
70
+ </dl>
71
+ )}
72
+ </div>
73
+ );
74
+ }
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import { JSONOutput } from 'typedoc';
3
+
4
+ function getModifierClassName(tag: string) {
5
+ switch (tag) {
6
+ case '@beta':
7
+ case '@experimental':
8
+ return 'warning';
9
+ case '@alpha':
10
+ return 'danger';
11
+ default:
12
+ return 'info';
13
+ }
14
+ }
15
+
16
+ export type CommentWithModifiers = Pick<JSONOutput.Comment, 'blockTags' | 'summary'> &
17
+ Required<Pick<JSONOutput.Comment, 'modifierTags'>>;
18
+
19
+ export function isCommentWithModifiers(
20
+ comment?: JSONOutput.Comment,
21
+ ): comment is CommentWithModifiers {
22
+ return !!comment && !!comment.modifierTags && comment.modifierTags.length > 0;
23
+ }
24
+
25
+ interface CommentBadgesProps {
26
+ comment: CommentWithModifiers;
27
+ }
28
+
29
+ export function CommentBadges({ comment }: CommentBadgesProps) {
30
+ const { modifierTags } = comment;
31
+ return (
32
+ <div className="badge-group">
33
+ {modifierTags.map((tag) => (
34
+ <span key={tag} className={`badge badge--${getModifierClassName(tag)}`}>
35
+ {tag.slice(1)}
36
+ </span>
37
+ ))}
38
+ </div>
39
+ );
40
+ }
@@ -0,0 +1,48 @@
1
+ /* eslint-disable react-perf/jsx-no-new-object-as-prop */
2
+
3
+ import React from 'react';
4
+ import type { JSONOutput } from 'typedoc';
5
+ import { displayPartsToMarkdown } from './Comment';
6
+ import { Type } from './Type';
7
+
8
+ export interface DefaultValueProps {
9
+ comment?: JSONOutput.Comment;
10
+ type?: { type: string };
11
+ value?: JSONOutput.SomeType | string;
12
+ }
13
+
14
+ function extractDefaultTag(comment?: JSONOutput.Comment): string | null {
15
+ const tag = comment?.blockTags?.find((tag) => tag.tag === '@default');
16
+
17
+ if (!tag) {
18
+ return null;
19
+ }
20
+
21
+ return displayPartsToMarkdown(tag.content);
22
+ }
23
+
24
+ export function DefaultValue({ comment, value, type }: DefaultValueProps) {
25
+ if (!comment && !value) {
26
+ return null;
27
+ }
28
+
29
+ const defaultTag = extractDefaultTag(comment);
30
+
31
+ if (!defaultTag && !value) {
32
+ return null;
33
+ }
34
+
35
+ return (
36
+ <span className="tsd-signature-symbol tsd-signature-default-value">
37
+ {' = '}
38
+
39
+ {value && <>{typeof value === 'string' ? value : <Type type={value} />}</>}
40
+
41
+ {!value && defaultTag && (
42
+ <Type
43
+ type={{ type: 'literal', ...(type?.type === 'intrinsic' ? {} : type), value: defaultTag }}
44
+ />
45
+ )}
46
+ </span>
47
+ );
48
+ }
@@ -0,0 +1,29 @@
1
+ // https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/comment.hbs
2
+ import React from 'react';
3
+ import type { JSONOutput } from 'typedoc';
4
+
5
+ function removePrefix(value: string) {
6
+ return value.replace(/^is([A-Z])/, (match, char) => String(char).toLocaleLowerCase());
7
+ }
8
+
9
+ export interface FlagsProps {
10
+ flags?: JSONOutput.ReflectionFlags;
11
+ }
12
+
13
+ export function Flags({ flags }: FlagsProps) {
14
+ if (!flags) {
15
+ return null;
16
+ }
17
+
18
+ return (
19
+ <span className='tsd-flag-group'>
20
+ {Object.keys(flags)
21
+ .map(removePrefix)
22
+ .map((flag) => (
23
+ <span key={flag} className={`tsd-flag tsd-flag-${flag}`}>
24
+ {flag}
25
+ </span>
26
+ ))}
27
+ </span>
28
+ );
29
+ }
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+
3
+ export function Footer() {
4
+ return (
5
+ <footer className="tsd-footer">
6
+ Powered by{' '}
7
+ <a href="https://github.com/milesj/docusaurus-plugin-typedoc-api">
8
+ docusaurus-plugin-typedoc-api
9
+ </a>{' '}
10
+ and <a href="https://typedoc.org/">TypeDoc</a>
11
+ </footer>
12
+ );
13
+ }
@@ -0,0 +1,27 @@
1
+ // https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/hierarchy.hbs
2
+
3
+ import React from 'react';
4
+ import type { HierarchyNode } from '../utils/hierarchy';
5
+ import { Type } from './Type';
6
+
7
+ export interface HierarchyProps {
8
+ tree: HierarchyNode;
9
+ }
10
+
11
+ export function Hierarchy({ tree }: HierarchyProps) {
12
+ return (
13
+ <ul className="tsd-hierarchy">
14
+ {tree.types.map((type, i) => (
15
+ <li key={type.type + String(i)}>
16
+ {tree.isTarget ? (
17
+ <em className="tsd-target">{type.type === 'reference' ? type.name : 'UNKNOWN'}</em>
18
+ ) : (
19
+ <Type type={type} />
20
+ )}
21
+
22
+ {i === tree.types.length - 1 && tree.next && <Hierarchy tree={tree.next} />}
23
+ </li>
24
+ ))}
25
+ </ul>
26
+ );
27
+ }
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import type { JSONOutput } from 'typedoc';
3
+ import { getKindIcon, getKindIconColor } from '../utils/icons';
4
+
5
+ export interface IconProps {
6
+ reflection: JSONOutput.DeclarationReflection;
7
+ }
8
+
9
+ export function Icon({ reflection }: IconProps) {
10
+ const icon = getKindIcon(reflection.kind, reflection.name);
11
+
12
+ if (!icon) {
13
+ return null;
14
+ }
15
+
16
+ const color = getKindIconColor(reflection.kind);
17
+
18
+ // eslint-disable-next-line react-perf/jsx-no-new-object-as-prop
19
+ return <i className={`codicon codicon-${icon}`} style={{ color }} />;
20
+ }
@@ -0,0 +1,109 @@
1
+ import React from 'react';
2
+ import type { JSONOutput } from 'typedoc';
3
+ import Link from '@docusaurus/Link';
4
+ import { useReflection } from '../hooks/useReflection';
5
+ import { AnchorLink } from './AnchorLink';
6
+ import { Icon } from './Icon';
7
+
8
+ export interface IndexChildProps {
9
+ id: number;
10
+ }
11
+
12
+ function IndexChild({ id }: IndexChildProps) {
13
+ const reflection = useReflection(id)!;
14
+
15
+ return (
16
+ <li>
17
+ <Link className="tsd-kind-icon" to={reflection.permalink ?? `#${reflection.name}`}>
18
+ <Icon reflection={reflection} />
19
+ {reflection.name ?? <em>{reflection.kindString}</em>}
20
+ </Link>
21
+ </li>
22
+ );
23
+ }
24
+
25
+ export interface IndexProps {
26
+ reflection: JSONOutput.DeclarationReflection;
27
+ }
28
+
29
+ export function Index({ reflection }: IndexProps) {
30
+ if (reflection.categories && reflection.categories.length > 0) {
31
+ return (
32
+ <section className="tsd-panel-group tsd-index-group">
33
+ <h2>
34
+ Index <AnchorLink id="Index" />
35
+ </h2>
36
+
37
+ <section className="tsd-panel tsd-index-panel">
38
+ <div className="tsd-index-content">
39
+ {reflection.categories.map((category) => (
40
+ <section key={category.title} className="tsd-index-section">
41
+ <h3 className="tsd-panel-header">
42
+ {category.title === 'CATEGORY' ? 'Other' : category.title}
43
+ </h3>
44
+
45
+ <div className="tsd-panel-content">
46
+ <ul className="tsd-index-list">
47
+ {category.children?.map((child) => (
48
+ <IndexChild key={child} id={child} />
49
+ ))}
50
+ </ul>
51
+ </div>
52
+ </section>
53
+ ))}
54
+ </div>
55
+ </section>
56
+ </section>
57
+ );
58
+ }
59
+
60
+ if (reflection.groups && reflection.groups.length > 0) {
61
+ return (
62
+ <section className="tsd-panel-group tsd-index-group">
63
+ <h2>
64
+ Index <AnchorLink id="Index" />
65
+ </h2>
66
+
67
+ <section className="tsd-panel tsd-index-panel">
68
+ <div className="tsd-index-content">
69
+ {reflection.groups.map((group) => (
70
+ <section key={group.title} className="tsd-index-section">
71
+ {group.categories && group.categories.length > 0 ? (
72
+ group.categories.map((category) => (
73
+ <React.Fragment key={category.title}>
74
+ <h3 className="tsd-panel-header">
75
+ {category.title === 'CATEGORY' ? group.title : category.title}
76
+ </h3>
77
+
78
+ <div className="tsd-panel-content">
79
+ <ul className="tsd-index-list">
80
+ {category.children?.map((child) => (
81
+ <IndexChild key={child} id={child} />
82
+ ))}
83
+ </ul>
84
+ </div>
85
+ </React.Fragment>
86
+ ))
87
+ ) : (
88
+ <>
89
+ <h3 className="tsd-panel-header">{group.title}</h3>
90
+
91
+ <div className="tsd-panel-content">
92
+ <ul className="tsd-index-list">
93
+ {group.children?.map((child) => (
94
+ <IndexChild key={child} id={child} />
95
+ ))}
96
+ </ul>
97
+ </div>
98
+ </>
99
+ )}
100
+ </section>
101
+ ))}
102
+ </div>
103
+ </section>
104
+ </section>
105
+ );
106
+ }
107
+
108
+ return null;
109
+ }