Skip to content

Commit 9561655

Browse files
refactor(docusaurus-theme): use typedoc types
1 parent c51b73d commit 9561655

File tree

3 files changed

+24
-50
lines changed

3 files changed

+24
-50
lines changed

packages/docusaurus-theme/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@types/react": "^18.3.3",
1919
"@types/react-dom": "^18.3.0",
2020
"@types/react-is": "^18",
21+
"typedoc": "^0.28.4",
2122
"typescript": "~5.5.4"
2223
},
2324
"main": "lib/index.js",

packages/docusaurus-theme/src/components/prop_table/prop_table.tsx

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,56 +18,10 @@ import { useCallback, useMemo } from 'react';
1818
import { css } from '@emotion/react';
1919
import Heading from '@theme/Heading';
2020
import types from '@elastic/eui-docgen/dist/types.json';
21+
import { JSONOutput } from 'typedoc';
2122

2223
import { PropTableExtendedTypes } from './extended_types';
2324

24-
export interface Source {
25-
fileName: string;
26-
line: number;
27-
character: number;
28-
url: string;
29-
}
30-
31-
export interface Child {
32-
id: number;
33-
name: string;
34-
variant: string;
35-
kind: number;
36-
flags: Record<string, unknown>;
37-
children?: Child[];
38-
groups?: Group[];
39-
sources?: Source[];
40-
type?: {
41-
type: string;
42-
types?: { type: string; value?: string }[];
43-
declaration?: Record<string, unknown>;
44-
target?: { qualifiedName: string };
45-
name?: string;
46-
package?: string;
47-
};
48-
defaultValue?: string;
49-
}
50-
51-
export interface Group {
52-
title: string;
53-
children: number[];
54-
}
55-
56-
export interface Types {
57-
schemaVersion: string;
58-
id: number;
59-
name: string;
60-
variant: string;
61-
kind: number;
62-
flags: Record<string, unknown>;
63-
children: Child[];
64-
groups: Group[];
65-
packageName: string;
66-
readme: unknown[];
67-
symbolIdMap: Record<string, unknown>;
68-
files: Record<string, unknown>;
69-
}
70-
7125
export interface PropTableProps {
7226
definition: ProcessedComponent;
7327
headingLevel?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
@@ -187,9 +141,10 @@ export const PropTable = ({
187141
) {
188142
const result = value
189143
.replace(/{@link (\w+)}/g, (_, componentName) => {
190-
const componentSource = (types as Types).children.find(
191-
(item) => item.name === componentName
192-
)?.sources?.[0];
144+
const componentSource = (
145+
types as JSONOutput.ProjectReflection
146+
).children?.find((item) => item.name === componentName)
147+
?.sources?.[0];
193148

194149
if (componentSource) {
195150
const { fileName, line } = componentSource;

yarn.lock

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7128,6 +7128,7 @@ __metadata:
71287128
react-is: "npm:^18.3.1"
71297129
react-live: "patch:react-live@npm%3A4.1.7#~/.yarn/patches/react-live-npm-4.1.7-7b41625faa.patch"
71307130
react-window: "npm:^1.8.10"
7131+
typedoc: "npm:^0.28.4"
71317132
typescript: "npm:~5.5.4"
71327133
peerDependencies:
71337134
react: ^18.0.0
@@ -40151,6 +40152,23 @@ __metadata:
4015140152
languageName: node
4015240153
linkType: hard
4015340154

40155+
"typedoc@npm:^0.28.4":
40156+
version: 0.28.4
40157+
resolution: "typedoc@npm:0.28.4"
40158+
dependencies:
40159+
"@gerrit0/mini-shiki": "npm:^3.2.2"
40160+
lunr: "npm:^2.3.9"
40161+
markdown-it: "npm:^14.1.0"
40162+
minimatch: "npm:^9.0.5"
40163+
yaml: "npm:^2.7.1"
40164+
peerDependencies:
40165+
typescript: 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x
40166+
bin:
40167+
typedoc: bin/typedoc
40168+
checksum: 10c0/5c7f4019da81e8b0869e4757b3d74c001dc021be381c5716a14212fbf63ad81bcfc470e040b7eac132603447c367019d5acab323d1b358b040979f1f56fe6393
40169+
languageName: node
40170+
linkType: hard
40171+
4015440172
"typescript@npm:4.5.3":
4015540173
version: 4.5.3
4015640174
resolution: "typescript@npm:4.5.3"

0 commit comments

Comments
 (0)