@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,241 @@
1
+ /* eslint-disable unicorn/no-unsafe-regex */
2
+ /* eslint-disable react/no-array-index-key */
3
+
4
+ import React, { useState } from 'react';
5
+ import { marked } from 'marked';
6
+ import { useDocsVersion } from '@docusaurus/theme-common/internal';
7
+ import MDX from '@theme/MDXComponents';
8
+ import { useReflectionMap } from '../hooks/useReflectionMap';
9
+ import { replaceLinkTokens } from '../utils/markdown';
10
+
11
+ interface Admonition {
12
+ type: 'admonition';
13
+ raw: string;
14
+ title?: string;
15
+ keyword?: string;
16
+ text: string;
17
+ tokens: marked.Token[];
18
+ }
19
+
20
+ type TokensList = (Admonition | marked.Token)[];
21
+
22
+ marked.setOptions({
23
+ gfm: true,
24
+ headerIds: false,
25
+ mangle: false,
26
+ smartLists: true,
27
+ smartypants: true,
28
+ });
29
+
30
+ const ADMONITION_START = /^:{3}([a-z]+)? *(.*)\n/;
31
+ const ADMONITION_END = '\n:::';
32
+
33
+ marked.use({
34
+ extensions: [
35
+ {
36
+ name: 'admonition',
37
+ level: 'block',
38
+ start(src) {
39
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
40
+ return src.match(ADMONITION_START)?.index!;
41
+ },
42
+ tokenizer(src, tokens) {
43
+ const match = ADMONITION_START.exec(src);
44
+
45
+ if (match) {
46
+ const keyword = match[1] ?? 'info';
47
+ const title = match[2] ? match[2].trim() : undefined;
48
+ const startIndex = match.index;
49
+ const startEndIndex = startIndex + match[0].length;
50
+ const endIndex = src.indexOf(ADMONITION_END, startEndIndex);
51
+ const endEndIndex = endIndex + 4;
52
+
53
+ const token: Admonition = {
54
+ type: 'admonition',
55
+ raw: src.slice(startIndex, endEndIndex),
56
+ text: src.slice(startEndIndex, endIndex),
57
+ title,
58
+ keyword,
59
+ tokens: [],
60
+ };
61
+
62
+ this.lexer.blockTokens(token.text, token.tokens);
63
+
64
+ return token;
65
+ }
66
+
67
+ return undefined;
68
+ },
69
+ },
70
+ ],
71
+ });
72
+
73
+ const TOKEN_TO_TAG: Record<string, keyof JSX.IntrinsicElements> = {
74
+ blockquote: 'blockquote',
75
+ br: 'br',
76
+ code: 'pre',
77
+ codespan: 'code',
78
+ def: 'span', // ???
79
+ del: 'del',
80
+ em: 'em',
81
+ escape: 'span', // ???
82
+ hr: 'hr',
83
+ html: 'div',
84
+ paragraph: 'p',
85
+ strong: 'strong',
86
+ table: 'table',
87
+ tablecell: 'td',
88
+ tablerow: 'tr',
89
+ };
90
+
91
+ function convertAstToElements(ast: TokensList): React.ReactNode[] | undefined {
92
+ const elements: React.ReactNode[] = [];
93
+ let counter = 0;
94
+
95
+ // eslint-disable-next-line complexity
96
+ ast.forEach((token) => {
97
+ // Nested tokens aren't typed for some reason...
98
+ const children = (token as unknown as { tokens: TokensList }).tokens ?? [];
99
+
100
+ switch (token.type) {
101
+ case 'code':
102
+ elements.push(
103
+ <MDX.pre key={counter} className={token.lang && `language-${token.lang}`}>
104
+ {token.text}
105
+ </MDX.pre>,
106
+ );
107
+ break;
108
+
109
+ case 'codespan':
110
+ // Non-raw is escaped and doesn't work with JSX, so use the raw value
111
+ // but remove the wrapping backticks!
112
+ elements.push(<MDX.code key={counter}>{token.raw.slice(1, -1)}</MDX.code>);
113
+ break;
114
+
115
+ case 'heading': {
116
+ const Comp = MDX[`h${token.depth}` as 'h1'];
117
+ elements.push(<Comp key={counter}>{convertAstToElements(children) ?? token.text}</Comp>);
118
+ break;
119
+ }
120
+
121
+ case 'image':
122
+ elements.push(<MDX.img key={counter} alt={token.title} src={token.href} />);
123
+ break;
124
+
125
+ case 'link':
126
+ elements.push(
127
+ <MDX.a key={counter} href={token.href} title={token.title}>
128
+ {convertAstToElements(children) ?? token.text}
129
+ </MDX.a>,
130
+ );
131
+ break;
132
+
133
+ case 'list': {
134
+ const Comp = token.ordered ? 'ol' : 'ul';
135
+ elements.push(
136
+ <Comp key={counter}>
137
+ {convertAstToElements((token.items as TokensList) ?? children)}
138
+ </Comp>,
139
+ );
140
+ break;
141
+ }
142
+
143
+ case 'list_item':
144
+ elements.push(
145
+ <li key={counter}>
146
+ {token.task && (
147
+ <>
148
+ <input checked={token.checked} type="checkbox" />{' '}
149
+ </>
150
+ )}
151
+ {convertAstToElements(children) ?? token.text}
152
+ </li>,
153
+ );
154
+ break;
155
+
156
+ case 'space':
157
+ elements.push(token.raw || ' ');
158
+ break;
159
+
160
+ case 'table':
161
+ elements.push(
162
+ <table key={counter}>
163
+ <thead>
164
+ <tr>
165
+ {token.header.map((h, i) => (
166
+ <th key={i} align={token.align[i]!}>
167
+ {convertAstToElements(h.tokens as TokensList)}
168
+ </th>
169
+ ))}
170
+ </tr>
171
+ </thead>
172
+ <tbody>
173
+ {token.rows.map((cells, i) => (
174
+ <tr key={i}>
175
+ {cells.map((c, i2) => (
176
+ <td key={i2} align={token.align[i]!}>
177
+ {convertAstToElements(c.tokens as TokensList)}
178
+ </td>
179
+ ))}
180
+ </tr>
181
+ ))}
182
+ </tbody>
183
+ </table>,
184
+ );
185
+ break;
186
+
187
+ case 'text':
188
+ elements.push(
189
+ children.length === 0 ? (
190
+ token.text
191
+ ) : (
192
+ <React.Fragment key={counter}>{convertAstToElements(children)}</React.Fragment>
193
+ ),
194
+ );
195
+ break;
196
+
197
+ case 'admonition':
198
+ elements.push(
199
+ <MDX.admonition key={counter} title={token.title} type={token.keyword as 'note'}>
200
+ {convertAstToElements(children) ?? token.text}
201
+ </MDX.admonition>,
202
+ );
203
+ break;
204
+
205
+ default: {
206
+ const Comp = TOKEN_TO_TAG[token.type] || token.type;
207
+ const innerText = 'text' in token ? token.text : '';
208
+
209
+ elements.push(<Comp key={counter}>{convertAstToElements(children) ?? innerText}</Comp>);
210
+ break;
211
+ }
212
+ }
213
+
214
+ counter += 1;
215
+ });
216
+
217
+ if (elements.length === 0) {
218
+ return undefined;
219
+ }
220
+
221
+ return elements;
222
+ }
223
+
224
+ export interface MarkdownProps {
225
+ content: string;
226
+ }
227
+
228
+ // Too bad we cant use `@mdx-js` here...
229
+ export function Markdown({ content }: MarkdownProps) {
230
+ const reflections = useReflectionMap();
231
+ const version = useDocsVersion();
232
+ const [ast] = useState<TokensList>(() =>
233
+ marked.lexer(replaceLinkTokens(content, reflections, version)),
234
+ );
235
+
236
+ if (!content) {
237
+ return null;
238
+ }
239
+
240
+ return <div className="tsd-markdown markdown">{convertAstToElements(ast)}</div>;
241
+ }
@@ -0,0 +1,64 @@
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 { useReflection } from '../hooks/useReflection';
6
+ import { useReflectionMap } from '../hooks/useReflectionMap';
7
+ import { hasOwnDocument } from '../utils/visibility';
8
+ import { AnchorLink } from './AnchorLink';
9
+ import { CommentBadges, isCommentWithModifiers } from './CommentBadges';
10
+ import { Flags } from './Flags';
11
+ import { MemberDeclaration } from './MemberDeclaration';
12
+ import { MemberGetterSetter } from './MemberGetterSetter';
13
+ import { MemberReference } from './MemberReference';
14
+ import { MemberSignatures } from './MemberSignatures';
15
+ import { SourceLink } from './SourceLink';
16
+
17
+ export interface MemberProps {
18
+ id: number;
19
+ }
20
+
21
+ export function Member({ id }: MemberProps) {
22
+ const reflections = useReflectionMap();
23
+ const reflection = useReflection(id)!;
24
+ const { comment } = reflection;
25
+ let content: React.ReactNode = null;
26
+
27
+ if (reflection.signatures) {
28
+ content = <MemberSignatures inPanel sigs={reflection.signatures} />;
29
+ } else if (reflection.getSignature || reflection.setSignature) {
30
+ content = (
31
+ <MemberGetterSetter
32
+ inPanel
33
+ getter={reflection.getSignature}
34
+ setter={reflection.setSignature}
35
+ />
36
+ );
37
+ } else if ('target' in reflection && (reflection as JSONOutput.ReferenceReflection).target) {
38
+ content = <MemberReference reflection={reflection as JSONOutput.ReferenceReflection} />;
39
+ } else {
40
+ content = <MemberDeclaration id={id} />;
41
+ }
42
+
43
+ return (
44
+ <section className="tsd-panel tsd-member">
45
+ <h3 className="tsd-panel-header">
46
+ <AnchorLink id={reflection.name} />
47
+ <SourceLink sources={reflection.sources} />
48
+ <Flags flags={reflection.flags} />
49
+ {reflection.name}
50
+ {isCommentWithModifiers(comment) && <CommentBadges comment={comment} />}
51
+ </h3>
52
+
53
+ {content}
54
+
55
+ {reflection.groups?.map((group) => (
56
+ <React.Fragment key={group.title}>
57
+ {group.children?.map((child) =>
58
+ hasOwnDocument(child, reflections) ? null : <Member key={child} id={child} />,
59
+ )}
60
+ </React.Fragment>
61
+ ))}
62
+ </section>
63
+ );
64
+ }
@@ -0,0 +1,67 @@
1
+ // https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.declaration.hbs
2
+
3
+ import React from 'react';
4
+ import { useMinimalLayout } from '../hooks/useMinimalLayout';
5
+ import { useReflection } from '../hooks/useReflection';
6
+ import { Comment, hasComment } from './Comment';
7
+ import { DefaultValue } from './DefaultValue';
8
+ import { Icon } from './Icon';
9
+ import { MemberSources } from './MemberSources';
10
+ import { Parameter } from './Parameter';
11
+ import { Type } from './Type';
12
+ import { TypeParameters } from './TypeParameters';
13
+ import { TypeParametersGeneric } from './TypeParametersGeneric';
14
+
15
+ export interface MemberDeclarationProps {
16
+ id: number;
17
+ }
18
+
19
+ export function MemberDeclaration({ id }: MemberDeclarationProps) {
20
+ const reflection = useReflection(id)!;
21
+ const minimal = useMinimalLayout();
22
+ const showTypes = reflection.typeParameters && reflection.typeParameters.length > 0;
23
+ const showDeclaration = !minimal && reflection.type?.declaration;
24
+
25
+ return (
26
+ <>
27
+ <div className="tsd-panel-content">
28
+ <div className="tsd-signature tsd-kind-icon">
29
+ <Icon reflection={reflection} />
30
+ {reflection.name}
31
+ <TypeParametersGeneric params={reflection.typeParameters} />
32
+ <span className="tsd-signature-symbol">{reflection.flags?.isOptional && '?'}: </span>{' '}
33
+ <Type type={reflection.type} />
34
+ <DefaultValue
35
+ comment={reflection.comment}
36
+ type={reflection.type}
37
+ value={reflection.defaultValue}
38
+ />
39
+ </div>
40
+ </div>
41
+
42
+ <div className="tsd-panel-content">
43
+ <MemberSources reflection={reflection} />
44
+
45
+ <Comment comment={reflection.comment} />
46
+
47
+ {hasComment(reflection.comment) && (showTypes || showDeclaration) && (
48
+ <hr className="tsd-divider" />
49
+ )}
50
+
51
+ {showTypes && (
52
+ <div className="tds-type-parameters">
53
+ <h4 className="tsd-type-parameters-title">Type parameters</h4>
54
+ <TypeParameters params={reflection.typeParameters} />
55
+ </div>
56
+ )}
57
+
58
+ {showDeclaration && (
59
+ <div className="tsd-type-declaration">
60
+ <h4>Type declaration</h4>
61
+ <Parameter param={reflection.type?.declaration} />
62
+ </div>
63
+ )}
64
+ </div>
65
+ </>
66
+ );
67
+ }
@@ -0,0 +1,69 @@
1
+ // https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.getterSetter.hbs
2
+
3
+ import React from 'react';
4
+ import type { JSONOutput } from 'typedoc';
5
+ import { useMinimalLayout } from '../hooks/useMinimalLayout';
6
+ import { Icon } from './Icon';
7
+ import { hasSigBody, MemberSignatureBody } from './MemberSignatureBody';
8
+ import { MemberSignatureTitle } from './MemberSignatureTitle';
9
+
10
+ export interface MemberGetterSetterProps {
11
+ inPanel?: boolean;
12
+ getter?: JSONOutput.DeclarationReflection['getSignature'];
13
+ setter?: JSONOutput.DeclarationReflection['setSignature'];
14
+ }
15
+
16
+ // eslint-disable-next-line complexity
17
+ export function MemberGetterSetter({ inPanel, getter, setter }: MemberGetterSetterProps) {
18
+ const minimal = useMinimalLayout();
19
+
20
+ if (!getter && !setter) {
21
+ return null;
22
+ }
23
+
24
+ return (
25
+ <>
26
+ {(getter || setter) && (
27
+ <div className={inPanel ? 'tsd-panel-content' : ''}>
28
+ <ul className="tsd-signatures">
29
+ {getter && (
30
+ <li className="tsd-signature tsd-kind-icon">
31
+ <Icon reflection={getter} />
32
+ <span className="tsd-signature-symbol">get </span>
33
+ {getter.name}
34
+ <MemberSignatureTitle hideName sig={getter} />
35
+ </li>
36
+ )}
37
+
38
+ {setter && (
39
+ <li className="tsd-signature tsd-kind-icon">
40
+ <Icon reflection={setter} />
41
+ <span className="tsd-signature-symbol">set </span>
42
+ {setter.name}
43
+ <MemberSignatureTitle hideName sig={setter} />
44
+ </li>
45
+ )}
46
+ </ul>
47
+ </div>
48
+ )}
49
+
50
+ {(hasSigBody(getter, minimal) || hasSigBody(setter, minimal)) && (
51
+ <div className={inPanel ? 'tsd-panel-content' : ''}>
52
+ <ul className="tsd-descriptions">
53
+ {getter && (
54
+ <li className="tsd-description">
55
+ <MemberSignatureBody sig={getter} />
56
+ </li>
57
+ )}
58
+
59
+ {setter && (
60
+ <li className="tsd-description">
61
+ <MemberSignatureBody sig={setter} />
62
+ </li>
63
+ )}
64
+ </ul>
65
+ </div>
66
+ )}
67
+ </>
68
+ );
69
+ }
@@ -0,0 +1,43 @@
1
+ // https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.reference.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 MemberReferenceProps {
9
+ reflection: JSONOutput.ReferenceReflection;
10
+ }
11
+
12
+ export function MemberReference({ reflection }: MemberReferenceProps) {
13
+ const target = useReflection(reflection.target);
14
+ let content: React.ReactNode = null;
15
+
16
+ if (!target) {
17
+ content = (
18
+ <>
19
+ Re-exports <span className="tsd-signature-type">{reflection.name}</span>
20
+ </>
21
+ );
22
+ } else if (reflection.name === target.name) {
23
+ content = (
24
+ <>
25
+ Re-exports{' '}
26
+ <Link className="tsd-signature-type" to={target.permalink}>
27
+ {target.name}
28
+ </Link>
29
+ </>
30
+ );
31
+ } else {
32
+ content = (
33
+ <>
34
+ Renames and re-exports{' '}
35
+ <Link className="tsd-signature-type" to={target.permalink}>
36
+ {target.name}
37
+ </Link>
38
+ </>
39
+ );
40
+ }
41
+
42
+ return <div className="tsd-panel-content">{content}</div>;
43
+ }
@@ -0,0 +1,121 @@
1
+ // https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.signature.body.hbs
2
+
3
+ import React from 'react';
4
+ import type { JSONOutput } from 'typedoc';
5
+ import { useMinimalLayout } from '../hooks/useMinimalLayout';
6
+ import { Comment, hasComment } from './Comment';
7
+ import { CommentBadges, isCommentWithModifiers } from './CommentBadges';
8
+ import { DefaultValue } from './DefaultValue';
9
+ import { Flags } from './Flags';
10
+ import { hasSources, MemberSources } from './MemberSources';
11
+ import { Parameter } from './Parameter';
12
+ import { Type } from './Type';
13
+ import { TypeParameters } from './TypeParameters';
14
+
15
+ export function hasSigBody(
16
+ sig: JSONOutput.SignatureReflection | undefined,
17
+ minimal: boolean,
18
+ hideSources: boolean = false,
19
+ ) {
20
+ if (!sig) {
21
+ return false;
22
+ }
23
+
24
+ return (
25
+ (!hideSources && hasSources(sig)) ||
26
+ hasComment(sig.comment) ||
27
+ (sig.typeParameter && sig.typeParameter.length > 0) ||
28
+ (!minimal && sig.parameters && sig.parameters.length > 0) ||
29
+ (!minimal && sig.type)
30
+ );
31
+ }
32
+
33
+ export interface MemberSignatureBodyProps {
34
+ hideSources?: boolean;
35
+ sig: JSONOutput.SignatureReflection;
36
+ }
37
+
38
+ function intoReturnComment(comment?: JSONOutput.Comment): JSONOutput.Comment | undefined {
39
+ if (comment?.blockTags) {
40
+ const tags = comment.blockTags.map((tag) => tag.tag);
41
+
42
+ if (tags.includes('@returns')) {
43
+ const index = tags.indexOf('@returns');
44
+
45
+ return {
46
+ summary: comment.blockTags[index].content,
47
+ };
48
+ }
49
+ }
50
+
51
+ return undefined;
52
+ }
53
+
54
+ const HIDE_TAGS = ['@returns', '@param'];
55
+
56
+ // eslint-disable-next-line complexity
57
+ export function MemberSignatureBody({ hideSources, sig }: MemberSignatureBodyProps) {
58
+ const minimal = useMinimalLayout();
59
+ const showTypes = sig.typeParameter && sig.typeParameter.length > 0;
60
+ const showParams = !minimal && sig.parameters && sig.parameters.length > 0;
61
+ const showReturn = !minimal && sig.type;
62
+
63
+ return (
64
+ <>
65
+ {!hideSources && <MemberSources reflection={sig} />}
66
+
67
+ {isCommentWithModifiers(sig.comment) && <CommentBadges comment={sig.comment} />}
68
+
69
+ <Comment comment={sig.comment} hideTags={HIDE_TAGS} />
70
+
71
+ {hasComment(sig.comment) && (showTypes || showParams || showReturn) && (
72
+ <hr className="tsd-divider" />
73
+ )}
74
+
75
+ {showTypes && (
76
+ <>
77
+ <h4 className="tsd-type-parameters-title">Type parameters</h4>
78
+ <TypeParameters params={sig.typeParameter} />
79
+ </>
80
+ )}
81
+
82
+ {showParams && (
83
+ <>
84
+ <h4 className="tsd-parameters-title">Parameters</h4>
85
+
86
+ <ul className="tsd-parameters">
87
+ {sig.parameters?.map((param) => (
88
+ <li key={param.id}>
89
+ <h5>
90
+ {param.flags?.isRest && <span className="tsd-signature-symbol">...</span>}
91
+ {`${param.name}: `}
92
+ <Type type={param.type} />
93
+ <DefaultValue
94
+ comment={param.comment}
95
+ type={param.type}
96
+ value={param.defaultValue}
97
+ />
98
+ <Flags flags={param.flags} />
99
+ </h5>
100
+
101
+ <Comment comment={param.comment} />
102
+ </li>
103
+ ))}
104
+ </ul>
105
+ </>
106
+ )}
107
+
108
+ {showReturn && (
109
+ <>
110
+ <h4 className="tsd-returns-title">
111
+ Returns <Type type={sig.type} />
112
+ </h4>
113
+
114
+ <Comment comment={intoReturnComment(sig.comment)} />
115
+
116
+ <Parameter param={sig.type?.declaration} />
117
+ </>
118
+ )}
119
+ </>
120
+ );
121
+ }
@@ -0,0 +1,65 @@
1
+ /* eslint-disable no-nested-ternary */
2
+ // https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.signature.title.hbs
3
+
4
+ import React from 'react';
5
+ import { JSONOutput } from 'typedoc';
6
+ import { Type } from './Type';
7
+ import { TypeParametersGeneric } from './TypeParametersGeneric';
8
+
9
+ export interface MemberSignatureTitleProps {
10
+ useArrow?: boolean;
11
+ hideName?: boolean;
12
+ sig: JSONOutput.SignatureReflection & { modifiers?: string[] };
13
+ }
14
+
15
+ export function MemberSignatureTitle({ useArrow, hideName, sig }: MemberSignatureTitleProps) {
16
+ // add `*` before the first keyword-only parameter
17
+ const parametersCopy = sig.parameters?.slice() ?? [];
18
+ const firstKeywordOnlyIndex = parametersCopy.findIndex((param) => Object.keys(param.flags).includes('keyword-only'));
19
+ if (firstKeywordOnlyIndex >= 0) {
20
+ parametersCopy.splice(firstKeywordOnlyIndex, 0, {
21
+ id: 999_999,
22
+ name: '*',
23
+ kind: 32_768,
24
+ flags: { },
25
+ permalink: '',
26
+ });
27
+ }
28
+
29
+ return (
30
+ <>
31
+ {!hideName && sig.name !== '__type' ? (
32
+ <span>{(sig.modifiers ?? []).join(' ')}<b>{sig.name}</b></span>
33
+ ) : sig.kindString === 'Constructor signature' ? (
34
+ <>
35
+ {sig.flags?.isAbstract && <span className="tsd-signature-symbol">abstract </span>}
36
+ <span className="tsd-signature-symbol">new </span>
37
+ </>
38
+ ) : null}
39
+
40
+ <TypeParametersGeneric params={sig.typeParameter} />
41
+
42
+ <span className="tsd-signature-symbol">(</span>
43
+
44
+ {parametersCopy.map((param, index) => (
45
+ <React.Fragment key={param.id}>
46
+ {index > 0 && <span className="tsd-signature-symbol">, </span>}
47
+
48
+ <span>
49
+ {param.flags?.isRest && <span className="tsd-signature-symbol">...</span>}
50
+ {param.name}
51
+ </span>
52
+ </React.Fragment>
53
+ ))}
54
+
55
+ <span className="tsd-signature-symbol">)</span>
56
+
57
+ {sig.type && (
58
+ <>
59
+ <span className="tsd-signature-symbol">{useArrow ? ' => ' : ': '}</span>
60
+ <Type type={sig.type} />
61
+ </>
62
+ )}
63
+ </>
64
+ );
65
+ }