@apify/docusaurus-plugin-typedoc-api 3.0.1 → 4.2.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.
- package/README.md +27 -5
- package/lib/components/AnchorLink.js +15 -10
- package/lib/components/AnchorLink.js.map +1 -1
- package/lib/components/ApiChangelog.js +9 -11
- package/lib/components/ApiChangelog.js.map +1 -1
- package/lib/components/ApiDataContext.js +2 -2
- package/lib/components/ApiIndex.js +55 -37
- package/lib/components/ApiIndex.js.map +1 -1
- package/lib/components/ApiItem.js +33 -29
- package/lib/components/ApiItem.js.map +1 -1
- package/lib/components/ApiItemLayout.js +49 -27
- package/lib/components/ApiItemLayout.js.map +1 -1
- package/lib/components/ApiPage.js +18 -10
- package/lib/components/ApiPage.js.map +1 -1
- package/lib/components/Breadcrumb.js +27 -14
- package/lib/components/Breadcrumb.js.map +1 -1
- package/lib/components/Comment.js +24 -18
- package/lib/components/Comment.js.map +1 -1
- package/lib/components/CommentBadges.js +8 -11
- package/lib/components/CommentBadges.js.map +1 -1
- package/lib/components/DefaultValue.js +20 -20
- package/lib/components/DefaultValue.js.map +1 -1
- package/lib/components/Flags.js +9 -11
- package/lib/components/Flags.js.map +1 -1
- package/lib/components/Footer.js +11 -12
- package/lib/components/Footer.js.map +1 -1
- package/lib/components/Hierarchy.js +15 -16
- package/lib/components/Hierarchy.js.map +1 -1
- package/lib/components/Icon.js +2 -6
- package/lib/components/Icon.js.map +1 -1
- package/lib/components/Index.js +84 -62
- package/lib/components/Index.js.map +1 -1
- package/lib/components/Markdown.js +80 -66
- package/lib/components/Markdown.js.map +1 -1
- package/lib/components/Member.js +28 -28
- package/lib/components/Member.js.map +1 -1
- package/lib/components/MemberDeclaration.js +51 -42
- package/lib/components/MemberDeclaration.js.map +1 -1
- package/lib/components/MemberGetterSetter.js +50 -40
- package/lib/components/MemberGetterSetter.js.map +1 -1
- package/lib/components/MemberReference.js +27 -16
- package/lib/components/MemberReference.js.map +1 -1
- package/lib/components/MemberSignatureBody.js +57 -45
- package/lib/components/MemberSignatureBody.js.map +1 -1
- package/lib/components/MemberSignatureTitle.js +48 -27
- package/lib/components/MemberSignatureTitle.js.map +1 -1
- package/lib/components/MemberSignatures.js +46 -38
- package/lib/components/MemberSignatures.js.map +1 -1
- package/lib/components/MemberSources.js +18 -15
- package/lib/components/MemberSources.js.map +1 -1
- package/lib/components/Members.js +32 -31
- package/lib/components/Members.js.map +1 -1
- package/lib/components/MembersGroup.js +24 -22
- package/lib/components/MembersGroup.js.map +1 -1
- package/lib/components/Parameter.js +139 -109
- package/lib/components/Parameter.js.map +1 -1
- package/lib/components/Reflection.js +113 -90
- package/lib/components/Reflection.js.map +1 -1
- package/lib/components/SourceLink.js +12 -13
- package/lib/components/SourceLink.js.map +1 -1
- package/lib/components/Type.js +320 -206
- package/lib/components/Type.js.map +1 -1
- package/lib/components/TypeAndParent.js +11 -10
- package/lib/components/TypeAndParent.js.map +1 -1
- package/lib/components/TypeParameters.js +23 -20
- package/lib/components/TypeParameters.js.map +1 -1
- package/lib/components/TypeParametersGeneric.js +17 -16
- package/lib/components/TypeParametersGeneric.js.map +1 -1
- package/lib/components/VersionBanner.js +21 -9
- package/lib/components/VersionBanner.js.map +1 -1
- package/lib/hooks/useBreadcrumbs.js +2 -2
- package/lib/hooks/useGitRefName.js +2 -2
- package/lib/hooks/useMinimalLayout.js +2 -2
- package/lib/hooks/useReflection.js +10 -6
- package/lib/hooks/useReflection.js.map +1 -1
- package/lib/hooks/useReflectionMap.js +2 -2
- package/lib/index.js +62 -25
- package/lib/index.js.map +1 -1
- package/lib/plugin/data.js +61 -18
- package/lib/plugin/data.js.map +1 -1
- package/lib/plugin/version.js +5 -4
- package/lib/plugin/version.js.map +1 -1
- package/lib/utils/helpers.js +8 -0
- package/lib/utils/helpers.js.map +1 -0
- package/lib/utils/hierarchy.js +6 -3
- package/lib/utils/hierarchy.js.map +1 -1
- package/lib/utils/icons.js +2 -5
- package/lib/utils/icons.js.map +1 -1
- package/lib/utils/markdown.js +5 -7
- package/lib/utils/markdown.js.map +1 -1
- package/package.json +17 -14
- package/src/components/AnchorLink.tsx +6 -3
- package/src/components/ApiChangelog.tsx +0 -1
- package/src/components/ApiDataContext.ts +2 -2
- package/src/components/ApiIndex.tsx +1 -1
- package/src/components/ApiItem.tsx +18 -20
- package/src/components/ApiItemLayout.tsx +1 -2
- package/src/components/ApiPage.tsx +18 -13
- package/src/components/Breadcrumb.tsx +2 -3
- package/src/components/Comment.tsx +3 -4
- package/src/components/CommentBadges.tsx +0 -1
- package/src/components/DefaultValue.tsx +0 -1
- package/src/components/Flags.tsx +1 -1
- package/src/components/Footer.tsx +0 -2
- package/src/components/Hierarchy.tsx +0 -1
- package/src/components/Icon.tsx +2 -3
- package/src/components/Index.tsx +14 -19
- package/src/components/Markdown.tsx +54 -25
- package/src/components/Member.tsx +7 -6
- package/src/components/MemberDeclaration.tsx +7 -7
- package/src/components/MemberGetterSetter.tsx +6 -6
- package/src/components/MemberReference.tsx +4 -4
- package/src/components/MemberSignatureBody.tsx +5 -5
- package/src/components/MemberSignatureTitle.tsx +11 -9
- package/src/components/MemberSignatures.tsx +5 -5
- package/src/components/MemberSources.tsx +3 -5
- package/src/components/Members.tsx +3 -4
- package/src/components/MembersGroup.tsx +1 -2
- package/src/components/Parameter.tsx +7 -12
- package/src/components/README.md +1 -1
- package/src/components/Reflection.tsx +7 -10
- package/src/components/SourceLink.tsx +0 -2
- package/src/components/Type.tsx +34 -22
- package/src/components/TypeAndParent.tsx +0 -1
- package/src/components/TypeParameters.tsx +0 -1
- package/src/components/TypeParametersGeneric.tsx +3 -3
- package/src/components/VersionBanner.tsx +1 -1
- package/src/hooks/useReflection.ts +11 -4
- package/src/hooks/useReflectionMap.ts +2 -2
- package/src/index.ts +92 -39
- package/src/plugin/data.ts +123 -54
- package/src/plugin/sidebar.ts +4 -3
- package/src/types.ts +24 -33
- package/src/utils/helpers.ts +4 -0
- package/src/utils/hierarchy.ts +11 -7
- package/src/utils/icons.ts +2 -3
- package/src/utils/markdown.ts +10 -7
- package/src/utils/visibility.ts +4 -4
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.reference.hbs
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
4
3
|
import type { JSONOutput } from 'typedoc';
|
|
5
4
|
import Link from '@docusaurus/Link';
|
|
6
5
|
import { useReflection } from '../hooks/useReflection';
|
|
6
|
+
import { escapeMdx } from '../utils/helpers';
|
|
7
7
|
|
|
8
8
|
export interface MemberReferenceProps {
|
|
9
9
|
reflection: JSONOutput.ReferenceReflection;
|
|
@@ -16,7 +16,7 @@ export function MemberReference({ reflection }: MemberReferenceProps) {
|
|
|
16
16
|
if (!target) {
|
|
17
17
|
content = (
|
|
18
18
|
<>
|
|
19
|
-
Re-exports <span className="tsd-signature-type">{reflection.name}</span>
|
|
19
|
+
Re-exports <span className="tsd-signature-type">{escapeMdx(reflection.name)}</span>
|
|
20
20
|
</>
|
|
21
21
|
);
|
|
22
22
|
} else if (reflection.name === target.name) {
|
|
@@ -24,7 +24,7 @@ export function MemberReference({ reflection }: MemberReferenceProps) {
|
|
|
24
24
|
<>
|
|
25
25
|
Re-exports{' '}
|
|
26
26
|
<Link className="tsd-signature-type" to={target.permalink}>
|
|
27
|
-
{target.name}
|
|
27
|
+
{escapeMdx(target.name)}
|
|
28
28
|
</Link>
|
|
29
29
|
</>
|
|
30
30
|
);
|
|
@@ -33,7 +33,7 @@ export function MemberReference({ reflection }: MemberReferenceProps) {
|
|
|
33
33
|
<>
|
|
34
34
|
Renames and re-exports{' '}
|
|
35
35
|
<Link className="tsd-signature-type" to={target.permalink}>
|
|
36
|
-
{target.name}
|
|
36
|
+
{escapeMdx(target.name)}
|
|
37
37
|
</Link>
|
|
38
38
|
</>
|
|
39
39
|
);
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.signature.body.hbs
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
4
3
|
import type { JSONOutput } from 'typedoc';
|
|
5
4
|
import { useMinimalLayout } from '../hooks/useMinimalLayout';
|
|
5
|
+
import type { TSDSignatureReflection } from '../types';
|
|
6
6
|
import { Comment, hasComment } from './Comment';
|
|
7
7
|
import { CommentBadges, isCommentWithModifiers } from './CommentBadges';
|
|
8
8
|
import { DefaultValue } from './DefaultValue';
|
|
9
9
|
import { Flags } from './Flags';
|
|
10
10
|
import { hasSources, MemberSources } from './MemberSources';
|
|
11
11
|
import { Parameter } from './Parameter';
|
|
12
|
-
import { Type } from './Type';
|
|
12
|
+
import { extractDeclarationFromType, Type } from './Type';
|
|
13
13
|
import { TypeParameters } from './TypeParameters';
|
|
14
14
|
|
|
15
15
|
export function hasSigBody(
|
|
16
|
-
sig:
|
|
16
|
+
sig: TSDSignatureReflection | undefined,
|
|
17
17
|
minimal: boolean,
|
|
18
18
|
hideSources: boolean = false,
|
|
19
19
|
) {
|
|
@@ -32,7 +32,7 @@ export function hasSigBody(
|
|
|
32
32
|
|
|
33
33
|
export interface MemberSignatureBodyProps {
|
|
34
34
|
hideSources?: boolean;
|
|
35
|
-
sig:
|
|
35
|
+
sig: TSDSignatureReflection;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function intoReturnComment(comment?: JSONOutput.Comment): JSONOutput.Comment | undefined {
|
|
@@ -113,7 +113,7 @@ export function MemberSignatureBody({ hideSources, sig }: MemberSignatureBodyPro
|
|
|
113
113
|
|
|
114
114
|
<Comment comment={intoReturnComment(sig.comment)} />
|
|
115
115
|
|
|
116
|
-
<Parameter param={sig.type
|
|
116
|
+
<Parameter param={extractDeclarationFromType(sig.type)} />
|
|
117
117
|
</>
|
|
118
118
|
)}
|
|
119
119
|
</>
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
2
|
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.signature.title.hbs
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
4
|
+
import { Fragment } from 'react';
|
|
5
|
+
import type { TSDSignatureReflection } from '../types';
|
|
6
|
+
import { escapeMdx } from '../utils/helpers';
|
|
6
7
|
import { Type } from './Type';
|
|
7
8
|
import { TypeParametersGeneric } from './TypeParametersGeneric';
|
|
8
9
|
|
|
9
10
|
export interface MemberSignatureTitleProps {
|
|
10
11
|
useArrow?: boolean;
|
|
11
12
|
hideName?: boolean;
|
|
12
|
-
sig:
|
|
13
|
+
sig: TSDSignatureReflection & { modifiers?: string[] };
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export function MemberSignatureTitle({ useArrow, hideName, sig }: MemberSignatureTitleProps) {
|
|
@@ -22,15 +23,16 @@ export function MemberSignatureTitle({ useArrow, hideName, sig }: MemberSignatur
|
|
|
22
23
|
name: '*',
|
|
23
24
|
kind: 32_768,
|
|
24
25
|
flags: { },
|
|
25
|
-
|
|
26
|
+
variant: 'param',
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
return (
|
|
30
31
|
<>
|
|
31
32
|
{!hideName && sig.name !== '__type' ? (
|
|
32
|
-
<span>{sig.modifiers ? `${sig.modifiers.join(' ')} ` : ''}<b>{sig.name}</b></span>
|
|
33
|
-
) :
|
|
33
|
+
<span>{sig.modifiers ? `${sig.modifiers.join(' ')} ` : ''}<b>{escapeMdx(sig.name)}</b></span>
|
|
34
|
+
) : // Constructor signature
|
|
35
|
+
sig.kind === 16_384 ? (
|
|
34
36
|
<>
|
|
35
37
|
{sig.flags?.isAbstract && <span className="tsd-signature-symbol">abstract </span>}
|
|
36
38
|
<span className="tsd-signature-symbol">new </span>
|
|
@@ -42,14 +44,14 @@ export function MemberSignatureTitle({ useArrow, hideName, sig }: MemberSignatur
|
|
|
42
44
|
<span className="tsd-signature-symbol">(</span>
|
|
43
45
|
|
|
44
46
|
{parametersCopy.map((param, index) => (
|
|
45
|
-
<
|
|
47
|
+
<Fragment key={param.id}>
|
|
46
48
|
{index > 0 && <span className="tsd-signature-symbol">, </span>}
|
|
47
49
|
|
|
48
50
|
<span>
|
|
49
51
|
{param.flags?.isRest && <span className="tsd-signature-symbol">...</span>}
|
|
50
|
-
{param.name}
|
|
52
|
+
{escapeMdx(param.name)}
|
|
51
53
|
</span>
|
|
52
|
-
</
|
|
54
|
+
</Fragment>
|
|
53
55
|
))}
|
|
54
56
|
|
|
55
57
|
<span className="tsd-signature-symbol">)</span>
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
3
3
|
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.signatures.hbs
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import type { JSONOutput } from 'typedoc';
|
|
5
|
+
import { useState } from 'react';
|
|
7
6
|
import { useMinimalLayout } from '../hooks/useMinimalLayout';
|
|
7
|
+
import type { TSDSignatureReflection } from '../types';
|
|
8
8
|
import { Icon } from './Icon';
|
|
9
9
|
import { hasSigBody, MemberSignatureBody } from './MemberSignatureBody';
|
|
10
10
|
import { MemberSignatureTitle } from './MemberSignatureTitle';
|
|
11
11
|
|
|
12
12
|
export interface MemberSignaturesProps {
|
|
13
13
|
inPanel?: boolean;
|
|
14
|
-
sigs:
|
|
14
|
+
sigs: TSDSignatureReflection[];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export function MemberSignatures({ inPanel, sigs }: MemberSignaturesProps) {
|
|
@@ -33,9 +33,9 @@ export function MemberSignatures({ inPanel, sigs }: MemberSignaturesProps) {
|
|
|
33
33
|
onClick={
|
|
34
34
|
hasMultiple
|
|
35
35
|
? // eslint-disable-next-line react-perf/jsx-no-new-function-as-prop
|
|
36
|
-
|
|
36
|
+
() => {
|
|
37
37
|
setActiveIndex(i);
|
|
38
|
-
|
|
38
|
+
}
|
|
39
39
|
: undefined
|
|
40
40
|
}
|
|
41
41
|
>
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.sources.hbs
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import type { JSONOutput } from 'typedoc';
|
|
3
|
+
import type { TSDDeclarationReflection, TSDSignatureReflection } from '../types';
|
|
5
4
|
import { TypeAndParent } from './TypeAndParent';
|
|
6
5
|
|
|
7
|
-
export function hasSources(reflection:
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
6
|
+
export function hasSources(reflection: TSDDeclarationReflection | TSDSignatureReflection) {
|
|
9
7
|
return Boolean(reflection.implementationOf || reflection.inheritedFrom || reflection.overwrites);
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
export interface MemberSourcesProps {
|
|
13
|
-
reflection:
|
|
11
|
+
reflection: TSDDeclarationReflection | TSDSignatureReflection;
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
export function MemberSources({ reflection }: MemberSourcesProps) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/members.hbs
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import type { JSONOutput } from 'typedoc';
|
|
5
3
|
import { useReflectionMap } from '../hooks/useReflectionMap';
|
|
4
|
+
import type { TSDDeclarationReflection } from '../types';
|
|
6
5
|
import {
|
|
7
6
|
allCategoryChildrenHaveOwnDocument,
|
|
8
7
|
allGroupChildrenHaveOwnDocument,
|
|
@@ -13,7 +12,7 @@ import { Member } from './Member';
|
|
|
13
12
|
import { MembersGroup } from './MembersGroup';
|
|
14
13
|
|
|
15
14
|
export interface MembersProps {
|
|
16
|
-
reflection:
|
|
15
|
+
reflection: TSDDeclarationReflection;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
export function Members({ reflection }: MembersProps) {
|
|
@@ -30,7 +29,7 @@ export function Members({ reflection }: MembersProps) {
|
|
|
30
29
|
return (
|
|
31
30
|
<section key={category.title} className="tsd-panel-group tsd-member-group">
|
|
32
31
|
<h2>
|
|
33
|
-
{category.title === '
|
|
32
|
+
{category.title === '__CATEGORY__' ? 'Other' : category.title}{' '}
|
|
34
33
|
<AnchorLink id={category.title} />
|
|
35
34
|
</h2>
|
|
36
35
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/members.group.hbs
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
4
3
|
import type { JSONOutput } from 'typedoc';
|
|
5
4
|
import { useReflectionMap } from '../hooks/useReflectionMap';
|
|
6
5
|
import { hasOwnDocument } from '../utils/visibility';
|
|
@@ -20,7 +19,7 @@ export function MembersGroup({ group }: MembersGroupProps) {
|
|
|
20
19
|
{group.categories.map((category) => (
|
|
21
20
|
<section key={category.title} className="tsd-panel-group tsd-member-group">
|
|
22
21
|
<h2>
|
|
23
|
-
{category.title === '
|
|
22
|
+
{category.title === '__CATEGORY__' ? 'Other' : category.title}{' '}
|
|
24
23
|
<AnchorLink id={category.title} />
|
|
25
24
|
</h2>
|
|
26
25
|
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
2
2
|
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/Parameter.hbs
|
|
3
3
|
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import type { JSONOutput } from 'typedoc';
|
|
6
4
|
import { useMinimalLayout } from '../hooks/useMinimalLayout';
|
|
5
|
+
import type { TSDDeclarationReflection } from '../types';
|
|
7
6
|
import { Comment } from './Comment';
|
|
8
7
|
import { Flags } from './Flags';
|
|
9
8
|
import { Icon } from './Icon';
|
|
10
9
|
import { hasSigBody, MemberSignatureBody } from './MemberSignatureBody';
|
|
11
10
|
import { MemberSignatures } from './MemberSignatures';
|
|
12
11
|
import { MemberSignatureTitle } from './MemberSignatureTitle';
|
|
13
|
-
import { Type } from './Type';
|
|
12
|
+
import { extractDeclarationFromType, Type } from './Type';
|
|
14
13
|
|
|
15
14
|
export interface ParameterProps {
|
|
16
|
-
param?:
|
|
15
|
+
param?: TSDDeclarationReflection;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
function ParameterChild({ param }: ParameterProps) {
|
|
@@ -49,11 +48,9 @@ function ParameterChild({ param }: ParameterProps) {
|
|
|
49
48
|
|
|
50
49
|
<Comment comment={param.comment} />
|
|
51
50
|
|
|
52
|
-
{param.children?.map((child) =>
|
|
53
|
-
<Parameter key={child.id} param={child} />
|
|
54
|
-
))}
|
|
51
|
+
{param.children?.map((child) => <Parameter key={child.id} param={child} />)}
|
|
55
52
|
|
|
56
|
-
<Parameter param={param.type
|
|
53
|
+
<Parameter param={extractDeclarationFromType(param.type)} />
|
|
57
54
|
</li>
|
|
58
55
|
);
|
|
59
56
|
}
|
|
@@ -153,13 +150,11 @@ export function Parameter({ param }: ParameterProps) {
|
|
|
153
150
|
|
|
154
151
|
<Comment comment={param.indexSignature.comment} />
|
|
155
152
|
|
|
156
|
-
<Parameter param={param.indexSignature
|
|
153
|
+
<Parameter param={extractDeclarationFromType(param.indexSignature)} />
|
|
157
154
|
</li>
|
|
158
155
|
)}
|
|
159
156
|
|
|
160
|
-
{param.children?.map((child) =>
|
|
161
|
-
<ParameterChild key={child.id} param={child} />
|
|
162
|
-
))}
|
|
157
|
+
{param.children?.map((child) => <ParameterChild key={child.id} param={child} />)}
|
|
163
158
|
</ul>
|
|
164
159
|
);
|
|
165
160
|
}
|
package/src/components/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
The `ApiPage` and `ApiItem` components are based on Docusaurus' built-in `
|
|
1
|
+
The `ApiPage` and `ApiItem` components are based on Docusaurus' built-in `DocRoot` and `DocItem`. We
|
|
2
2
|
wanted to reuse as much code as possible, so we try and extend or duplicate when necessary. Please
|
|
3
3
|
reference the classic them when making changes:
|
|
4
4
|
https://github.com/facebook/docusaurus/tree/main/packages/docusaurus-theme-classic/src/theme
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/templates/reflection.hbs
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import type {
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import type { TSDDeclarationReflection, TSDReflection, TSDSignatureReflection } from '../types';
|
|
5
5
|
import { createHierarchy } from '../utils/hierarchy';
|
|
6
6
|
import { Comment, hasComment } from './Comment';
|
|
7
7
|
import { CommentBadges, isCommentWithModifiers } from './CommentBadges';
|
|
@@ -11,14 +11,11 @@ import { Index } from './Index';
|
|
|
11
11
|
import { Members } from './Members';
|
|
12
12
|
import { MemberSignatures } from './MemberSignatures';
|
|
13
13
|
import { Parameter } from './Parameter';
|
|
14
|
-
import { Type } from './Type';
|
|
14
|
+
import { extractDeclarationFromType, Type } from './Type';
|
|
15
15
|
import { TypeParameters } from './TypeParameters';
|
|
16
16
|
|
|
17
17
|
export interface ReflectionProps {
|
|
18
|
-
reflection:
|
|
19
|
-
| JSONOutput.DeclarationReflection
|
|
20
|
-
| JSONOutput.Reflection
|
|
21
|
-
| JSONOutput.SignatureReflection;
|
|
18
|
+
reflection: TSDDeclarationReflection | TSDReflection | TSDSignatureReflection;
|
|
22
19
|
}
|
|
23
20
|
// eslint-disable-next-line complexity
|
|
24
21
|
export function Reflection({ reflection }: ReflectionProps) {
|
|
@@ -123,14 +120,14 @@ export function Reflection({ reflection }: ReflectionProps) {
|
|
|
123
120
|
|
|
124
121
|
<Comment comment={reflection.indexSignature.comment} />
|
|
125
122
|
|
|
126
|
-
<Parameter param={reflection.indexSignature.type
|
|
123
|
+
<Parameter param={extractDeclarationFromType(reflection.indexSignature.type)} />
|
|
127
124
|
</div>
|
|
128
125
|
</section>
|
|
129
126
|
)}
|
|
130
127
|
|
|
131
|
-
<Index reflection={reflection} />
|
|
128
|
+
<Index reflection={reflection as TSDDeclarationReflection} />
|
|
132
129
|
|
|
133
|
-
<Members reflection={reflection} />
|
|
130
|
+
<Members reflection={reflection as TSDDeclarationReflection} />
|
|
134
131
|
</>
|
|
135
132
|
);
|
|
136
133
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { JSONOutput } from 'typedoc';
|
|
3
2
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
4
3
|
import { useGitRefName } from '../hooks/useGitRefName';
|
|
@@ -27,7 +26,6 @@ export function SourceLink({ sources = [] }: SourceLinkProps) {
|
|
|
27
26
|
key={source.fileName}
|
|
28
27
|
className="tsd-anchor"
|
|
29
28
|
href={
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
31
29
|
source.url ||
|
|
32
30
|
`https://${siteConfig.githubHost}${
|
|
33
31
|
siteConfig.githubPort ? `:${siteConfig.githubPort}` : ''
|
package/src/components/Type.tsx
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
/* eslint-disable react/no-array-index-key */
|
|
2
|
-
/* eslint-disable @typescript-eslint/restrict-plus-operands */
|
|
3
|
-
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/type.hbs
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/type.hbs
|
|
4
|
+
import { Fragment } from 'react';
|
|
6
5
|
import type { JSONOutput } from 'typedoc';
|
|
7
6
|
import Link from '@docusaurus/Link';
|
|
8
7
|
import { useReflectionMap } from '../hooks/useReflectionMap';
|
|
8
|
+
import type { TSDDeclarationReflection } from '../types';
|
|
9
9
|
import { MemberSignatureTitle } from './MemberSignatureTitle';
|
|
10
10
|
|
|
11
|
+
export function extractDeclarationFromType(
|
|
12
|
+
type?: JSONOutput.Reflection | JSONOutput.SomeType,
|
|
13
|
+
): TSDDeclarationReflection | undefined {
|
|
14
|
+
if (!type) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (type as unknown as { declaration?: TSDDeclarationReflection })?.declaration;
|
|
19
|
+
}
|
|
20
|
+
|
|
11
21
|
function parens(element: JSX.Element, needsParens: boolean): JSX.Element {
|
|
12
22
|
if (!needsParens) {
|
|
13
23
|
return element;
|
|
@@ -95,10 +105,10 @@ export function Type({ needsParens = false, type: base }: TypeProps) {
|
|
|
95
105
|
return parens(
|
|
96
106
|
<>
|
|
97
107
|
{type.types.map((t, i) => (
|
|
98
|
-
<
|
|
108
|
+
<Fragment key={t.type + i}>
|
|
99
109
|
{i > 0 && <span className="tsd-signature-symbol"> & </span>}
|
|
100
110
|
<Type needsParens type={t} />
|
|
101
|
-
</
|
|
111
|
+
</Fragment>
|
|
102
112
|
))}
|
|
103
113
|
</>,
|
|
104
114
|
needsParens,
|
|
@@ -193,7 +203,7 @@ export function Type({ needsParens = false, type: base }: TypeProps) {
|
|
|
193
203
|
|
|
194
204
|
case 'reference': {
|
|
195
205
|
const type = base as JSONOutput.ReferenceType;
|
|
196
|
-
const ref = type.
|
|
206
|
+
const ref = type.target ? reflections[Number(type.target)] : null;
|
|
197
207
|
const genericClass = ref?.id && !ref.sources ? 'tsd-signature-type-generic' : '';
|
|
198
208
|
|
|
199
209
|
return (
|
|
@@ -201,7 +211,7 @@ export function Type({ needsParens = false, type: base }: TypeProps) {
|
|
|
201
211
|
{ref?.permalink ? (
|
|
202
212
|
<Link
|
|
203
213
|
className={`tsd-signature-type ${genericClass}`}
|
|
204
|
-
data-tsd-kind={ref.
|
|
214
|
+
data-tsd-kind={ref.kind}
|
|
205
215
|
to={ref.permalink}
|
|
206
216
|
>
|
|
207
217
|
{type.name}
|
|
@@ -213,10 +223,10 @@ export function Type({ needsParens = false, type: base }: TypeProps) {
|
|
|
213
223
|
<>
|
|
214
224
|
<span className="tsd-signature-symbol"><</span>
|
|
215
225
|
{type.typeArguments.map((t, i) => (
|
|
216
|
-
<
|
|
226
|
+
<Fragment key={t.type + i}>
|
|
217
227
|
{i > 0 && <span className="tsd-signature-symbol">, </span>}
|
|
218
228
|
<Type type={t} />
|
|
219
|
-
</
|
|
229
|
+
</Fragment>
|
|
220
230
|
))}
|
|
221
231
|
<span className="tsd-signature-symbol">></span>
|
|
222
232
|
</>
|
|
@@ -235,14 +245,14 @@ export function Type({ needsParens = false, type: base }: TypeProps) {
|
|
|
235
245
|
<>
|
|
236
246
|
<span className="tsd-signature-symbol">{'{ '}</span>
|
|
237
247
|
{decl.children.map((child, i) => (
|
|
238
|
-
<
|
|
248
|
+
<Fragment key={child.id ?? i}>
|
|
239
249
|
{i > 0 && <span className="tsd-signature-symbol">; </span>}
|
|
240
250
|
<span>
|
|
241
251
|
{child.name}
|
|
242
252
|
<span className="tsd-signature-symbol">{child.flags?.isOptional && '?'}: </span>
|
|
243
253
|
{child.type ? <Type type={child.type} /> : 'any'}
|
|
244
254
|
</span>
|
|
245
|
-
</
|
|
255
|
+
</Fragment>
|
|
246
256
|
))}
|
|
247
257
|
<span className="tsd-signature-symbol">{' }'}</span>
|
|
248
258
|
</>
|
|
@@ -258,10 +268,10 @@ export function Type({ needsParens = false, type: base }: TypeProps) {
|
|
|
258
268
|
<>
|
|
259
269
|
<span className="tsd-signature-symbol">{'{ '}</span>
|
|
260
270
|
{decl.signatures.map((sig, i) => (
|
|
261
|
-
<
|
|
271
|
+
<Fragment key={sig.id ?? i}>
|
|
262
272
|
{i > 0 && <span className="tsd-signature-symbol">; </span>}
|
|
263
273
|
<MemberSignatureTitle sig={sig} />
|
|
264
|
-
</
|
|
274
|
+
</Fragment>
|
|
265
275
|
))}
|
|
266
276
|
<span className="tsd-signature-symbol">{' }'}</span>
|
|
267
277
|
</>,
|
|
@@ -290,10 +300,10 @@ export function Type({ needsParens = false, type: base }: TypeProps) {
|
|
|
290
300
|
<>
|
|
291
301
|
<span className="tsd-signature-symbol">[</span>
|
|
292
302
|
{type.elements?.map((t, i) => (
|
|
293
|
-
<
|
|
303
|
+
<Fragment key={t.type + i}>
|
|
294
304
|
{i > 0 && <span className="tsd-signature-symbol">, </span>}
|
|
295
305
|
<Type type={t} />
|
|
296
|
-
</
|
|
306
|
+
</Fragment>
|
|
297
307
|
))}
|
|
298
308
|
<span className="tsd-signature-symbol">]</span>
|
|
299
309
|
</>
|
|
@@ -323,10 +333,10 @@ export function Type({ needsParens = false, type: base }: TypeProps) {
|
|
|
323
333
|
return parens(
|
|
324
334
|
<>
|
|
325
335
|
{type.types.map((t, i) => (
|
|
326
|
-
<
|
|
336
|
+
<Fragment key={t.type + i}>
|
|
327
337
|
{i > 0 && <span className="tsd-signature-symbol"> | </span>}
|
|
328
338
|
<Type needsParens type={t} />
|
|
329
|
-
</
|
|
339
|
+
</Fragment>
|
|
330
340
|
))}
|
|
331
341
|
</>,
|
|
332
342
|
needsParens,
|
|
@@ -339,7 +349,8 @@ export function Type({ needsParens = false, type: base }: TypeProps) {
|
|
|
339
349
|
return <span className="tsd-signature-type">{type.name}</span>;
|
|
340
350
|
}
|
|
341
351
|
|
|
342
|
-
case 'named-tuple-member':
|
|
352
|
+
case 'named-tuple-member':
|
|
353
|
+
case 'namedTupleMember': {
|
|
343
354
|
const type = base as unknown as JSONOutput.NamedTupleMemberType;
|
|
344
355
|
|
|
345
356
|
return (
|
|
@@ -351,7 +362,8 @@ export function Type({ needsParens = false, type: base }: TypeProps) {
|
|
|
351
362
|
);
|
|
352
363
|
}
|
|
353
364
|
|
|
354
|
-
case 'template-literal':
|
|
365
|
+
case 'template-literal':
|
|
366
|
+
case 'templateLiteral': {
|
|
355
367
|
const type = base as unknown as JSONOutput.TemplateLiteralType;
|
|
356
368
|
|
|
357
369
|
return (
|
|
@@ -359,12 +371,12 @@ export function Type({ needsParens = false, type: base }: TypeProps) {
|
|
|
359
371
|
<span className="tsd-signature-symbol">`</span>
|
|
360
372
|
{type.head && <span className="tsd-signature-type">{type.head}</span>}
|
|
361
373
|
{type.tail.map((t, i) => (
|
|
362
|
-
<
|
|
374
|
+
<Fragment key={i}>
|
|
363
375
|
<span className="tsd-signature-symbol">{'${'}</span>
|
|
364
|
-
{typeof t[0] !== 'string' && <Type type={t[0]
|
|
376
|
+
{typeof t[0] !== 'string' && <Type type={t[0]} />}
|
|
365
377
|
<span className="tsd-signature-symbol">{'}'}</span>
|
|
366
378
|
{typeof t[1] === 'string' && <span className="tsd-signature-type">{t[1]}</span>}
|
|
367
|
-
</
|
|
379
|
+
</Fragment>
|
|
368
380
|
))}
|
|
369
381
|
<span className="tsd-signature-symbol">`</span>
|
|
370
382
|
</>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/typeParameters.hbs
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
4
3
|
import type { JSONOutput } from 'typedoc';
|
|
5
4
|
import { Comment } from './Comment';
|
|
6
5
|
import { DefaultValue } from './DefaultValue';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Fragment } from 'react';
|
|
2
2
|
import type { JSONOutput } from 'typedoc';
|
|
3
3
|
|
|
4
4
|
export interface TypeParametersGenericProps {
|
|
@@ -14,10 +14,10 @@ export function TypeParametersGeneric({ params }: TypeParametersGenericProps) {
|
|
|
14
14
|
<span className="tsd-generics">
|
|
15
15
|
<span className="tsd-signature-symbol"><</span>
|
|
16
16
|
{params.map((param, i) => (
|
|
17
|
-
<
|
|
17
|
+
<Fragment key={param.id}>
|
|
18
18
|
{i > 0 && <span className="tsd-signature-symbol">, </span>}
|
|
19
19
|
{param.name}
|
|
20
|
-
</
|
|
20
|
+
</Fragment>
|
|
21
21
|
))}
|
|
22
22
|
<span className="tsd-signature-symbol">></span>
|
|
23
23
|
</span>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
2
|
import Link from '@docusaurus/Link';
|
|
3
3
|
import { useDocVersionSuggestions } from '@docusaurus/plugin-content-docs/client';
|
|
4
4
|
import { ThemeClassNames, useDocsPreferredVersion } from '@docusaurus/theme-common';
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
|
-
import type { JSONOutput } from 'typedoc';
|
|
3
2
|
import { ApiDataContext } from '../components/ApiDataContext';
|
|
3
|
+
import type { TSDDeclarationReflection } from '../types';
|
|
4
4
|
|
|
5
|
-
export function useReflection<T =
|
|
5
|
+
export function useReflection<T = TSDDeclarationReflection>(
|
|
6
|
+
id?: number,
|
|
7
|
+
required?: boolean,
|
|
8
|
+
): T | null {
|
|
6
9
|
const { reflections } = useContext(ApiDataContext);
|
|
7
10
|
|
|
8
11
|
// 0 is a valid ID
|
|
9
|
-
if (id === undefined) {
|
|
12
|
+
if (id === undefined && !required) {
|
|
10
13
|
return null;
|
|
11
14
|
}
|
|
12
15
|
|
|
13
|
-
if (reflections[id]) {
|
|
16
|
+
if (id !== undefined && reflections[id]) {
|
|
14
17
|
return reflections[id] as unknown as T;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
throw new Error(`Unable to find declaration with ID ${id}`);
|
|
18
21
|
}
|
|
22
|
+
|
|
23
|
+
export function useRequiredReflection<T = TSDDeclarationReflection>(id?: number): T {
|
|
24
|
+
return useReflection<T>(id, true) as unknown as T;
|
|
25
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import { ApiDataContext } from '../components/ApiDataContext';
|
|
3
|
-
import type {
|
|
3
|
+
import type { TSDDeclarationReflectionMap } from '../types';
|
|
4
4
|
|
|
5
|
-
export function useReflectionMap():
|
|
5
|
+
export function useReflectionMap(): TSDDeclarationReflectionMap {
|
|
6
6
|
return useContext(ApiDataContext).reflections;
|
|
7
7
|
}
|