@apify/docusaurus-plugin-typedoc-api 4.2.10 → 4.2.11-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/lib/components/ApiItem.js +97 -2
  2. package/lib/components/ApiItem.js.map +1 -1
  3. package/lib/components/ApiPage.js +0 -3
  4. package/lib/components/ApiPage.js.map +1 -1
  5. package/lib/components/Markdown.js +0 -2
  6. package/lib/components/Markdown.js.map +1 -1
  7. package/lib/components/MemberGetterSetter.js +0 -1
  8. package/lib/components/MemberGetterSetter.js.map +1 -1
  9. package/lib/components/MemberSignatureBody.js +2 -7
  10. package/lib/components/MemberSignatureBody.js.map +1 -1
  11. package/lib/components/Reflection.js +0 -1
  12. package/lib/components/Reflection.js.map +1 -1
  13. package/lib/components/SourceLink.js +5 -1
  14. package/lib/components/SourceLink.js.map +1 -1
  15. package/lib/components/Type.js +2 -3
  16. package/lib/components/Type.js.map +1 -1
  17. package/lib/index.js +23 -10
  18. package/lib/index.js.map +1 -1
  19. package/lib/plugin/data.js +1 -9
  20. package/lib/plugin/data.js.map +1 -1
  21. package/lib/plugin/python/consts.js +47 -0
  22. package/lib/plugin/python/consts.js.map +1 -0
  23. package/lib/plugin/python/index.js +36 -0
  24. package/lib/plugin/python/index.js.map +1 -0
  25. package/lib/plugin/python/inheritance.js +71 -0
  26. package/lib/plugin/python/inheritance.js.map +1 -0
  27. package/lib/plugin/python/packageVersions.js +46 -0
  28. package/lib/plugin/python/packageVersions.js.map +1 -0
  29. package/lib/plugin/python/transformation.js +359 -0
  30. package/lib/plugin/python/transformation.js.map +1 -0
  31. package/lib/plugin/python/type-parsing/index.js +79 -0
  32. package/lib/plugin/python/type-parsing/index.js.map +1 -0
  33. package/lib/plugin/python/types.js +2 -0
  34. package/lib/plugin/python/types.js.map +1 -0
  35. package/lib/plugin/python/utils.js +106 -0
  36. package/lib/plugin/python/utils.js.map +1 -0
  37. package/lib/plugin/structure/0.23.js +0 -2
  38. package/lib/plugin/structure/0.23.js.map +1 -1
  39. package/lib/utils/icons.js +1 -2
  40. package/lib/utils/icons.js.map +1 -1
  41. package/lib/utils/reexports.js +96 -0
  42. package/lib/utils/reexports.js.map +1 -0
  43. package/package.json +5 -3
  44. package/src/components/ApiItem.tsx +103 -9
  45. package/src/components/ApiItemLayout.tsx +4 -2
  46. package/src/components/ApiOptionsLayout.tsx +18 -16
  47. package/src/components/ApiPage.tsx +0 -2
  48. package/src/components/DefaultValue.tsx +0 -1
  49. package/src/components/Flags.tsx +1 -1
  50. package/src/components/Markdown.tsx +0 -1
  51. package/src/components/Member.tsx +19 -17
  52. package/src/components/MemberGetterSetter.tsx +0 -1
  53. package/src/components/MemberSignatureBody.tsx +42 -38
  54. package/src/components/MemberSignatureTitle.tsx +18 -15
  55. package/src/components/Reflection.tsx +1 -1
  56. package/src/components/SourceLink.tsx +6 -8
  57. package/src/components/Type.tsx +6 -14
  58. package/src/components/VersionBanner.tsx +5 -1
  59. package/src/index.ts +39 -9
  60. package/src/plugin/data.ts +6 -12
  61. package/src/plugin/python/consts.ts +50 -0
  62. package/src/plugin/python/docspec-gen/__init__.py +0 -0
  63. package/src/plugin/python/docspec-gen/generate_ast.py +73 -0
  64. package/src/plugin/python/docspec-gen/google_docstring_processor.py +185 -0
  65. package/src/plugin/python/index.ts +47 -0
  66. package/src/plugin/python/inheritance.ts +80 -0
  67. package/src/plugin/python/packageVersions.ts +43 -0
  68. package/src/plugin/python/transformation.ts +444 -0
  69. package/src/plugin/python/type-parsing/index.ts +88 -0
  70. package/src/plugin/python/type-parsing/parse_types.py +82 -0
  71. package/src/plugin/python/types.ts +83 -0
  72. package/src/plugin/python/utils.ts +123 -0
  73. package/src/plugin/structure/0.23.ts +0 -2
  74. package/src/plugin/version.ts +2 -2
  75. package/src/types.ts +9 -0
  76. package/src/utils/icons.ts +4 -3
  77. package/src/utils/reexports.ts +105 -0
@@ -0,0 +1,96 @@
1
+ 'use strict';
2
+
3
+ const cheerio = require('cheerio');
4
+ const fs = require('node:fs');
5
+ const _interopDefault = e => e && e.__esModule ? e : {
6
+ default: e
7
+ };
8
+ const fs__default = /*#__PURE__*/_interopDefault(fs);
9
+
10
+ /* eslint-disable */
11
+ // @ts-nocheck
12
+
13
+ async function loadExternalApiItem(url) {
14
+ console.log(`Loading external API item from ${url}...`);
15
+ const response = await fetch(url);
16
+ const $ = cheerio.load(await response.text(), {
17
+ decodeEntities: false
18
+ });
19
+ const base64encoded = $('script[type="application/typedoc-data;base64"]')?.first()?.text();
20
+ if (!base64encoded) return null;
21
+ const jsonData = atob(base64encoded);
22
+ return JSON.parse(jsonData);
23
+ }
24
+
25
+ // Recursively find the maximum numerical `id` property in a JS object
26
+ function getMaxId(obj) {
27
+ let maxId = 0;
28
+ for (const key in obj) {
29
+ if (typeof obj[key] === 'object') {
30
+ maxId = Math.max(maxId, getMaxId(obj[key]));
31
+ } else if (key === 'id') {
32
+ maxId = Math.max(maxId, obj[key]);
33
+ }
34
+ }
35
+ return maxId;
36
+ }
37
+ function incrementIds(obj, increment) {
38
+ let max = 0;
39
+ for (const key in obj) {
40
+ if (key === 'children' && Array.isArray(obj[key]) && obj[key].every(c => typeof c === 'number')) {
41
+ obj[key] = obj[key].map(c => c + increment);
42
+ max = Math.max(max, ...obj[key]);
43
+ } else if (key === 'id' && Number.isInteger(obj[key])) {
44
+ obj[key] += increment;
45
+ max = Math.max(obj[key], max);
46
+ } else if (obj[key] && typeof obj[key] === 'object') {
47
+ max = Math.max(incrementIds(obj[key], increment), max);
48
+ }
49
+ }
50
+ return max;
51
+ }
52
+ async function injectReexports(typedocJsonFilePath, reexports) {
53
+ const typedocJson = await import(typedocJsonFilePath);
54
+ let baseId = getMaxId(typedocJson);
55
+ const externalApiItems = await Promise.all(reexports.map(async ({
56
+ url,
57
+ group
58
+ }) => ({
59
+ externalItem: await loadExternalApiItem(url),
60
+ customGroup: group
61
+ })));
62
+ for (const _ref of externalApiItems) {
63
+ const externalItem = _ref.externalItem;
64
+ const customGroup = _ref.customGroup;
65
+ if (!externalItem) continue;
66
+ let item = externalItem.item,
67
+ groups = externalItem.groups;
68
+
69
+ // Make sure the new item doesn't have any conflicting IDs
70
+ baseId = incrementIds(item, baseId);
71
+
72
+ // Add the new item to the root children
73
+ typedocJson.children.push(item);
74
+ if (customGroup) {
75
+ groups = [customGroup];
76
+ } else if (groups.length === 0) {
77
+ groups = ['Reexports'];
78
+ }
79
+ for (const groupName of groups) {
80
+ // Assign the new item into the specified groups
81
+ const reexportsGroup = typedocJson.groups.find(g => g.title === groupName);
82
+ if (reexportsGroup) {
83
+ reexportsGroup.children.push(item.id);
84
+ } else {
85
+ typedocJson.groups.push({
86
+ title: groupName,
87
+ children: [item.id]
88
+ });
89
+ }
90
+ }
91
+ console.log(`Reexported item ${item.name} from ${item.sources[0].fileName} to ${groups.join(', ')}`);
92
+ }
93
+ fs__default.default.writeFileSync(typedocJsonFilePath, JSON.stringify(typedocJson, null, 4));
94
+ }
95
+ exports.injectReexports = injectReexports;
96
+ //# sourceMappingURL=reexports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reexports.js","sources":["../../src/utils/reexports.ts"],"sourcesContent":null,"names":["load","fs"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AAGA,eAAe,mBAAmB,CAAC,GAAG,EAAE;AACxC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,+BAA+B,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1D,EAAE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;AACpC,EAAE,MAAM,CAAC,GAAGA,YAAI,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE;AACxC,IAAI,cAAc,EAAE,KAAK;AACzB,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,aAAa,GAAG,CAAC,CAAC,gDAAgD,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC;AAC7F,EAAE,IAA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 +1,6 @@
1
1
  {
2
2
  "name": "@apify/docusaurus-plugin-typedoc-api",
3
- "version": "4.2.10",
3
+ "version": "4.2.11-1",
4
4
  "description": "Docusaurus plugin that provides source code API documentation powered by TypeDoc. ",
5
5
  "keywords": [
6
6
  "docusaurus",
@@ -32,7 +32,8 @@
32
32
  "@theme/*",
33
33
  "@docusaurus/*",
34
34
  "@vscode/*",
35
- "css$"
35
+ "css$",
36
+ "cheerio*"
36
37
  ]
37
38
  },
38
39
  "peerDependencies": {
@@ -59,5 +60,6 @@
59
60
  "react": "^18.2.0",
60
61
  "react-dom": "^18.2.0",
61
62
  "typescript": "^5.3.3"
62
- }
63
+ },
64
+ "stableVersion": "4.2.10"
63
65
  }
@@ -1,6 +1,10 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  import { createContext, useMemo, useState } from 'react';
2
3
  import { PageMetadata } from '@docusaurus/theme-common';
4
+ import type { DocusaurusConfig } from '@docusaurus/types';
5
+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
3
6
  import type { Props as DocItemProps } from '@theme/DocItem';
7
+ import { useGitRefName } from '../hooks/useGitRefName';
4
8
  import { useReflection, useRequiredReflection } from '../hooks/useReflection';
5
9
  import { useReflectionMap } from '../hooks/useReflectionMap';
6
10
  import type { TOCItem, TSDDeclarationReflection, TSDDeclarationReflectionMap } from '../types';
@@ -10,6 +14,7 @@ import ApiItemLayout from './ApiItemLayout';
10
14
  import { displayPartsToMarkdown } from './Comment';
11
15
  import { Flags } from './Flags';
12
16
  import { Reflection } from './Reflection';
17
+ import { resolveGithubUrl } from './SourceLink';
13
18
  import { TypeParametersGeneric } from './TypeParametersGeneric';
14
19
 
15
20
  function extractTOC(
@@ -23,9 +28,9 @@ function extractTOC(
23
28
  item.groups?.forEach((group) => {
24
29
  group.children?.forEach((childId) => {
25
30
  const child = map[childId];
26
- const shouldShow = child.inheritedFrom ? !hideInherited : true;
31
+ const shouldShow = child?.inheritedFrom ? !hideInherited : true;
27
32
 
28
- if (!shouldShow || mapped.has(child.name)) {
33
+ if (!child || !shouldShow || mapped.has(child.name)) {
29
34
  return;
30
35
  }
31
36
 
@@ -55,19 +60,84 @@ export interface ApiItemProps extends Pick<DocItemProps, 'route'> {
55
60
 
56
61
  export const ApiOptionsContext = createContext({
57
62
  hideInherited: false,
58
- setHideInherited: (hideInherited: boolean) => {}
63
+ setHideInherited: (hideInherited: boolean) => {},
59
64
  });
60
65
 
66
+ // Recursively traverse the passed object. If the object has a `sources` property, resolve the GitHub URLs.
67
+ function resolveGithubUrls(obj: { sources?: { url?: string; fileName: string; line: number; character: number }[] }, siteConfig: DocusaurusConfig, gitRefName: string) {
68
+ if (!obj) return;
69
+
70
+ if (obj.sources) {
71
+ obj.sources.forEach((source) => {
72
+ source.url = resolveGithubUrl(source, siteConfig, gitRefName);
73
+ });
74
+ }
75
+
76
+ for (const key in obj) {
77
+ if (typeof obj[key as keyof typeof obj] === 'object') {
78
+ resolveGithubUrls(obj[key as keyof typeof obj] as { sources?: { url?: string; fileName: string; line: number; character: number }[] }, siteConfig, gitRefName);
79
+ }
80
+ }
81
+ }
82
+
83
+ function resolveTypeReferences(obj: { type?: "reference", target?: number, ref?: TSDDeclarationReflection }, reflectionMap: TSDDeclarationReflectionMap, baseUrl: string) {
84
+ if (!obj) return;
85
+
86
+ if (obj.type === 'reference') {
87
+ const reflectionIdentifier: number = obj.target ?? (obj as { id: number }).id;
88
+ const ref = reflectionIdentifier ? reflectionMap[Number(reflectionIdentifier)] : null;
89
+ obj.target = obj.target ? obj.target : 0;
90
+
91
+ const { id, sources, kind, permalink } = ref ?? {};
92
+ // @ts-expect-error Partial reexports
93
+ obj.ref = { id, sources, kind, permalink };
94
+ if (ref && obj.ref) obj.ref.permalink = new URL(ref?.permalink ?? '', baseUrl).toString();
95
+ }
96
+
97
+ for (const key in obj) {
98
+ if (typeof obj[key as keyof typeof obj] === 'object') {
99
+ resolveTypeReferences(obj[key as keyof typeof obj] as { type?: "reference", target?: number, permalink?: string }, reflectionMap, baseUrl);
100
+ }
101
+ }
102
+ }
103
+
104
+ function getOwnGroupNames(reflection: TSDDeclarationReflection, reflections: TSDDeclarationReflectionMap): string[] {
105
+ const parent = reflections[(reflection as unknown as { parentId: number }).parentId]
106
+
107
+ return parent?.groups?.filter(
108
+ ({ children }) => children?.includes(reflection.id)
109
+ ).map(({ title }) => title) ?? [];
110
+ }
111
+
112
+ function deepCopy(obj: any): any {
113
+ if (typeof obj !== 'object') return obj;
114
+
115
+ const copy: any = Array.isArray(obj) ? [] : {};
116
+ // eslint-disable-next-line guard-for-in
117
+ for (const key in obj) {
118
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
119
+ copy[key as keyof typeof copy] = deepCopy(obj[key as keyof typeof obj]);
120
+ }
121
+
122
+ return copy;
123
+ }
124
+
61
125
  export default function ApiItem({ readme: Readme, route }: ApiItemProps) {
62
126
  const [hideInherited, setHideInherited] = useState(false);
63
- const apiOptions = useMemo(() => ({
64
- hideInherited,
65
- setHideInherited,
66
- }), [hideInherited, setHideInherited]);
127
+ const apiOptions = useMemo(
128
+ () => ({
129
+ hideInherited,
130
+ setHideInherited,
131
+ }),
132
+ [hideInherited, setHideInherited],
133
+ );
67
134
 
68
135
  const item = useRequiredReflection((route as unknown as { id: number }).id);
69
136
  const reflections = useReflectionMap();
70
- const toc = useMemo(() => extractTOC(item, reflections, hideInherited), [item, reflections, hideInherited]);
137
+ const toc = useMemo(
138
+ () => extractTOC(item, reflections, hideInherited),
139
+ [item, reflections, hideInherited],
140
+ );
71
141
 
72
142
  // Pagination
73
143
  const prevItem = useReflection(item.previousId);
@@ -90,6 +160,17 @@ export default function ApiItem({ readme: Readme, route }: ApiItemProps) {
90
160
  [nextItem, prevItem],
91
161
  );
92
162
 
163
+ const { siteConfig } = useDocusaurusContext();
164
+ const gitRefName = useGitRefName();
165
+
166
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
167
+ const apiItem = deepCopy(item);
168
+
169
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
170
+ resolveGithubUrls(apiItem, siteConfig, gitRefName);
171
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
172
+ resolveTypeReferences(apiItem, reflections, new URL(siteConfig.baseUrl, siteConfig.url).href);
173
+
93
174
  return (
94
175
  <ApiOptionsContext.Provider value={apiOptions}>
95
176
  <ApiItemLayout
@@ -117,7 +198,20 @@ export default function ApiItem({ readme: Readme, route }: ApiItemProps) {
117
198
  </section>
118
199
  )}
119
200
 
120
- <Reflection reflection={item} />
201
+ <Reflection reflection={item} />
202
+ {/* The `application/json+typedoc-data;base64` is an base64 encoded JSON object that contains the machine-readable API item data. */}
203
+ <script type="application/typedoc-data;base64">{btoa(JSON.stringify(
204
+ {
205
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
206
+ item: {
207
+ ...apiItem,
208
+ nextId: undefined,
209
+ previousId: undefined,
210
+ parentId: undefined,
211
+ },
212
+ groups: getOwnGroupNames(item, reflections),
213
+ },
214
+ ))}</script>
121
215
  </ApiItemLayout>
122
216
  </ApiOptionsContext.Provider>
123
217
  );
@@ -14,7 +14,7 @@ import TOC from '@theme/TOC';
14
14
  import TOCCollapsible from '@theme/TOCCollapsible';
15
15
  import { useBreadcrumbs } from '../hooks/useBreadcrumbs';
16
16
  import type { TOCItem } from '../types';
17
- import ApiOptionsLayout from './ApiOptionsLayout'
17
+ import ApiOptionsLayout from './ApiOptionsLayout';
18
18
  import { VersionBanner } from './VersionBanner';
19
19
 
20
20
  export interface ApiItemLayoutProps extends Pick<DocItemProps, 'route'> {
@@ -72,7 +72,9 @@ export default function ApiItemLayout({
72
72
  <div className={`${ThemeClassNames.docs.docMarkdown ?? ''} markdown`}>
73
73
  <header>
74
74
  <Heading as="h1">{heading}</Heading>
75
- {module && <code className="tsd-header-member-fullname">{`${module}.${name}`}</code>}
75
+ {module && (
76
+ <code className="tsd-header-member-fullname">{`${module}.${name}`}</code>
77
+ )}
76
78
  </header>
77
79
 
78
80
  <MDXContent>{children}</MDXContent>
@@ -2,21 +2,23 @@ import { useCallback, useContext } from 'react';
2
2
  import { ApiOptionsContext } from './ApiItem';
3
3
 
4
4
  export default function ApiOptionsLayout({ className }: { className: string }) {
5
- const { hideInherited, setHideInherited } = useContext(ApiOptionsContext);
6
- const handleHideInherited = useCallback(() => {
7
- setHideInherited(!hideInherited);
8
- }, [hideInherited, setHideInherited]);
5
+ const { hideInherited, setHideInherited } = useContext(ApiOptionsContext);
6
+ const handleHideInherited = useCallback(() => {
7
+ setHideInherited(!hideInherited);
8
+ }, [hideInherited, setHideInherited]);
9
9
 
10
- return (
11
- <>
12
- <div className={className}>
13
- <div><b>Page Options</b></div>
14
- <label>
15
- <input checked={hideInherited} type="checkbox" onChange={handleHideInherited} />
16
- <span>Hide Inherited</span>
17
- </label>
18
- <div />
19
- </div>
20
- </>
21
- );
10
+ return (
11
+ <>
12
+ <div className={className}>
13
+ <div>
14
+ <b>Page Options</b>
15
+ </div>
16
+ <label>
17
+ <input checked={hideInherited} type="checkbox" onChange={handleHideInherited} />
18
+ <span>Hide Inherited</span>
19
+ </label>
20
+ <div />
21
+ </div>
22
+ </>
23
+ );
22
24
  }
@@ -1,5 +1,3 @@
1
- /* eslint-disable no-param-reassign */
2
-
3
1
  import '@vscode/codicons/dist/codicon.css';
4
2
  import './styles.css';
5
3
  import { useMemo } from 'react';
@@ -34,7 +34,6 @@ export function DefaultValue({ comment, value, type }: DefaultValueProps) {
34
34
  defaultTag = decode(marked(defaultTag));
35
35
  }
36
36
 
37
-
38
37
  if (!defaultTag && !value) {
39
38
  return null;
40
39
  }
@@ -16,7 +16,7 @@ export function Flags({ flags }: FlagsProps) {
16
16
  }
17
17
 
18
18
  return (
19
- <span className='tsd-flag-group'>
19
+ <span className="tsd-flag-group">
20
20
  {Object.keys(flags)
21
21
  .map(removePrefix)
22
22
  .map((flag) => (
@@ -111,7 +111,6 @@ function convertAstToElements(ast: TokensList): React.ReactNode[] | undefined {
111
111
  const elements: React.ReactNode[] = [];
112
112
  let counter = 0;
113
113
 
114
- // eslint-disable-next-line complexity
115
114
  ast.forEach((token) => {
116
115
  // Nested tokens aren't typed for some reason...
117
116
  const children = (token as unknown as { tokens: TokensList }).tokens ?? [];
@@ -46,24 +46,26 @@ export function Member({ id }: MemberProps) {
46
46
  }
47
47
 
48
48
  return (
49
- !shouldHideInherited && <section className="tsd-panel tsd-member">
50
- <h3 className="tsd-panel-header">
51
- <AnchorLink id={reflection.name} />
52
- <SourceLink sources={reflection.sources} />
53
- <Flags flags={reflection.flags} />
54
- {escapeMdx(reflection.name)}
55
- {isCommentWithModifiers(comment) && <CommentBadges comment={comment} />}
56
- </h3>
49
+ !shouldHideInherited && (
50
+ <section className="tsd-panel tsd-member">
51
+ <h3 className="tsd-panel-header">
52
+ <AnchorLink id={reflection.name} />
53
+ <SourceLink sources={reflection.sources} />
54
+ <Flags flags={reflection.flags} />
55
+ {escapeMdx(reflection.name)}
56
+ {isCommentWithModifiers(comment) && <CommentBadges comment={comment} />}
57
+ </h3>
57
58
 
58
- {content}
59
+ {content}
59
60
 
60
- {reflection.groups?.map((group) => (
61
- <Fragment key={group.title}>
62
- {group.children?.map((child) =>
63
- hasOwnDocument(child, reflections) ? null : <Member key={child} id={child} />,
64
- )}
65
- </Fragment>
66
- ))}
67
- </section>
61
+ {reflection.groups?.map((group) => (
62
+ <Fragment key={group.title}>
63
+ {group.children?.map((child) =>
64
+ hasOwnDocument(child, reflections) ? null : <Member key={child} id={child} />,
65
+ )}
66
+ </Fragment>
67
+ ))}
68
+ </section>
69
+ )
68
70
  );
69
71
  }
@@ -13,7 +13,6 @@ export interface MemberGetterSetterProps {
13
13
  setter?: TSDDeclarationReflection['setSignature'];
14
14
  }
15
15
 
16
- // eslint-disable-next-line complexity
17
16
  export function MemberGetterSetter({ inPanel, getter, setter }: MemberGetterSetterProps) {
18
17
  const minimal = useMinimalLayout();
19
18
 
@@ -1,6 +1,6 @@
1
1
  // https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.signature.body.hbs
2
2
 
3
- import { Fragment, useContext } from 'react'
3
+ import { Fragment, useContext } from 'react';
4
4
  import type { JSONOutput, Models } from 'typedoc';
5
5
  import { type GlobalData } from '@docusaurus/types';
6
6
  import { usePluginData } from '@docusaurus/useGlobalData';
@@ -57,7 +57,6 @@ function intoReturnComment(comment?: JSONOutput.Comment): JSONOutput.Comment | u
57
57
 
58
58
  const HIDE_TAGS = ['@returns', '@param'];
59
59
 
60
- // eslint-disable-next-line complexity
61
60
  export function MemberSignatureBody({ hideSources, sig }: MemberSignatureBodyProps) {
62
61
  const minimal = useMinimalLayout();
63
62
  const showTypes = sig.typeParameter && sig.typeParameter.length > 0;
@@ -67,39 +66,37 @@ export function MemberSignatureBody({ hideSources, sig }: MemberSignatureBodyPro
67
66
  const { reflections } = useContext(ApiDataContext);
68
67
  const { isPython } = usePluginData('docusaurus-plugin-typedoc-api') as GlobalData;
69
68
 
70
-
71
69
  if (isPython) {
72
- // eslint-disable-next-line
73
70
  sig.parameters = sig.parameters?.reduce<typeof sig.parameters>((acc, param) => {
74
71
  // @ts-expect-error Silence ts errors
75
72
  switch (param.type?.name) {
76
73
  case 'Unpack':
77
74
  // @ts-expect-error Silence ts errors
78
- // eslint-disable-next-line
79
- acc.push(...reflections[param.type.typeArguments[0].target].children.map(x => ({...x, flags: {'keyword-only': true}})));
75
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
76
+ acc.push(...(reflections[param.type.typeArguments[0].target]?.children ?? []).map((x) => ({...x, flags: { 'keyword-only': true } })),
77
+ );
80
78
  break;
81
79
  default:
82
80
  acc.push(param);
83
81
  break;
84
82
  }
85
-
83
+
86
84
  return acc;
87
85
  }, []);
88
-
89
- // eslint-disable-next-line
86
+
90
87
  sig.parameters = sig.parameters?.reduce<typeof sig.parameters>((acc, param) => {
91
88
  // @ts-expect-error Silence ts errors
92
89
  switch (param.type?.name) {
93
90
  case 'NotRequired':
94
91
  // @ts-expect-error Silence ts errors
95
92
  // eslint-disable-next-line
96
- acc.push({...param, type: param.type.typeArguments[0]});
93
+ acc.push({ ...param, type: param.type.typeArguments[0] });
97
94
  break;
98
95
  default:
99
96
  acc.push(param);
100
97
  break;
101
98
  }
102
-
99
+
103
100
  return acc;
104
101
  }, []);
105
102
  }
@@ -152,7 +149,9 @@ export function MemberSignatureBody({ hideSources, sig }: MemberSignatureBodyPro
152
149
  <li key={reflectionChild.id}>
153
150
  <h5>
154
151
  <Flags flags={reflectionChild.flags} />
155
- {reflectionChild.flags?.isRest && <span className="tsd-signature-symbol">...</span>}
152
+ {reflectionChild.flags?.isRest && (
153
+ <span className="tsd-signature-symbol">...</span>
154
+ )}
156
155
  {`${reflectionChild.name}: `}
157
156
  <Type type={reflectionChild.type} />
158
157
  <DefaultValue
@@ -162,37 +161,42 @@ export function MemberSignatureBody({ hideSources, sig }: MemberSignatureBodyPro
162
161
  />
163
162
  </h5>
164
163
 
165
- <Comment comment={reflectionChild.comment as unknown as JSONOutput.Comment} />
164
+ <Comment
165
+ comment={reflectionChild.comment as unknown as JSONOutput.Comment}
166
+ />
166
167
  </li>
167
168
  ))}
168
169
  </ul>
169
170
  )}
170
171
 
171
- {param.type?.type === 'union' && (
172
- ((param.type.types.filter(
173
- (unionType) => unionType.type === 'reflection')) as unknown as Models.ReflectionType[]).map(
174
- (unionReflectionType) => (
175
- <ul key={unionReflectionType.declaration.id}>
176
- {unionReflectionType.declaration?.children?.map((unionChild) => (
177
- <li key={unionChild.id}>
178
- <h5>
179
- <Flags flags={unionChild.flags} />
180
- {unionChild.flags?.isRest && <span className="tsd-signature-symbol">...</span>}
181
- {`${unionChild.name}: `}
182
- <Type type={unionChild.type} />
183
- <DefaultValue
184
- comment={unionChild.comment as unknown as JSONOutput.Comment}
185
- type={unionChild.type}
186
- value={unionChild.defaultValue}
187
- />
188
- </h5>
189
-
190
- <Comment comment={unionChild.comment as unknown as JSONOutput.Comment} />
191
- </li>
192
- ))}
193
- </ul>
194
- ))
195
- )}
172
+ {param.type?.type === 'union' &&
173
+ (
174
+ param.type.types.filter(
175
+ (unionType) => unionType.type === 'reflection',
176
+ ) as unknown as Models.ReflectionType[]
177
+ ).map((unionReflectionType) => (
178
+ <ul key={unionReflectionType.declaration.id}>
179
+ {unionReflectionType.declaration?.children?.map((unionChild) => (
180
+ <li key={unionChild.id}>
181
+ <h5>
182
+ <Flags flags={unionChild.flags} />
183
+ {unionChild.flags?.isRest && (
184
+ <span className="tsd-signature-symbol">...</span>
185
+ )}
186
+ {`${unionChild.name}: `}
187
+ <Type type={unionChild.type} />
188
+ <DefaultValue
189
+ comment={unionChild.comment as unknown as JSONOutput.Comment}
190
+ type={unionChild.type}
191
+ value={unionChild.defaultValue}
192
+ />
193
+ </h5>
194
+
195
+ <Comment comment={unionChild.comment as unknown as JSONOutput.Comment} />
196
+ </li>
197
+ ))}
198
+ </ul>
199
+ ))}
196
200
  </Fragment>
197
201
  ))}
198
202
  </ul>
@@ -3,7 +3,7 @@
3
3
 
4
4
  import { Fragment } from 'react';
5
5
  import { usePluginData } from '@docusaurus/useGlobalData';
6
- import type { GlobalData,TSDSignatureReflection } from '../types';
6
+ import type { GlobalData, TSDSignatureReflection } from '../types';
7
7
  import { escapeMdx } from '../utils/helpers';
8
8
  import { Type } from './Type';
9
9
  import { TypeParametersGeneric } from './TypeParametersGeneric';
@@ -18,13 +18,15 @@ export function MemberSignatureTitle({ useArrow, hideName, sig }: MemberSignatur
18
18
  const { isPython } = usePluginData('docusaurus-plugin-typedoc-api') as GlobalData;
19
19
  // add `*` before the first keyword-only parameter
20
20
  const parametersCopy = sig.parameters?.slice() ?? [];
21
- const firstKeywordOnlyIndex = parametersCopy.findIndex((param) => Object.keys(param.flags).includes('keyword-only'));
21
+ const firstKeywordOnlyIndex = parametersCopy.findIndex((param) =>
22
+ Object.keys(param.flags).includes('keyword-only'),
23
+ );
22
24
  if (firstKeywordOnlyIndex >= 0) {
23
25
  parametersCopy.splice(firstKeywordOnlyIndex, 0, {
24
26
  id: 999_999,
25
27
  name: '*',
26
28
  kind: 32_768,
27
- flags: { },
29
+ flags: {},
28
30
  variant: 'param',
29
31
  });
30
32
  }
@@ -32,7 +34,10 @@ export function MemberSignatureTitle({ useArrow, hideName, sig }: MemberSignatur
32
34
  return (
33
35
  <>
34
36
  {!hideName && sig.name !== '__type' ? (
35
- <span>{sig.modifiers ? `${sig.modifiers.join(' ')} ` : ''}<b>{escapeMdx(sig.name)}</b></span>
37
+ <span>
38
+ {sig.modifiers ? `${sig.modifiers.join(' ')} ` : ''}
39
+ <b>{escapeMdx(sig.name)}</b>
40
+ </span>
36
41
  ) : // Constructor signature
37
42
  sig.kind === 16_384 ? (
38
43
  <>
@@ -52,17 +57,15 @@ export function MemberSignatureTitle({ useArrow, hideName, sig }: MemberSignatur
52
57
  <span>
53
58
  {param.flags?.isRest && <span className="tsd-signature-symbol">...</span>}
54
59
  {escapeMdx(param.name)}
55
- {
56
- !isPython && (
57
- <>
58
- <span className="tsd-signature-symbol">
59
- {(param.flags?.isOptional || 'defaultValue' in param) && '?'}
60
- {': '}
61
- </span>
62
- <Type type={param.type} />
63
- </>
64
- )
65
- }
60
+ {!isPython && (
61
+ <>
62
+ <span className="tsd-signature-symbol">
63
+ {(param.flags?.isOptional || 'defaultValue' in param) && '?'}
64
+ {': '}
65
+ </span>
66
+ <Type type={param.type} />
67
+ </>
68
+ )}
66
69
  </span>
67
70
  </Fragment>
68
71
  ))}
@@ -17,7 +17,7 @@ import { TypeParameters } from './TypeParameters';
17
17
  export interface ReflectionProps {
18
18
  reflection: TSDDeclarationReflection | TSDReflection | TSDSignatureReflection;
19
19
  }
20
- // eslint-disable-next-line complexity
20
+
21
21
  export function Reflection({ reflection }: ReflectionProps) {
22
22
  const hierarchy = useMemo(() => createHierarchy(reflection), [reflection]);
23
23