@apify/docusaurus-plugin-typedoc-api 3.0.1 → 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
package/src/utils/hierarchy.ts
CHANGED
|
@@ -8,11 +8,15 @@ export interface HierarchyNode {
|
|
|
8
8
|
|
|
9
9
|
// The JSON output does not include hierarchy information, so we need to duplicate the logic!
|
|
10
10
|
// https://github.com/TypeStrong/typedoc/blob/master/src/lib/converter/plugins/TypePlugin.ts#L98
|
|
11
|
-
export function createHierarchy(reflection: JSONOutput.
|
|
11
|
+
export function createHierarchy(reflection: JSONOutput.Reflection) {
|
|
12
12
|
let root!: HierarchyNode;
|
|
13
13
|
let hierarchy!: HierarchyNode;
|
|
14
14
|
|
|
15
|
-
function push(types
|
|
15
|
+
function push(types?: JSONOutput.SomeType[]) {
|
|
16
|
+
if (!types) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
const level: HierarchyNode = { types };
|
|
17
21
|
|
|
18
22
|
if (hierarchy) {
|
|
@@ -24,22 +28,22 @@ export function createHierarchy(reflection: JSONOutput.DeclarationReflection) {
|
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
if (reflection.extendedTypes) {
|
|
28
|
-
push(reflection.extendedTypes);
|
|
31
|
+
if ('extendedTypes' in reflection && reflection.extendedTypes) {
|
|
32
|
+
push((reflection as JSONOutput.DeclarationReflection).extendedTypes);
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
push([
|
|
32
36
|
{
|
|
33
|
-
id: reflection.id,
|
|
34
37
|
name: reflection.name,
|
|
38
|
+
target: reflection.id,
|
|
35
39
|
type: 'reference',
|
|
36
40
|
},
|
|
37
41
|
]);
|
|
38
42
|
|
|
39
43
|
hierarchy.isTarget = true;
|
|
40
44
|
|
|
41
|
-
if (reflection.extendedBy) {
|
|
42
|
-
push(reflection.extendedBy);
|
|
45
|
+
if ('extendedBy' in reflection && reflection.extendedBy) {
|
|
46
|
+
push((reflection as JSONOutput.DeclarationReflection).extendedBy);
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
return root;
|
package/src/utils/icons.ts
CHANGED
|
@@ -26,9 +26,8 @@ const KIND_ICONS: Record<ReflectionKind, string> = {
|
|
|
26
26
|
262_144: 'symbol-field', // Accessor
|
|
27
27
|
524_288: 'symbol-field', // GetSignature
|
|
28
28
|
1_048_576: 'symbol-field', // SetSignature
|
|
29
|
-
2_097_152: '
|
|
30
|
-
4_194_304: '
|
|
31
|
-
8_388_608: 'references', // Reference
|
|
29
|
+
2_097_152: 'symbol-parameter', // TypeAlias
|
|
30
|
+
4_194_304: 'references', // Reference
|
|
32
31
|
};
|
|
33
32
|
|
|
34
33
|
export function getKindIcon(kind: ReflectionKind, name: string): string {
|
package/src/utils/markdown.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PropVersionMetadata } from '@docusaurus/plugin-content-docs';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TSDDeclarationReflectionMap } from '../types';
|
|
3
3
|
|
|
4
4
|
function splitLinkText(text: string): { caption: string; target: string } {
|
|
5
5
|
let splitIndex = text.indexOf('|');
|
|
@@ -25,7 +25,7 @@ function splitLinkText(text: string): { caption: string; target: string } {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function findReflectionWithMatchingTarget(
|
|
28
|
-
reflections:
|
|
28
|
+
reflections: TSDDeclarationReflectionMap,
|
|
29
29
|
symbol: string,
|
|
30
30
|
member?: string,
|
|
31
31
|
) {
|
|
@@ -39,7 +39,7 @@ function findReflectionWithMatchingTarget(
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function replaceApiLinks(
|
|
42
|
-
reflections:
|
|
42
|
+
reflections: TSDDeclarationReflectionMap,
|
|
43
43
|
): (match: string, tagName: string, content: string) => string {
|
|
44
44
|
return (match: string, tagName: string, content: string) => {
|
|
45
45
|
const { caption, target } = splitLinkText(content);
|
|
@@ -57,13 +57,15 @@ function replaceApiLinks(
|
|
|
57
57
|
|
|
58
58
|
function replaceDocLinks(
|
|
59
59
|
currentVersion: PropVersionMetadata,
|
|
60
|
+
baseUrl: string,
|
|
60
61
|
): (match: string, content: string) => string {
|
|
61
62
|
return (match: string, content: string) => {
|
|
62
63
|
const { caption, target } = splitLinkText(content);
|
|
63
64
|
const version = currentVersion.version === 'current' ? 'next' : currentVersion.version;
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
const url = currentVersion.isLast
|
|
67
|
+
? `${baseUrl === '/' ? '' : baseUrl}/${target}`
|
|
68
|
+
: `${baseUrl === '/' ? '' : baseUrl}/${version}/${target}`;
|
|
67
69
|
|
|
68
70
|
return `[${caption}](${url})`;
|
|
69
71
|
};
|
|
@@ -73,10 +75,11 @@ function replaceDocLinks(
|
|
|
73
75
|
// @see https://github.com/TypeStrong/typedoc/blob/master/src/lib/output/plugins/MarkedLinksPlugin.ts
|
|
74
76
|
export function replaceLinkTokens(
|
|
75
77
|
markdown: string,
|
|
76
|
-
reflections:
|
|
78
|
+
reflections: TSDDeclarationReflectionMap,
|
|
77
79
|
currentVersion: PropVersionMetadata,
|
|
80
|
+
docsBaseUrl: string,
|
|
78
81
|
) {
|
|
79
82
|
return markdown
|
|
80
83
|
.replace(/{@(link|linkcode|linkplain|apilink)\s+([^}]+?)}/gi, replaceApiLinks(reflections))
|
|
81
|
-
.replace(/{@doclink\s+([^}]+?)}/gi, replaceDocLinks(currentVersion));
|
|
84
|
+
.replace(/{@doclink\s+([^}]+?)}/gi, replaceDocLinks(currentVersion, docsBaseUrl));
|
|
82
85
|
}
|
package/src/utils/visibility.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { JSONOutput } from 'typedoc';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TSDDeclarationReflectionMap } from '../types';
|
|
3
3
|
|
|
4
4
|
// https://github.com/TypeStrong/typedoc/blob/master/src/lib/output/themes/DefaultTheme.ts#L264
|
|
5
|
-
export function hasOwnDocument(id: number, reflections:
|
|
5
|
+
export function hasOwnDocument(id: number, reflections: TSDDeclarationReflectionMap): boolean {
|
|
6
6
|
const reflection = reflections[id];
|
|
7
7
|
|
|
8
8
|
return Boolean(reflection?.permalink && !reflection.permalink.includes('#'));
|
|
@@ -11,7 +11,7 @@ export function hasOwnDocument(id: number, reflections: DeclarationReflectionMap
|
|
|
11
11
|
// https://github.com/TypeStrong/typedoc/blob/2103f347c9cba40fcaa1f67e36f7cea0bdea2f0f/src/lib/models/ReflectionCategory.ts#L44
|
|
12
12
|
export function allCategoryChildrenHaveOwnDocument(
|
|
13
13
|
category: JSONOutput.ReflectionCategory,
|
|
14
|
-
reflections:
|
|
14
|
+
reflections: TSDDeclarationReflectionMap,
|
|
15
15
|
): boolean {
|
|
16
16
|
let onlyOwnDocuments = true;
|
|
17
17
|
|
|
@@ -25,7 +25,7 @@ export function allCategoryChildrenHaveOwnDocument(
|
|
|
25
25
|
// https://github.com/TypeStrong/typedoc/blob/2103f347c9cba40fcaa1f67e36f7cea0bdea2f0f/src/lib/models/ReflectionGroup.ts#L81
|
|
26
26
|
export function allGroupChildrenHaveOwnDocument(
|
|
27
27
|
group: JSONOutput.ReflectionGroup,
|
|
28
|
-
reflections:
|
|
28
|
+
reflections: TSDDeclarationReflectionMap,
|
|
29
29
|
): boolean {
|
|
30
30
|
return Boolean(group.children?.every((child) => hasOwnDocument(child, reflections)));
|
|
31
31
|
}
|