@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.
Files changed (138) hide show
  1. package/README.md +27 -5
  2. package/lib/components/AnchorLink.js +15 -10
  3. package/lib/components/AnchorLink.js.map +1 -1
  4. package/lib/components/ApiChangelog.js +9 -11
  5. package/lib/components/ApiChangelog.js.map +1 -1
  6. package/lib/components/ApiDataContext.js +2 -2
  7. package/lib/components/ApiIndex.js +55 -37
  8. package/lib/components/ApiIndex.js.map +1 -1
  9. package/lib/components/ApiItem.js +33 -29
  10. package/lib/components/ApiItem.js.map +1 -1
  11. package/lib/components/ApiItemLayout.js +49 -27
  12. package/lib/components/ApiItemLayout.js.map +1 -1
  13. package/lib/components/ApiPage.js +18 -10
  14. package/lib/components/ApiPage.js.map +1 -1
  15. package/lib/components/Breadcrumb.js +27 -14
  16. package/lib/components/Breadcrumb.js.map +1 -1
  17. package/lib/components/Comment.js +24 -18
  18. package/lib/components/Comment.js.map +1 -1
  19. package/lib/components/CommentBadges.js +8 -11
  20. package/lib/components/CommentBadges.js.map +1 -1
  21. package/lib/components/DefaultValue.js +20 -20
  22. package/lib/components/DefaultValue.js.map +1 -1
  23. package/lib/components/Flags.js +9 -11
  24. package/lib/components/Flags.js.map +1 -1
  25. package/lib/components/Footer.js +11 -12
  26. package/lib/components/Footer.js.map +1 -1
  27. package/lib/components/Hierarchy.js +15 -16
  28. package/lib/components/Hierarchy.js.map +1 -1
  29. package/lib/components/Icon.js +2 -6
  30. package/lib/components/Icon.js.map +1 -1
  31. package/lib/components/Index.js +84 -62
  32. package/lib/components/Index.js.map +1 -1
  33. package/lib/components/Markdown.js +80 -66
  34. package/lib/components/Markdown.js.map +1 -1
  35. package/lib/components/Member.js +28 -28
  36. package/lib/components/Member.js.map +1 -1
  37. package/lib/components/MemberDeclaration.js +51 -42
  38. package/lib/components/MemberDeclaration.js.map +1 -1
  39. package/lib/components/MemberGetterSetter.js +50 -40
  40. package/lib/components/MemberGetterSetter.js.map +1 -1
  41. package/lib/components/MemberReference.js +27 -16
  42. package/lib/components/MemberReference.js.map +1 -1
  43. package/lib/components/MemberSignatureBody.js +57 -45
  44. package/lib/components/MemberSignatureBody.js.map +1 -1
  45. package/lib/components/MemberSignatureTitle.js +48 -27
  46. package/lib/components/MemberSignatureTitle.js.map +1 -1
  47. package/lib/components/MemberSignatures.js +46 -38
  48. package/lib/components/MemberSignatures.js.map +1 -1
  49. package/lib/components/MemberSources.js +18 -15
  50. package/lib/components/MemberSources.js.map +1 -1
  51. package/lib/components/Members.js +32 -31
  52. package/lib/components/Members.js.map +1 -1
  53. package/lib/components/MembersGroup.js +24 -22
  54. package/lib/components/MembersGroup.js.map +1 -1
  55. package/lib/components/Parameter.js +139 -109
  56. package/lib/components/Parameter.js.map +1 -1
  57. package/lib/components/Reflection.js +113 -90
  58. package/lib/components/Reflection.js.map +1 -1
  59. package/lib/components/SourceLink.js +12 -13
  60. package/lib/components/SourceLink.js.map +1 -1
  61. package/lib/components/Type.js +320 -206
  62. package/lib/components/Type.js.map +1 -1
  63. package/lib/components/TypeAndParent.js +11 -10
  64. package/lib/components/TypeAndParent.js.map +1 -1
  65. package/lib/components/TypeParameters.js +23 -20
  66. package/lib/components/TypeParameters.js.map +1 -1
  67. package/lib/components/TypeParametersGeneric.js +17 -16
  68. package/lib/components/TypeParametersGeneric.js.map +1 -1
  69. package/lib/components/VersionBanner.js +21 -9
  70. package/lib/components/VersionBanner.js.map +1 -1
  71. package/lib/hooks/useBreadcrumbs.js +2 -2
  72. package/lib/hooks/useGitRefName.js +2 -2
  73. package/lib/hooks/useMinimalLayout.js +2 -2
  74. package/lib/hooks/useReflection.js +10 -6
  75. package/lib/hooks/useReflection.js.map +1 -1
  76. package/lib/hooks/useReflectionMap.js +2 -2
  77. package/lib/index.js +62 -25
  78. package/lib/index.js.map +1 -1
  79. package/lib/plugin/data.js +61 -18
  80. package/lib/plugin/data.js.map +1 -1
  81. package/lib/plugin/version.js +5 -4
  82. package/lib/plugin/version.js.map +1 -1
  83. package/lib/utils/helpers.js +8 -0
  84. package/lib/utils/helpers.js.map +1 -0
  85. package/lib/utils/hierarchy.js +6 -3
  86. package/lib/utils/hierarchy.js.map +1 -1
  87. package/lib/utils/icons.js +2 -5
  88. package/lib/utils/icons.js.map +1 -1
  89. package/lib/utils/markdown.js +5 -7
  90. package/lib/utils/markdown.js.map +1 -1
  91. package/package.json +17 -14
  92. package/src/components/AnchorLink.tsx +6 -3
  93. package/src/components/ApiChangelog.tsx +0 -1
  94. package/src/components/ApiDataContext.ts +2 -2
  95. package/src/components/ApiIndex.tsx +1 -1
  96. package/src/components/ApiItem.tsx +18 -20
  97. package/src/components/ApiItemLayout.tsx +1 -2
  98. package/src/components/ApiPage.tsx +18 -13
  99. package/src/components/Breadcrumb.tsx +2 -3
  100. package/src/components/Comment.tsx +3 -4
  101. package/src/components/CommentBadges.tsx +0 -1
  102. package/src/components/DefaultValue.tsx +0 -1
  103. package/src/components/Flags.tsx +1 -1
  104. package/src/components/Footer.tsx +0 -2
  105. package/src/components/Hierarchy.tsx +0 -1
  106. package/src/components/Icon.tsx +2 -3
  107. package/src/components/Index.tsx +14 -19
  108. package/src/components/Markdown.tsx +54 -25
  109. package/src/components/Member.tsx +7 -6
  110. package/src/components/MemberDeclaration.tsx +7 -7
  111. package/src/components/MemberGetterSetter.tsx +6 -6
  112. package/src/components/MemberReference.tsx +4 -4
  113. package/src/components/MemberSignatureBody.tsx +5 -5
  114. package/src/components/MemberSignatureTitle.tsx +11 -9
  115. package/src/components/MemberSignatures.tsx +5 -5
  116. package/src/components/MemberSources.tsx +3 -5
  117. package/src/components/Members.tsx +3 -4
  118. package/src/components/MembersGroup.tsx +1 -2
  119. package/src/components/Parameter.tsx +7 -12
  120. package/src/components/README.md +1 -1
  121. package/src/components/Reflection.tsx +7 -10
  122. package/src/components/SourceLink.tsx +0 -2
  123. package/src/components/Type.tsx +34 -22
  124. package/src/components/TypeAndParent.tsx +0 -1
  125. package/src/components/TypeParameters.tsx +0 -1
  126. package/src/components/TypeParametersGeneric.tsx +3 -3
  127. package/src/components/VersionBanner.tsx +1 -1
  128. package/src/hooks/useReflection.ts +11 -4
  129. package/src/hooks/useReflectionMap.ts +2 -2
  130. package/src/index.ts +92 -39
  131. package/src/plugin/data.ts +123 -54
  132. package/src/plugin/sidebar.ts +4 -3
  133. package/src/types.ts +24 -33
  134. package/src/utils/helpers.ts +4 -0
  135. package/src/utils/hierarchy.ts +11 -7
  136. package/src/utils/icons.ts +2 -3
  137. package/src/utils/markdown.ts +10 -7
  138. package/src/utils/visibility.ts +4 -4
@@ -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.DeclarationReflection) {
11
+ export function createHierarchy(reflection: JSONOutput.Reflection) {
12
12
  let root!: HierarchyNode;
13
13
  let hierarchy!: HierarchyNode;
14
14
 
15
- function push(types: JSONOutput.SomeType[]) {
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;
@@ -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: 'bracket', // ObjectLiteral
30
- 4_194_304: 'symbol-parameter', // TypeAlias
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 {
@@ -1,5 +1,5 @@
1
1
  import type { PropVersionMetadata } from '@docusaurus/plugin-content-docs';
2
- import type { DeclarationReflectionMap } from '../types';
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: DeclarationReflectionMap,
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: DeclarationReflectionMap,
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
- // TODO: Handle `routeBasePath`? Something else besides "docs"?
66
- const url = currentVersion.isLast ? `/docs/${target}` : `/docs/${version}/${target}`;
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: DeclarationReflectionMap,
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
  }
@@ -1,8 +1,8 @@
1
1
  import type { JSONOutput } from 'typedoc';
2
- import type { DeclarationReflectionMap } from '../types';
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: DeclarationReflectionMap): boolean {
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: DeclarationReflectionMap,
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: DeclarationReflectionMap,
28
+ reflections: TSDDeclarationReflectionMap,
29
29
  ): boolean {
30
30
  return Boolean(group.children?.every((child) => hasOwnDocument(child, reflections)));
31
31
  }