@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,64 @@
1
+ /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
2
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
3
+ // https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.signatures.hbs
4
+
5
+ import React, { useState } from 'react';
6
+ import type { JSONOutput } from 'typedoc';
7
+ import { useMinimalLayout } from '../hooks/useMinimalLayout';
8
+ import { Icon } from './Icon';
9
+ import { hasSigBody, MemberSignatureBody } from './MemberSignatureBody';
10
+ import { MemberSignatureTitle } from './MemberSignatureTitle';
11
+
12
+ export interface MemberSignaturesProps {
13
+ inPanel?: boolean;
14
+ sigs: JSONOutput.SignatureReflection[];
15
+ }
16
+
17
+ export function MemberSignatures({ inPanel, sigs }: MemberSignaturesProps) {
18
+ const [activeIndex, setActiveIndex] = useState(0);
19
+ const minimal = useMinimalLayout();
20
+ const hasMultiple = sigs.length > 1;
21
+ const body = sigs[activeIndex];
22
+
23
+ return (
24
+ <>
25
+ <div className={inPanel ? 'tsd-panel-content' : ''}>
26
+ <ul className="tsd-signatures">
27
+ {sigs.map((sig, i) => (
28
+ <li
29
+ key={sig.id}
30
+ className={`tsd-signature tsd-kind-icon ${
31
+ i === activeIndex ? '' : 'tsd-signature-inactive'
32
+ } ${hasMultiple ? 'tsd-pressable' : ''}`}
33
+ onClick={
34
+ hasMultiple
35
+ ? // eslint-disable-next-line react-perf/jsx-no-new-function-as-prop
36
+ () => {
37
+ setActiveIndex(i);
38
+ }
39
+ : undefined
40
+ }
41
+ >
42
+ <Icon reflection={sig} />
43
+ <MemberSignatureTitle sig={sig} />
44
+ </li>
45
+ ))}
46
+ </ul>
47
+ </div>
48
+
49
+ {hasSigBody(body, minimal) && (
50
+ <>
51
+ {!inPanel && <hr className="tsd-divider" />}
52
+
53
+ <div className={inPanel ? 'tsd-panel-content' : ''}>
54
+ <ul className="tsd-descriptions">
55
+ <li key={body.id} className="tsd-description">
56
+ <MemberSignatureBody sig={body} />
57
+ </li>
58
+ </ul>
59
+ </div>
60
+ </>
61
+ )}
62
+ </>
63
+ );
64
+ }
@@ -0,0 +1,42 @@
1
+ // https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.sources.hbs
2
+
3
+ import React from 'react';
4
+ import type { JSONOutput } from 'typedoc';
5
+ import { TypeAndParent } from './TypeAndParent';
6
+
7
+ export function hasSources(reflection: JSONOutput.DeclarationReflection) {
8
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
9
+ return Boolean(reflection.implementationOf || reflection.inheritedFrom || reflection.overwrites);
10
+ }
11
+
12
+ export interface MemberSourcesProps {
13
+ reflection: JSONOutput.DeclarationReflection;
14
+ }
15
+
16
+ export function MemberSources({ reflection }: MemberSourcesProps) {
17
+ if (!hasSources(reflection)) {
18
+ return null;
19
+ }
20
+
21
+ return (
22
+ <aside className="tsd-sources">
23
+ {reflection.implementationOf && (
24
+ <p>
25
+ Implementation of <TypeAndParent type={reflection.implementationOf} />
26
+ </p>
27
+ )}
28
+
29
+ {reflection.inheritedFrom && (
30
+ <p>
31
+ Inherited from <TypeAndParent type={reflection.inheritedFrom} />
32
+ </p>
33
+ )}
34
+
35
+ {reflection.overwrites && (
36
+ <p>
37
+ Overrides <TypeAndParent type={reflection.overwrites} />
38
+ </p>
39
+ )}
40
+ </aside>
41
+ );
42
+ }
@@ -0,0 +1,62 @@
1
+ // https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/members.hbs
2
+
3
+ import React from 'react';
4
+ import type { JSONOutput } from 'typedoc';
5
+ import { useReflectionMap } from '../hooks/useReflectionMap';
6
+ import {
7
+ allCategoryChildrenHaveOwnDocument,
8
+ allGroupChildrenHaveOwnDocument,
9
+ hasOwnDocument,
10
+ } from '../utils/visibility';
11
+ import { AnchorLink } from './AnchorLink';
12
+ import { Member } from './Member';
13
+ import { MembersGroup } from './MembersGroup';
14
+
15
+ export interface MembersProps {
16
+ reflection: JSONOutput.DeclarationReflection;
17
+ }
18
+
19
+ export function Members({ reflection }: MembersProps) {
20
+ const reflections = useReflectionMap();
21
+
22
+ if (reflection.categories && reflection.categories.length > 0) {
23
+ return (
24
+ <>
25
+ {reflection.categories.map((category) => {
26
+ if (allCategoryChildrenHaveOwnDocument(category, reflections)) {
27
+ return null;
28
+ }
29
+
30
+ return (
31
+ <section key={category.title} className="tsd-panel-group tsd-member-group">
32
+ <h2>
33
+ {category.title === 'CATEGORY' ? 'Other' : category.title}{' '}
34
+ <AnchorLink id={category.title} />
35
+ </h2>
36
+
37
+ {category.children?.map((child) => {
38
+ if (hasOwnDocument(child, reflections)) {
39
+ return null;
40
+ }
41
+
42
+ return <Member key={child} id={child} />;
43
+ })}
44
+ </section>
45
+ );
46
+ })}
47
+ </>
48
+ );
49
+ }
50
+
51
+ return (
52
+ <>
53
+ {reflection.groups?.map((group) => {
54
+ if (allGroupChildrenHaveOwnDocument(group, reflections)) {
55
+ return null;
56
+ }
57
+
58
+ return <MembersGroup key={group.title} group={group} />;
59
+ })}
60
+ </>
61
+ );
62
+ }
@@ -0,0 +1,47 @@
1
+ // https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/members.group.hbs
2
+
3
+ import React from 'react';
4
+ import type { JSONOutput } from 'typedoc';
5
+ import { useReflectionMap } from '../hooks/useReflectionMap';
6
+ import { hasOwnDocument } from '../utils/visibility';
7
+ import { AnchorLink } from './AnchorLink';
8
+ import { Member } from './Member';
9
+
10
+ export interface MembersGroupProps {
11
+ group: JSONOutput.ReflectionGroup;
12
+ }
13
+
14
+ export function MembersGroup({ group }: MembersGroupProps) {
15
+ const reflections = useReflectionMap();
16
+
17
+ if (group.categories && group.categories.length > 0) {
18
+ return (
19
+ <>
20
+ {group.categories.map((category) => (
21
+ <section key={category.title} className="tsd-panel-group tsd-member-group">
22
+ <h2>
23
+ {category.title === 'CATEGORY' ? 'Other' : category.title}{' '}
24
+ <AnchorLink id={category.title} />
25
+ </h2>
26
+
27
+ {category.children?.map((child) =>
28
+ hasOwnDocument(child, reflections) ? null : <Member key={child} id={child} />,
29
+ )}
30
+ </section>
31
+ ))}
32
+ </>
33
+ );
34
+ }
35
+
36
+ return (
37
+ <section className="tsd-panel-group tsd-member-group">
38
+ <h2>
39
+ {group.title} <AnchorLink id={group.title} />
40
+ </h2>
41
+
42
+ {group.children?.map((child) =>
43
+ hasOwnDocument(child, reflections) ? null : <Member key={child} id={child} />,
44
+ )}
45
+ </section>
46
+ );
47
+ }
@@ -0,0 +1,165 @@
1
+ /* eslint-disable @typescript-eslint/no-use-before-define */
2
+ // https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/Parameter.hbs
3
+
4
+ import React from 'react';
5
+ import type { JSONOutput } from 'typedoc';
6
+ import { useMinimalLayout } from '../hooks/useMinimalLayout';
7
+ import { Comment } from './Comment';
8
+ import { Flags } from './Flags';
9
+ import { Icon } from './Icon';
10
+ import { hasSigBody, MemberSignatureBody } from './MemberSignatureBody';
11
+ import { MemberSignatures } from './MemberSignatures';
12
+ import { MemberSignatureTitle } from './MemberSignatureTitle';
13
+ import { Type } from './Type';
14
+
15
+ export interface ParameterProps {
16
+ param?: JSONOutput.DeclarationReflection;
17
+ }
18
+
19
+ function ParameterChild({ param }: ParameterProps) {
20
+ if (!param) {
21
+ return null;
22
+ }
23
+
24
+ if (param.signatures && param.signatures.length > 0) {
25
+ return (
26
+ <li className="tsd-parameter">
27
+ <h5>
28
+ {param.flags?.isRest && <span className="tsd-signature-symbol">...</span>}
29
+ {param.name}
30
+ <span className="tsd-signature-symbol">{param.flags?.isOptional && '?'}: </span>
31
+ function
32
+ </h5>
33
+
34
+ <MemberSignatures sigs={param.signatures} />
35
+ </li>
36
+ );
37
+ }
38
+
39
+ if (param.type) {
40
+ return (
41
+ <li className="tsd-parameter">
42
+ <h5>
43
+ <Flags flags={param.flags} />
44
+ {param.flags?.isRest && <span className="tsd-signature-symbol">...</span>}
45
+ {param.name}
46
+ <span className="tsd-signature-symbol">{param.flags?.isOptional && '?'}: </span>
47
+ <Type type={param.type} />
48
+ </h5>
49
+
50
+ <Comment comment={param.comment} />
51
+
52
+ {param.children?.map((child) => (
53
+ <Parameter key={child.id} param={child} />
54
+ ))}
55
+
56
+ <Parameter param={param.type.declaration} />
57
+ </li>
58
+ );
59
+ }
60
+
61
+ const getter = param.getSignature;
62
+ const setter = param.setSignature;
63
+
64
+ return (
65
+ <>
66
+ {getter && (
67
+ <li className="tsd-parameter">
68
+ <h5>
69
+ <Flags flags={getter.flags} />
70
+ <span className="tsd-signature-symbol">get </span>
71
+ {getter.name}
72
+ <span className="tsd-signature-symbol">(): </span>
73
+ <Type type={getter.type} />
74
+ </h5>
75
+
76
+ <Comment comment={getter.comment} />
77
+ </li>
78
+ )}
79
+
80
+ {setter && (
81
+ <li className="tsd-parameter">
82
+ <h5>
83
+ <Flags flags={setter.flags} />
84
+ <span className="tsd-signature-symbol">set </span>
85
+ {setter.name}
86
+ <span className="tsd-signature-symbol">(</span>
87
+ {setter.parameters?.map((p, i) => (
88
+ <span key={p.id}>
89
+ {i > 0 && ', '}
90
+ {p.name}
91
+ <span className="tsd-signature-symbol">: </span>
92
+ {p.type ? <Type type={p.type} /> : 'any'}
93
+ </span>
94
+ ))}
95
+ <span className="tsd-signature-symbol">): </span>
96
+ <Type type={setter.type} />
97
+ </h5>
98
+
99
+ <Comment comment={setter.comment} />
100
+ </li>
101
+ )}
102
+ </>
103
+ );
104
+ }
105
+
106
+ export function Parameter({ param }: ParameterProps) {
107
+ const minimal = useMinimalLayout();
108
+
109
+ if (!param || minimal) {
110
+ return null;
111
+ }
112
+
113
+ const hasSomeBody = param.signatures?.some((sig) => hasSigBody(sig, minimal, true));
114
+
115
+ return (
116
+ <ul className="tsd-parameters">
117
+ {param.signatures && param.signatures.length > 0 && (
118
+ <li className="tsd-parameter-signature">
119
+ <ul className="tsd-signatures">
120
+ {param.signatures.map((sig) => (
121
+ <li key={sig.id} className="tsd-signature tsd-kind-icon">
122
+ <Icon reflection={sig} />
123
+ <MemberSignatureTitle hideName sig={sig} />
124
+ </li>
125
+ ))}
126
+ </ul>
127
+
128
+ {hasSomeBody && (
129
+ <ul className="tsd-descriptions">
130
+ {param.signatures.map((sig) => (
131
+ <li key={sig.id} className="tsd-description">
132
+ <MemberSignatureBody hideSources sig={sig} />
133
+ </li>
134
+ ))}
135
+ </ul>
136
+ )}
137
+ </li>
138
+ )}
139
+
140
+ {param.indexSignature && (
141
+ <li className="tsd-parameter-index-signature">
142
+ <h5>
143
+ <span className="tsd-signature-symbol">[</span>
144
+ {param.indexSignature.parameters?.map((p) => (
145
+ <span key={p.id}>
146
+ {p.flags?.isRest && <span className="tsd-signature-symbol">...</span>}
147
+ {p.name} <Type type={p.type} />
148
+ </span>
149
+ ))}
150
+ <span className="tsd-signature-symbol">]: </span>
151
+ <Type type={param.indexSignature.type} />
152
+ </h5>
153
+
154
+ <Comment comment={param.indexSignature.comment} />
155
+
156
+ <Parameter param={param.indexSignature.declaration} />
157
+ </li>
158
+ )}
159
+
160
+ {param.children?.map((child) => (
161
+ <ParameterChild key={child.id} param={child} />
162
+ ))}
163
+ </ul>
164
+ );
165
+ }
@@ -0,0 +1,9 @@
1
+ The `ApiPage` and `ApiItem` components are based on Docusaurus' built-in `DocPage` and `DocItem`. We
2
+ wanted to reuse as much code as possible, so we try and extend or duplicate when necessary. Please
3
+ reference the classic them when making changes:
4
+ https://github.com/facebook/docusaurus/tree/main/packages/docusaurus-theme-classic/src/theme
5
+
6
+ The remaining components are React based copies of the TypeDoc handlebar templates. We wanted the UI
7
+ to feel as similar as possible, so we align our markup as closely as possible to TypeDoc. Please
8
+ reference the default theme when making changes:
9
+ https://github.com/TypeStrong/typedoc-default-themes/tree/master/src/default
@@ -0,0 +1,136 @@
1
+ // https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/templates/reflection.hbs
2
+
3
+ import React, { useMemo } from 'react';
4
+ import type { JSONOutput } from 'typedoc';
5
+ import { createHierarchy } from '../utils/hierarchy';
6
+ import { Comment, hasComment } from './Comment';
7
+ import { CommentBadges, isCommentWithModifiers } from './CommentBadges';
8
+ import { Hierarchy } from './Hierarchy';
9
+ import { Icon } from './Icon';
10
+ import { Index } from './Index';
11
+ import { Members } from './Members';
12
+ import { MemberSignatures } from './MemberSignatures';
13
+ import { Parameter } from './Parameter';
14
+ import { Type } from './Type';
15
+ import { TypeParameters } from './TypeParameters';
16
+
17
+ export interface ReflectionProps {
18
+ reflection:
19
+ | JSONOutput.DeclarationReflection
20
+ | JSONOutput.Reflection
21
+ | JSONOutput.SignatureReflection;
22
+ }
23
+ // eslint-disable-next-line complexity
24
+ export function Reflection({ reflection }: ReflectionProps) {
25
+ const hierarchy = useMemo(() => createHierarchy(reflection), [reflection]);
26
+
27
+ return (
28
+ <>
29
+ {isCommentWithModifiers(reflection.comment) && <CommentBadges comment={reflection.comment} />}
30
+ {hasComment(reflection.comment) && <Comment root comment={reflection.comment} />}
31
+
32
+ {'typeParameter' in reflection &&
33
+ reflection.typeParameter &&
34
+ reflection.typeParameter.length > 0 &&
35
+ // Class
36
+ reflection.kind !== 128 && (
37
+ <section className="tsd-panel">
38
+ <h3 className="tsd-panel-header">Type parameters</h3>
39
+
40
+ <div className="tsd-panel-content">
41
+ <TypeParameters params={reflection.typeParameter} />
42
+ </div>
43
+ </section>
44
+ )}
45
+
46
+ {(('extendedBy' in reflection && reflection.extendedBy && reflection.extendedBy.length > 0) ||
47
+ ('extendedTypes' in reflection &&
48
+ reflection.extendedTypes &&
49
+ reflection.extendedTypes.length > 0)) && (
50
+ <section className="tsd-panel">
51
+ <h3 className="tsd-panel-header">Hierarchy</h3>
52
+
53
+ <div className="tsd-panel-content">
54
+ <Hierarchy tree={hierarchy} />
55
+ </div>
56
+ </section>
57
+ )}
58
+
59
+ {'implementedTypes' in reflection &&
60
+ reflection.implementedTypes &&
61
+ reflection.implementedTypes.length > 0 && (
62
+ <section className="tsd-panel">
63
+ <h3 className="tsd-panel-header">Implements</h3>
64
+
65
+ <div className="tsd-panel-content">
66
+ <ul className="tsd-hierarchy">
67
+ {reflection.implementedTypes.map((type, i) => (
68
+ <li key={type.type + String(i)}>
69
+ <Type type={type} />
70
+ </li>
71
+ ))}
72
+ </ul>
73
+ </div>
74
+ </section>
75
+ )}
76
+
77
+ {'implementedBy' in reflection &&
78
+ reflection.implementedBy &&
79
+ reflection.implementedBy.length > 0 && (
80
+ <section className="tsd-panel">
81
+ <h3 className="tsd-panel-header">Implemented by</h3>
82
+
83
+ <div className="tsd-panel-content">
84
+ <ul className="tsd-hierarchy">
85
+ {reflection.implementedBy.map((type, i) => (
86
+ <li key={type.name + String(i)}>
87
+ <Type type={type} />
88
+ </li>
89
+ ))}
90
+ </ul>
91
+ </div>
92
+ </section>
93
+ )}
94
+
95
+ {'signatures' in reflection && reflection.signatures && reflection.signatures.length > 0 && (
96
+ <section className="tsd-panel">
97
+ <h3 className="tsd-panel-header tsd-before-signature">Callable</h3>
98
+
99
+ <div className="tsd-panel-content">
100
+ <MemberSignatures sigs={reflection.signatures} />
101
+ </div>
102
+ </section>
103
+ )}
104
+
105
+ {'indexSignature' in reflection && reflection.indexSignature && (
106
+ <section className="tsd-panel">
107
+ <h3 className="tsd-panel-header tsd-before-signature">Indexable</h3>
108
+
109
+ <div className="tsd-panel-content">
110
+ <div className="tsd-signature tsd-kind-icon">
111
+ <Icon reflection={reflection.indexSignature} />
112
+ <span className="tsd-signature-symbol">[</span>
113
+ {reflection.indexSignature.parameters?.map((param) => (
114
+ <span key={param.id}>
115
+ {param.name}
116
+ {': '}
117
+ <Type type={param.type} />
118
+ </span>
119
+ ))}
120
+ <span className="tsd-signature-symbol">]: </span>
121
+ <Type type={reflection.indexSignature.type} />
122
+ </div>
123
+
124
+ <Comment comment={reflection.indexSignature.comment} />
125
+
126
+ <Parameter param={reflection.indexSignature.type?.declaration} />
127
+ </div>
128
+ </section>
129
+ )}
130
+
131
+ <Index reflection={reflection} />
132
+
133
+ <Members reflection={reflection} />
134
+ </>
135
+ );
136
+ }
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import type { JSONOutput } from 'typedoc';
3
+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
4
+ import { useGitRefName } from '../hooks/useGitRefName';
5
+
6
+ function replaceWithSrc(url: string): string {
7
+ // Always link the source file
8
+ return url.replace(/\/(dts|dist|lib|build|es|esm|cjs|mjs)\//, '/src/');
9
+ }
10
+
11
+ export interface SourceLinkProps {
12
+ sources?: JSONOutput.SourceReference[];
13
+ }
14
+
15
+ export function SourceLink({ sources = [] }: SourceLinkProps) {
16
+ const { siteConfig } = useDocusaurusContext();
17
+ const gitRefName = useGitRefName();
18
+
19
+ if (sources.length === 0) {
20
+ return null;
21
+ }
22
+
23
+ return (
24
+ <>
25
+ {sources.map((source) => (
26
+ <a
27
+ key={source.fileName}
28
+ className="tsd-anchor"
29
+ href={
30
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
31
+ source.url ||
32
+ `https://${siteConfig.githubHost}${
33
+ siteConfig.githubPort ? `:${siteConfig.githubPort}` : ''
34
+ }/${siteConfig.organizationName}/${
35
+ siteConfig.projectName
36
+ }/blob/${gitRefName}/${replaceWithSrc(source.fileName)}#L${source.line}`
37
+ }
38
+ rel="noreferrer"
39
+ target="_blank"
40
+ >
41
+ <i className="codicon codicon-file-code" />
42
+ </a>
43
+ ))}
44
+ </>
45
+ );
46
+ }