@apify/docusaurus-plugin-typedoc-api 3.0.0 → 4.2.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.
- 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,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { JSONOutput } from 'typedoc';
|
|
1
|
+
import { useMemo } from 'react';
|
|
3
2
|
import { PageMetadata } from '@docusaurus/theme-common';
|
|
4
3
|
import type { Props as DocItemProps } from '@theme/DocItem';
|
|
5
|
-
import { useReflection } from '../hooks/useReflection';
|
|
4
|
+
import { useReflection, useRequiredReflection } from '../hooks/useReflection';
|
|
6
5
|
import { useReflectionMap } from '../hooks/useReflectionMap';
|
|
7
|
-
import type {
|
|
6
|
+
import type { TOCItem, TSDDeclarationReflection, TSDDeclarationReflectionMap } from '../types';
|
|
7
|
+
import { escapeMdx } from '../utils/helpers';
|
|
8
8
|
import { getKindIconHtml } from '../utils/icons';
|
|
9
9
|
import ApiItemLayout from './ApiItemLayout';
|
|
10
10
|
import { displayPartsToMarkdown } from './Comment';
|
|
@@ -12,29 +12,27 @@ import { Flags } from './Flags';
|
|
|
12
12
|
import { Reflection } from './Reflection';
|
|
13
13
|
import { TypeParametersGeneric } from './TypeParametersGeneric';
|
|
14
14
|
|
|
15
|
-
function extractTOC(
|
|
16
|
-
item: JSONOutput.DeclarationReflection,
|
|
17
|
-
map: DeclarationReflectionMap,
|
|
18
|
-
): TOCItem[] {
|
|
15
|
+
function extractTOC(item: TSDDeclarationReflection, map: TSDDeclarationReflectionMap): TOCItem[] {
|
|
19
16
|
const toc: TOCItem[] = [];
|
|
20
17
|
const mapped = new Set<string>();
|
|
21
18
|
|
|
22
19
|
item.groups?.forEach((group) => {
|
|
23
20
|
group.children?.forEach((childId) => {
|
|
24
|
-
const child = map[childId]
|
|
21
|
+
const child = map[childId];
|
|
25
22
|
|
|
26
23
|
if (mapped.has(child.name)) {
|
|
27
24
|
return;
|
|
28
25
|
}
|
|
29
26
|
|
|
30
|
-
const iconHtml = getKindIconHtml(child.kind, child.name);
|
|
31
|
-
|
|
32
27
|
if (!child.permalink || child.permalink.includes('#')) {
|
|
28
|
+
const iconHtml = getKindIconHtml(child.kind, child.name);
|
|
29
|
+
const value = escapeMdx(child.name) ?? '';
|
|
30
|
+
|
|
33
31
|
toc.push({
|
|
34
32
|
// @ts-expect-error Not typed upstream
|
|
35
33
|
children: [],
|
|
36
34
|
id: child.name,
|
|
37
|
-
value: iconHtml ? `${iconHtml} ${
|
|
35
|
+
value: iconHtml ? `${iconHtml} ${value}` : value,
|
|
38
36
|
level: 1,
|
|
39
37
|
});
|
|
40
38
|
|
|
@@ -51,7 +49,7 @@ export interface ApiItemProps extends Pick<DocItemProps, 'route'> {
|
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
export default function ApiItem({ readme: Readme, route }: ApiItemProps) {
|
|
54
|
-
const item =
|
|
52
|
+
const item = useRequiredReflection((route as unknown as { id: number }).id);
|
|
55
53
|
const reflections = useReflectionMap();
|
|
56
54
|
const toc = useMemo(() => extractTOC(item, reflections), [item, reflections]);
|
|
57
55
|
|
|
@@ -63,14 +61,14 @@ export default function ApiItem({ readme: Readme, route }: ApiItemProps) {
|
|
|
63
61
|
next: nextItem
|
|
64
62
|
? {
|
|
65
63
|
permalink: nextItem.permalink,
|
|
66
|
-
title: nextItem.name,
|
|
67
|
-
|
|
64
|
+
title: escapeMdx(nextItem.name) ?? '',
|
|
65
|
+
}
|
|
68
66
|
: undefined,
|
|
69
67
|
previous: prevItem
|
|
70
68
|
? {
|
|
71
69
|
permalink: prevItem.permalink,
|
|
72
|
-
title: prevItem.name,
|
|
73
|
-
|
|
70
|
+
title: escapeMdx(prevItem.name) ?? '',
|
|
71
|
+
}
|
|
74
72
|
: undefined,
|
|
75
73
|
}),
|
|
76
74
|
[nextItem, prevItem],
|
|
@@ -83,15 +81,15 @@ export default function ApiItem({ readme: Readme, route }: ApiItemProps) {
|
|
|
83
81
|
<span className="tsd-header-flags">
|
|
84
82
|
<Flags flags={item.flags} />
|
|
85
83
|
</span>
|
|
86
|
-
{item.name} <TypeParametersGeneric params={item.typeParameters} />
|
|
84
|
+
{escapeMdx(item.name)} <TypeParametersGeneric params={item.typeParameters} />
|
|
87
85
|
</>
|
|
88
86
|
}
|
|
89
87
|
module={(item as unknown as { module: string }).module}
|
|
90
88
|
name={item.name}
|
|
91
89
|
pageMetadata={
|
|
92
90
|
<PageMetadata
|
|
93
|
-
description={item
|
|
94
|
-
title={`${item.name} | API`}
|
|
91
|
+
description={item?.comment?.summary ? displayPartsToMarkdown(item.comment.summary) : ''}
|
|
92
|
+
title={`${item?.name ? `${item.name} | ` : ''}API`}
|
|
95
93
|
/>
|
|
96
94
|
}
|
|
97
95
|
pagingMetadata={pagingMetadata}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// we had to duplicate it. Keep this file in sync as much as possible!
|
|
3
3
|
// https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-theme-classic/src/theme/DocItem/index.tsx
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
6
5
|
import type { PropNavigation } from '@docusaurus/plugin-content-docs';
|
|
7
6
|
import { ThemeClassNames, useWindowSize } from '@docusaurus/theme-common';
|
|
8
7
|
import DocBreadcrumbs from '@theme/DocBreadcrumbs';
|
|
@@ -23,7 +22,7 @@ export interface ApiItemLayoutProps extends Pick<DocItemProps, 'route'> {
|
|
|
23
22
|
toc: readonly TOCItem[];
|
|
24
23
|
pageMetadata?: React.ReactNode;
|
|
25
24
|
pagingMetadata?: PropNavigation;
|
|
26
|
-
name
|
|
25
|
+
name?: string;
|
|
27
26
|
module?: string;
|
|
28
27
|
}
|
|
29
28
|
|
|
@@ -2,20 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
import '@vscode/codicons/dist/codicon.css';
|
|
4
4
|
import './styles.css';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
import DocRoot, { type Props as DocRootProps } from '@theme/DocRoot';
|
|
7
|
+
import type {
|
|
8
|
+
ApiOptions,
|
|
9
|
+
PackageReflectionGroup,
|
|
10
|
+
TSDDeclarationReflection,
|
|
11
|
+
TSDDeclarationReflectionMap,
|
|
12
|
+
TSDReflection,
|
|
13
|
+
} from '../types';
|
|
9
14
|
import { ApiDataContext } from './ApiDataContext';
|
|
10
15
|
|
|
11
|
-
function isObject(value: unknown): value is
|
|
16
|
+
function isObject(value: unknown): value is TSDReflection {
|
|
12
17
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
function deepMapReflections(
|
|
16
|
-
data:
|
|
17
|
-
map:
|
|
18
|
-
parent?:
|
|
21
|
+
data: TSDReflection,
|
|
22
|
+
map: TSDDeclarationReflectionMap,
|
|
23
|
+
parent?: TSDReflection,
|
|
19
24
|
) {
|
|
20
25
|
Object.entries(data).forEach(([key, value]) => {
|
|
21
26
|
if (key === 'id') {
|
|
@@ -23,7 +28,7 @@ function deepMapReflections(
|
|
|
23
28
|
|
|
24
29
|
// Dont overwrite with reference nodes
|
|
25
30
|
if (!hasType || (hasType && (data as unknown as { type: string }).type !== 'reference')) {
|
|
26
|
-
map[Number(value)] = data;
|
|
31
|
+
map[Number(value)] = data as TSDDeclarationReflection;
|
|
27
32
|
|
|
28
33
|
if (parent) {
|
|
29
34
|
data.parentId = parent.id;
|
|
@@ -43,8 +48,8 @@ function deepMapReflections(
|
|
|
43
48
|
return map;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
function mapPackagesToReflection(packages: PackageReflectionGroup[]):
|
|
47
|
-
const map:
|
|
51
|
+
function mapPackagesToReflection(packages: PackageReflectionGroup[]): TSDDeclarationReflectionMap {
|
|
52
|
+
const map: TSDDeclarationReflectionMap = {};
|
|
48
53
|
|
|
49
54
|
packages.forEach((pkg) => {
|
|
50
55
|
pkg.entryPoints.forEach((entry) => {
|
|
@@ -55,7 +60,7 @@ function mapPackagesToReflection(packages: PackageReflectionGroup[]): Declaratio
|
|
|
55
60
|
return map;
|
|
56
61
|
}
|
|
57
62
|
|
|
58
|
-
export interface ApiPageProps extends
|
|
63
|
+
export interface ApiPageProps extends DocRootProps {
|
|
59
64
|
options: ApiOptions;
|
|
60
65
|
packages: PackageReflectionGroup[];
|
|
61
66
|
}
|
|
@@ -69,7 +74,7 @@ function ApiPage({ options, packages, ...props }: ApiPageProps) {
|
|
|
69
74
|
return (
|
|
70
75
|
<ApiDataContext.Provider value={value}>
|
|
71
76
|
<div className="apiPage">
|
|
72
|
-
<
|
|
77
|
+
<DocRoot {...props} />
|
|
73
78
|
</div>
|
|
74
79
|
</ApiDataContext.Provider>
|
|
75
80
|
);
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/breadcrumb.hbs
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import type { JSONOutput } from 'typedoc';
|
|
5
3
|
import Link from '@docusaurus/Link';
|
|
6
4
|
import { useReflection } from '../hooks/useReflection';
|
|
5
|
+
import type { TSDReflection } from '../types';
|
|
7
6
|
|
|
8
7
|
export interface BreadcrumbProps {
|
|
9
|
-
reflection:
|
|
8
|
+
reflection: TSDReflection;
|
|
10
9
|
root?: boolean;
|
|
11
10
|
}
|
|
12
11
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/comment.hbs
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
2
|
+
import { Fragment } from 'react';
|
|
4
3
|
import type { JSONOutput } from 'typedoc';
|
|
5
4
|
import { Markdown } from './Markdown';
|
|
6
5
|
|
|
@@ -58,14 +57,14 @@ export function Comment({ comment, root, hideTags = [] }: CommentProps) {
|
|
|
58
57
|
{blockTags.length > 0 && (
|
|
59
58
|
<dl className="tsd-comment-tags">
|
|
60
59
|
{blockTags.map((tag) => (
|
|
61
|
-
<
|
|
60
|
+
<Fragment key={tag.tag}>
|
|
62
61
|
<dt>
|
|
63
62
|
<strong>{tag.tag}</strong>
|
|
64
63
|
</dt>
|
|
65
64
|
<dd>
|
|
66
65
|
<Markdown content={displayPartsToMarkdown(tag.content)} />
|
|
67
66
|
</dd>
|
|
68
|
-
</
|
|
67
|
+
</Fragment>
|
|
69
68
|
))}
|
|
70
69
|
</dl>
|
|
71
70
|
)}
|
package/src/components/Flags.tsx
CHANGED
package/src/components/Icon.tsx
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { JSONOutput } from 'typedoc';
|
|
1
|
+
import type { TSDDeclarationReflection, TSDSignatureReflection } from '../types';
|
|
3
2
|
import { getKindIcon, getKindIconColor } from '../utils/icons';
|
|
4
3
|
|
|
5
4
|
export interface IconProps {
|
|
6
|
-
reflection:
|
|
5
|
+
reflection: TSDDeclarationReflection | TSDSignatureReflection;
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
export function Icon({ reflection }: IconProps) {
|
package/src/components/Index.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { JSONOutput } from 'typedoc';
|
|
1
|
+
import { Fragment } from 'react';
|
|
3
2
|
import Link from '@docusaurus/Link';
|
|
4
|
-
import {
|
|
3
|
+
import { useRequiredReflection } from '../hooks/useReflection';
|
|
4
|
+
import type { TSDDeclarationReflection } from '../types';
|
|
5
|
+
import { escapeMdx } from '../utils/helpers';
|
|
5
6
|
import { AnchorLink } from './AnchorLink';
|
|
6
7
|
import { Icon } from './Icon';
|
|
7
8
|
|
|
@@ -10,20 +11,20 @@ export interface IndexChildProps {
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
function IndexChild({ id }: IndexChildProps) {
|
|
13
|
-
const reflection =
|
|
14
|
+
const reflection = useRequiredReflection(id);
|
|
14
15
|
|
|
15
16
|
return (
|
|
16
17
|
<li>
|
|
17
18
|
<Link className="tsd-kind-icon" to={reflection.permalink ?? `#${reflection.name}`}>
|
|
18
19
|
<Icon reflection={reflection} />
|
|
19
|
-
{reflection.name
|
|
20
|
+
{escapeMdx(reflection.name)}
|
|
20
21
|
</Link>
|
|
21
22
|
</li>
|
|
22
23
|
);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export interface IndexProps {
|
|
26
|
-
reflection:
|
|
27
|
+
reflection: TSDDeclarationReflection;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export function Index({ reflection }: IndexProps) {
|
|
@@ -39,14 +40,12 @@ export function Index({ reflection }: IndexProps) {
|
|
|
39
40
|
{reflection.categories.map((category) => (
|
|
40
41
|
<section key={category.title} className="tsd-index-section">
|
|
41
42
|
<h3 className="tsd-panel-header">
|
|
42
|
-
{category.title === '
|
|
43
|
+
{category.title === '__CATEGORY__' ? 'Other' : category.title}
|
|
43
44
|
</h3>
|
|
44
45
|
|
|
45
46
|
<div className="tsd-panel-content">
|
|
46
47
|
<ul className="tsd-index-list">
|
|
47
|
-
{category.children?.map((child) =>
|
|
48
|
-
<IndexChild key={child} id={child} />
|
|
49
|
-
))}
|
|
48
|
+
{category.children?.map((child) => <IndexChild key={child} id={child} />)}
|
|
50
49
|
</ul>
|
|
51
50
|
</div>
|
|
52
51
|
</section>
|
|
@@ -70,19 +69,17 @@ export function Index({ reflection }: IndexProps) {
|
|
|
70
69
|
<section key={group.title} className="tsd-index-section">
|
|
71
70
|
{group.categories && group.categories.length > 0 ? (
|
|
72
71
|
group.categories.map((category) => (
|
|
73
|
-
<
|
|
72
|
+
<Fragment key={category.title}>
|
|
74
73
|
<h3 className="tsd-panel-header">
|
|
75
|
-
{category.title === '
|
|
74
|
+
{category.title === '__CATEGORY__' ? group.title : category.title}
|
|
76
75
|
</h3>
|
|
77
76
|
|
|
78
77
|
<div className="tsd-panel-content">
|
|
79
78
|
<ul className="tsd-index-list">
|
|
80
|
-
{category.children?.map((child) =>
|
|
81
|
-
<IndexChild key={child} id={child} />
|
|
82
|
-
))}
|
|
79
|
+
{category.children?.map((child) => <IndexChild key={child} id={child} />)}
|
|
83
80
|
</ul>
|
|
84
81
|
</div>
|
|
85
|
-
</
|
|
82
|
+
</Fragment>
|
|
86
83
|
))
|
|
87
84
|
) : (
|
|
88
85
|
<>
|
|
@@ -90,9 +87,7 @@ export function Index({ reflection }: IndexProps) {
|
|
|
90
87
|
|
|
91
88
|
<div className="tsd-panel-content">
|
|
92
89
|
<ul className="tsd-index-list">
|
|
93
|
-
{group.children?.map((child) =>
|
|
94
|
-
<IndexChild key={child} id={child} />
|
|
95
|
-
))}
|
|
90
|
+
{group.children?.map((child) => <IndexChild key={child} id={child} />)}
|
|
96
91
|
</ul>
|
|
97
92
|
</div>
|
|
98
93
|
</>
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
/* eslint-disable unicorn/no-unsafe-regex */
|
|
2
1
|
/* eslint-disable react/no-array-index-key */
|
|
3
2
|
|
|
4
|
-
import
|
|
5
|
-
import { marked } from 'marked';
|
|
3
|
+
import { Fragment, useState } from 'react';
|
|
4
|
+
import { marked, type Tokens } from 'marked';
|
|
5
|
+
import { markedSmartypants } from 'marked-smartypants';
|
|
6
|
+
import { useDocsData } from '@docusaurus/plugin-content-docs/client';
|
|
6
7
|
import { useDocsVersion } from '@docusaurus/theme-common/internal';
|
|
8
|
+
import CodeBlock from '@theme/CodeBlock';
|
|
7
9
|
import MDX from '@theme/MDXComponents';
|
|
8
10
|
import { useReflectionMap } from '../hooks/useReflectionMap';
|
|
9
11
|
import { replaceLinkTokens } from '../utils/markdown';
|
|
@@ -14,30 +16,48 @@ interface Admonition {
|
|
|
14
16
|
title?: string;
|
|
15
17
|
keyword?: string;
|
|
16
18
|
text: string;
|
|
17
|
-
tokens:
|
|
19
|
+
tokens: Token[];
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
type
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
type Token =
|
|
23
|
+
| Admonition
|
|
24
|
+
| Tokens.Blockquote
|
|
25
|
+
| Tokens.Br
|
|
26
|
+
| Tokens.Code
|
|
27
|
+
| Tokens.Codespan
|
|
28
|
+
| Tokens.Def
|
|
29
|
+
| Tokens.Del
|
|
30
|
+
| Tokens.Em
|
|
31
|
+
| Tokens.Escape
|
|
32
|
+
| Tokens.Heading
|
|
33
|
+
| Tokens.Hr
|
|
34
|
+
| Tokens.HTML
|
|
35
|
+
| Tokens.Image
|
|
36
|
+
| Tokens.Link
|
|
37
|
+
| Tokens.List
|
|
38
|
+
| Tokens.ListItem
|
|
39
|
+
| Tokens.Paragraph
|
|
40
|
+
| Tokens.Space
|
|
41
|
+
| Tokens.Strong
|
|
42
|
+
| Tokens.Table
|
|
43
|
+
| Tokens.Tag
|
|
44
|
+
| Tokens.Text;
|
|
45
|
+
type TokensList = Token[];
|
|
29
46
|
|
|
30
47
|
const ADMONITION_START = /^:{3}([a-z]+)? *(.*)\n/;
|
|
31
48
|
const ADMONITION_END = '\n:::';
|
|
32
49
|
|
|
50
|
+
marked.setOptions({
|
|
51
|
+
gfm: true,
|
|
52
|
+
});
|
|
53
|
+
marked.use(markedSmartypants());
|
|
33
54
|
marked.use({
|
|
34
55
|
extensions: [
|
|
35
56
|
{
|
|
36
57
|
name: 'admonition',
|
|
37
58
|
level: 'block',
|
|
38
59
|
start(src) {
|
|
39
|
-
|
|
40
|
-
return src.match(ADMONITION_START)?.index!;
|
|
60
|
+
return src.match(ADMONITION_START)?.index;
|
|
41
61
|
},
|
|
42
62
|
tokenizer(src, tokens) {
|
|
43
63
|
const match = ADMONITION_START.exec(src);
|
|
@@ -100,9 +120,12 @@ function convertAstToElements(ast: TokensList): React.ReactNode[] | undefined {
|
|
|
100
120
|
switch (token.type) {
|
|
101
121
|
case 'code':
|
|
102
122
|
elements.push(
|
|
103
|
-
<MDX.pre key={counter} className={token.lang && `language-${token.lang}`}>
|
|
123
|
+
/* <MDX.pre key={counter} className={token.lang && `language-${token.lang}`}>
|
|
124
|
+
{token.text}
|
|
125
|
+
</MDX.pre>, */
|
|
126
|
+
<CodeBlock key={counter} language={token.lang}>
|
|
104
127
|
{token.text}
|
|
105
|
-
</
|
|
128
|
+
</CodeBlock>,
|
|
106
129
|
);
|
|
107
130
|
break;
|
|
108
131
|
|
|
@@ -119,12 +142,12 @@ function convertAstToElements(ast: TokensList): React.ReactNode[] | undefined {
|
|
|
119
142
|
}
|
|
120
143
|
|
|
121
144
|
case 'image':
|
|
122
|
-
elements.push(<MDX.img key={counter} alt={token.title} src={token.href} />);
|
|
145
|
+
elements.push(<MDX.img key={counter} alt={token.title ?? ''} src={token.href} />);
|
|
123
146
|
break;
|
|
124
147
|
|
|
125
148
|
case 'link':
|
|
126
149
|
elements.push(
|
|
127
|
-
<MDX.a key={counter} href={token.href} title={token.title}>
|
|
150
|
+
<MDX.a key={counter} href={token.href} title={token.title ?? ''}>
|
|
128
151
|
{convertAstToElements(children) ?? token.text}
|
|
129
152
|
</MDX.a>,
|
|
130
153
|
);
|
|
@@ -163,7 +186,7 @@ function convertAstToElements(ast: TokensList): React.ReactNode[] | undefined {
|
|
|
163
186
|
<thead>
|
|
164
187
|
<tr>
|
|
165
188
|
{token.header.map((h, i) => (
|
|
166
|
-
<th key={i} align={token.align[i]
|
|
189
|
+
<th key={i} align={token.align[i] ?? 'left'}>
|
|
167
190
|
{convertAstToElements(h.tokens as TokensList)}
|
|
168
191
|
</th>
|
|
169
192
|
))}
|
|
@@ -173,7 +196,7 @@ function convertAstToElements(ast: TokensList): React.ReactNode[] | undefined {
|
|
|
173
196
|
{token.rows.map((cells, i) => (
|
|
174
197
|
<tr key={i}>
|
|
175
198
|
{cells.map((c, i2) => (
|
|
176
|
-
<td key={i2} align={token.align[i]
|
|
199
|
+
<td key={i2} align={token.align[i] ?? 'left'}>
|
|
177
200
|
{convertAstToElements(c.tokens as TokensList)}
|
|
178
201
|
</td>
|
|
179
202
|
))}
|
|
@@ -189,7 +212,7 @@ function convertAstToElements(ast: TokensList): React.ReactNode[] | undefined {
|
|
|
189
212
|
children.length === 0 ? (
|
|
190
213
|
token.text
|
|
191
214
|
) : (
|
|
192
|
-
<
|
|
215
|
+
<Fragment key={counter}>{convertAstToElements(children)}</Fragment>
|
|
193
216
|
),
|
|
194
217
|
);
|
|
195
218
|
break;
|
|
@@ -203,7 +226,9 @@ function convertAstToElements(ast: TokensList): React.ReactNode[] | undefined {
|
|
|
203
226
|
break;
|
|
204
227
|
|
|
205
228
|
default: {
|
|
206
|
-
const Comp = TOKEN_TO_TAG[token.type] || token.type
|
|
229
|
+
const Comp = (TOKEN_TO_TAG[token.type] || token.type) as unknown as React.ComponentType<{
|
|
230
|
+
children: React.ReactNode;
|
|
231
|
+
}>;
|
|
207
232
|
const innerText = 'text' in token ? token.text : '';
|
|
208
233
|
|
|
209
234
|
elements.push(<Comp key={counter}>{convertAstToElements(children) ?? innerText}</Comp>);
|
|
@@ -229,8 +254,12 @@ export interface MarkdownProps {
|
|
|
229
254
|
export function Markdown({ content }: MarkdownProps) {
|
|
230
255
|
const reflections = useReflectionMap();
|
|
231
256
|
const version = useDocsVersion();
|
|
232
|
-
const
|
|
233
|
-
|
|
257
|
+
const docsData = useDocsData(version.pluginId);
|
|
258
|
+
const [ast] = useState<TokensList>(
|
|
259
|
+
() =>
|
|
260
|
+
marked.lexer(
|
|
261
|
+
replaceLinkTokens(content, reflections, version, docsData.path),
|
|
262
|
+
) as unknown as TokensList,
|
|
234
263
|
);
|
|
235
264
|
|
|
236
265
|
if (!content) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/members.hbs
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { Fragment } from 'react';
|
|
4
4
|
import type { JSONOutput } from 'typedoc';
|
|
5
|
-
import {
|
|
5
|
+
import { useRequiredReflection } from '../hooks/useReflection';
|
|
6
6
|
import { useReflectionMap } from '../hooks/useReflectionMap';
|
|
7
|
+
import { escapeMdx } from '../utils/helpers';
|
|
7
8
|
import { hasOwnDocument } from '../utils/visibility';
|
|
8
9
|
import { AnchorLink } from './AnchorLink';
|
|
9
10
|
import { CommentBadges, isCommentWithModifiers } from './CommentBadges';
|
|
@@ -20,7 +21,7 @@ export interface MemberProps {
|
|
|
20
21
|
|
|
21
22
|
export function Member({ id }: MemberProps) {
|
|
22
23
|
const reflections = useReflectionMap();
|
|
23
|
-
const reflection =
|
|
24
|
+
const reflection = useRequiredReflection(id);
|
|
24
25
|
const { comment } = reflection;
|
|
25
26
|
let content: React.ReactNode = null;
|
|
26
27
|
|
|
@@ -46,18 +47,18 @@ export function Member({ id }: MemberProps) {
|
|
|
46
47
|
<AnchorLink id={reflection.name} />
|
|
47
48
|
<SourceLink sources={reflection.sources} />
|
|
48
49
|
<Flags flags={reflection.flags} />
|
|
49
|
-
{reflection.name}
|
|
50
|
+
{escapeMdx(reflection.name)}
|
|
50
51
|
{isCommentWithModifiers(comment) && <CommentBadges comment={comment} />}
|
|
51
52
|
</h3>
|
|
52
53
|
|
|
53
54
|
{content}
|
|
54
55
|
|
|
55
56
|
{reflection.groups?.map((group) => (
|
|
56
|
-
<
|
|
57
|
+
<Fragment key={group.title}>
|
|
57
58
|
{group.children?.map((child) =>
|
|
58
59
|
hasOwnDocument(child, reflections) ? null : <Member key={child} id={child} />,
|
|
59
60
|
)}
|
|
60
|
-
</
|
|
61
|
+
</Fragment>
|
|
61
62
|
))}
|
|
62
63
|
</section>
|
|
63
64
|
);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.declaration.hbs
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
4
3
|
import { useMinimalLayout } from '../hooks/useMinimalLayout';
|
|
5
|
-
import {
|
|
4
|
+
import { useRequiredReflection } from '../hooks/useReflection';
|
|
5
|
+
import { escapeMdx } from '../utils/helpers';
|
|
6
6
|
import { Comment, hasComment } from './Comment';
|
|
7
7
|
import { DefaultValue } from './DefaultValue';
|
|
8
8
|
import { Icon } from './Icon';
|
|
9
9
|
import { MemberSources } from './MemberSources';
|
|
10
10
|
import { Parameter } from './Parameter';
|
|
11
|
-
import { Type } from './Type';
|
|
11
|
+
import { extractDeclarationFromType, Type } from './Type';
|
|
12
12
|
import { TypeParameters } from './TypeParameters';
|
|
13
13
|
import { TypeParametersGeneric } from './TypeParametersGeneric';
|
|
14
14
|
|
|
@@ -17,17 +17,17 @@ export interface MemberDeclarationProps {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export function MemberDeclaration({ id }: MemberDeclarationProps) {
|
|
20
|
-
const reflection =
|
|
20
|
+
const reflection = useRequiredReflection(id);
|
|
21
21
|
const minimal = useMinimalLayout();
|
|
22
22
|
const showTypes = reflection.typeParameters && reflection.typeParameters.length > 0;
|
|
23
|
-
const showDeclaration = !minimal && reflection.type
|
|
23
|
+
const showDeclaration = !minimal && extractDeclarationFromType(reflection.type);
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
26
|
<>
|
|
27
27
|
<div className="tsd-panel-content">
|
|
28
28
|
<div className="tsd-signature tsd-kind-icon">
|
|
29
29
|
<Icon reflection={reflection} />
|
|
30
|
-
{reflection.name}
|
|
30
|
+
{escapeMdx(reflection.name)}
|
|
31
31
|
<TypeParametersGeneric params={reflection.typeParameters} />
|
|
32
32
|
<span className="tsd-signature-symbol">{reflection.flags?.isOptional && '?'}: </span>{' '}
|
|
33
33
|
<Type type={reflection.type} />
|
|
@@ -58,7 +58,7 @@ export function MemberDeclaration({ id }: MemberDeclarationProps) {
|
|
|
58
58
|
{showDeclaration && (
|
|
59
59
|
<div className="tsd-type-declaration">
|
|
60
60
|
<h4>Type declaration</h4>
|
|
61
|
-
<Parameter param={reflection.type
|
|
61
|
+
<Parameter param={extractDeclarationFromType(reflection.type)} />
|
|
62
62
|
</div>
|
|
63
63
|
)}
|
|
64
64
|
</div>
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.getterSetter.hbs
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import type { JSONOutput } from 'typedoc';
|
|
5
3
|
import { useMinimalLayout } from '../hooks/useMinimalLayout';
|
|
4
|
+
import type { TSDDeclarationReflection } from '../types';
|
|
5
|
+
import { escapeMdx } from '../utils/helpers';
|
|
6
6
|
import { Icon } from './Icon';
|
|
7
7
|
import { hasSigBody, MemberSignatureBody } from './MemberSignatureBody';
|
|
8
8
|
import { MemberSignatureTitle } from './MemberSignatureTitle';
|
|
9
9
|
|
|
10
10
|
export interface MemberGetterSetterProps {
|
|
11
11
|
inPanel?: boolean;
|
|
12
|
-
getter?:
|
|
13
|
-
setter?:
|
|
12
|
+
getter?: TSDDeclarationReflection['getSignature'];
|
|
13
|
+
setter?: TSDDeclarationReflection['setSignature'];
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// eslint-disable-next-line complexity
|
|
@@ -30,7 +30,7 @@ export function MemberGetterSetter({ inPanel, getter, setter }: MemberGetterSett
|
|
|
30
30
|
<li className="tsd-signature tsd-kind-icon">
|
|
31
31
|
<Icon reflection={getter} />
|
|
32
32
|
<span className="tsd-signature-symbol">get </span>
|
|
33
|
-
{getter.name}
|
|
33
|
+
{escapeMdx(getter.name)}
|
|
34
34
|
<MemberSignatureTitle hideName sig={getter} />
|
|
35
35
|
</li>
|
|
36
36
|
)}
|
|
@@ -39,7 +39,7 @@ export function MemberGetterSetter({ inPanel, getter, setter }: MemberGetterSett
|
|
|
39
39
|
<li className="tsd-signature tsd-kind-icon">
|
|
40
40
|
<Icon reflection={setter} />
|
|
41
41
|
<span className="tsd-signature-symbol">set </span>
|
|
42
|
-
{setter.name}
|
|
42
|
+
{escapeMdx(setter.name)}
|
|
43
43
|
<MemberSignatureTitle hideName sig={setter} />
|
|
44
44
|
</li>
|
|
45
45
|
)}
|