@stainless-api/docs-ui 0.1.0-beta.5 → 0.1.0-beta.50
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/dist/breadcrumbs-C6pTTw_o.d.ts +20 -0
- package/dist/breadcrumbs-DEyC9k79.d.ts +20 -0
- package/dist/breadcrumbs-nSFZO5Gf.js +63 -0
- package/dist/chunk-DRcLgZ1e.js +18 -0
- package/dist/component-DRO8kQSp.js +23 -0
- package/dist/component-generics-B6Fn47Mz.js +45 -0
- package/dist/component-generics-D_yxZT6v.d.ts +30 -0
- package/dist/component-generics-DxN-MaP2.d.ts +30 -0
- package/dist/components/MaskedInput.d.ts +14 -0
- package/dist/components/MaskedInput.js +76 -0
- package/dist/components/breadcrumbs.d.ts +2 -0
- package/dist/components/breadcrumbs.js +9 -0
- package/dist/components/icons.d.ts +55 -0
- package/dist/components/icons.js +3 -0
- package/dist/components/index.d.ts +10 -0
- package/dist/components/index.js +18 -0
- package/dist/components/method.d.ts +2 -0
- package/dist/components/method.js +10 -0
- package/dist/components/overview.d.ts +2 -0
- package/dist/components/overview.js +11 -0
- package/dist/components/primitives.d.ts +2 -0
- package/dist/components/primitives.js +8 -0
- package/dist/components/properties.d.ts +2 -0
- package/dist/components/properties.js +9 -0
- package/dist/components/sdk.d.ts +2 -0
- package/dist/components/sdk.js +10 -0
- package/dist/components/sidebar.d.ts +2 -0
- package/dist/components/sidebar.js +11 -0
- package/dist/components/snippets.d.ts +3 -0
- package/dist/components/snippets.js +9 -0
- package/dist/components-D7M-BwNI.js +71 -0
- package/dist/contexts/component-generics.d.ts +2 -0
- package/dist/contexts/component-generics.js +3 -0
- package/dist/contexts/component-types.d.ts +16 -0
- package/dist/contexts/component-types.js +0 -0
- package/dist/contexts/component.d.ts +29 -0
- package/dist/contexts/component.js +27 -0
- package/dist/contexts/docs.d.ts +2 -0
- package/dist/contexts/docs.js +3 -0
- package/dist/contexts/index.d.ts +16 -0
- package/dist/contexts/index.js +7 -0
- package/dist/contexts/markdown.d.ts +2 -0
- package/dist/contexts/markdown.js +4 -0
- package/dist/contexts/navigation.d.ts +2 -0
- package/dist/contexts/navigation.js +3 -0
- package/dist/contexts/use-components.d.ts +14 -0
- package/dist/contexts/use-components.js +4 -0
- package/dist/contexts-p3rRZDlM.js +39 -0
- package/dist/csharp-CDSxfCZE.js +283 -0
- package/dist/docs-CXqi26jB.js +54 -0
- package/dist/docs-dNFWvk6w.d.ts +47 -0
- package/dist/docs-mMDqYdkf.d.ts +47 -0
- package/dist/go-1c3S5ETL.js +303 -0
- package/dist/http-2QNWXH9t.js +330 -0
- package/dist/icons-Ckod9aod.js +869 -0
- package/dist/index-0imEqwWy.d.ts +15 -0
- package/dist/index-BJR7MT73.d.ts +13 -0
- package/dist/index-DGWbX2x8.d.ts +13 -0
- package/dist/index-DJO7hQAU.d.ts +274 -0
- package/dist/index-DMFZJxNb.d.ts +15 -0
- package/dist/index-tw6MEWKp.d.ts +274 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +29 -7542
- package/dist/java-BbjF_oUI.js +403 -0
- package/dist/languages/csharp.d.ts +11 -0
- package/dist/languages/csharp.js +9 -0
- package/dist/languages/go.d.ts +11 -0
- package/dist/languages/go.js +9 -0
- package/dist/languages/http.d.ts +11 -0
- package/dist/languages/http.js +19 -0
- package/dist/languages/index.d.ts +11 -0
- package/dist/languages/index.js +26 -0
- package/dist/languages/java.d.ts +11 -0
- package/dist/languages/java.js +9 -0
- package/dist/languages/python.d.ts +11 -0
- package/dist/languages/python.js +9 -0
- package/dist/languages/ruby.d.ts +11 -0
- package/dist/languages/ruby.js +9 -0
- package/dist/languages/typescript.d.ts +11 -0
- package/dist/languages/typescript.js +9 -0
- package/dist/languages-BCYZjzuS.js +26 -0
- package/dist/markdown/index.d.ts +12 -0
- package/dist/markdown/index.js +104 -0
- package/dist/markdown/md.d.ts +15 -0
- package/dist/markdown/md.js +3 -0
- package/dist/markdown/printer.d.ts +2 -0
- package/dist/markdown/printer.js +28 -0
- package/dist/markdown/utils.d.ts +3 -0
- package/dist/markdown/utils.js +3 -0
- package/dist/markdown-CxdeWgjV.js +48 -0
- package/dist/markdown-DeSSIANr.d.ts +22 -0
- package/dist/markdown-OuUthjwK.d.ts +22 -0
- package/dist/md-oM2tUaCA.js +41 -0
- package/dist/method-BiXJltKa.d.ts +71 -0
- package/dist/method-CE08mUME.js +115 -0
- package/dist/method-DQ3lDoTM.d.ts +71 -0
- package/dist/navigation-BX8nuda9.d.ts +29 -0
- package/dist/navigation-C5TN0SgC.js +24 -0
- package/dist/navigation-CWDfzVoR.d.ts +29 -0
- package/dist/overview-B43BuZbK.d.ts +39 -0
- package/dist/overview-MTDgZ7Xr.d.ts +39 -0
- package/dist/overview-S2hUqPXA.js +139 -0
- package/dist/primitives-1lB1L0is.d.ts +97 -0
- package/dist/primitives-BIWfwN5L.js +258 -0
- package/dist/primitives-DLv4uMoz.d.ts +97 -0
- package/dist/printer-DBw4S_Jn.d.ts +13 -0
- package/dist/printer-bNxiG6UB.js +74 -0
- package/dist/properties-B-giMW4K.d.ts +54 -0
- package/dist/properties-BvP2WAjP.d.ts +54 -0
- package/dist/properties-jlGW3USi.js +131 -0
- package/dist/python-USOwFDv_.js +279 -0
- package/dist/routing-CMqh1cTZ.d.ts +54 -0
- package/dist/routing-Wbb7YECB.js +194 -0
- package/dist/routing.d.ts +2 -0
- package/dist/routing.js +3 -180
- package/dist/ruby-CSvGbSLe.js +387 -0
- package/dist/sdk-BwXeHS3_.d.ts +118 -0
- package/dist/sdk-CSCbbn3O.js +336 -0
- package/dist/sdk-DXdNszcC.d.ts +118 -0
- package/dist/sidebar-CWyvCrJ0.js +81 -0
- package/dist/sidebar-DGGt5gik.d.ts +36 -0
- package/dist/sidebar-DfS6SWQz.d.ts +36 -0
- package/dist/snippets-BQLXEIf6.js +161 -0
- package/dist/snippets-BRs_4F1I.d.ts +51 -0
- package/dist/snippets-DxSMK50g.d.ts +51 -0
- package/dist/spec.d.ts +65 -0
- package/dist/spec.js +167 -0
- package/dist/style-D7RO5ymE.d.ts +168 -0
- package/dist/style-gnVEeXFj.js +169 -0
- package/dist/style.d.ts +2 -0
- package/dist/style.js +3 -0
- package/dist/styles/main.css +727 -754
- package/dist/styles/main.js +0 -0
- package/dist/styles/primitives.css +317 -461
- package/dist/styles/primitives.js +0 -0
- package/dist/styles/resets.css +32 -41
- package/dist/styles/resets.js +0 -0
- package/dist/styles/search.css +175 -274
- package/dist/styles/search.js +0 -0
- package/dist/styles/sidebar.css +59 -60
- package/dist/styles/sidebar.js +0 -0
- package/dist/styles/variables.css +26 -89
- package/dist/styles/variables.js +0 -0
- package/dist/styles.css +2910 -0
- package/dist/styles.mjs +1 -0
- package/dist/typescript-DXG9psK3.js +449 -0
- package/dist/use-components-RWQbviGq.js +7 -0
- package/dist/utils-BaLi5Bed.d.ts +21 -0
- package/dist/utils-CqnL9Fc3.js +31 -0
- package/dist/utils-D_1AWSRX.js +32 -0
- package/dist/utils-_AEBNJhG.d.ts +21 -0
- package/dist/utils-d8paVwKN.d.ts +14 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +3 -0
- package/package.json +73 -21
- package/dist/mcp.js +0 -16003
- package/dist/styles/snippets.css +0 -132
- package/src/components/breadcrumbs.tsx +0 -94
- package/src/components/chat.tsx +0 -154
- package/src/components/dropdown.tsx +0 -91
- package/src/components/icons.tsx +0 -584
- package/src/components/index.ts +0 -9
- package/src/components/method.tsx +0 -144
- package/src/components/overview.tsx +0 -159
- package/src/components/primitives.tsx +0 -284
- package/src/components/properties.tsx +0 -130
- package/src/components/scripts/dropdown.ts +0 -78
- package/src/components/sdk.tsx +0 -402
- package/src/components/sidebar.tsx +0 -99
- package/src/components/snippets.tsx +0 -179
- package/src/contexts/component-generics.tsx +0 -48
- package/src/contexts/component-types.tsx +0 -5
- package/src/contexts/component.tsx +0 -32
- package/src/contexts/docs.tsx +0 -75
- package/src/contexts/index.tsx +0 -17
- package/src/contexts/markdown.tsx +0 -43
- package/src/contexts/navigation.tsx +0 -44
- package/src/contexts/search.tsx +0 -28
- package/src/contexts/use-components.tsx +0 -4
- package/src/index.ts +0 -6
- package/src/languages/go.tsx +0 -281
- package/src/languages/http.tsx +0 -321
- package/src/languages/index.ts +0 -26
- package/src/languages/java.tsx +0 -358
- package/src/languages/python.tsx +0 -255
- package/src/languages/ruby.tsx +0 -320
- package/src/languages/typescript.tsx +0 -393
- package/src/markdown/index.ts +0 -107
- package/src/markdown/md.ts +0 -45
- package/src/markdown/utils.ts +0 -49
- package/src/routing.ts +0 -238
- package/src/search/form.tsx +0 -127
- package/src/search/index.tsx +0 -1
- package/src/search/indexer.ts +0 -246
- package/src/search/mcp.ts +0 -61
- package/src/search/printer.tsx +0 -86
- package/src/search/providers/algolia.ts +0 -88
- package/src/search/providers/fuse.ts +0 -19
- package/src/search/providers/pagefind.ts +0 -17
- package/src/search/providers/walker.ts +0 -30
- package/src/search/results.tsx +0 -181
- package/src/search/state.ts +0 -64
- package/src/search/types.ts +0 -116
- package/src/style.ts +0 -197
- package/src/styles/main.css +0 -993
- package/src/styles/primitives.css +0 -573
- package/src/styles/resets.css +0 -47
- package/src/styles/search.css +0 -342
- package/src/styles/sidebar.css +0 -87
- package/src/styles/snippets.css +0 -132
- package/src/styles/variables.css +0 -90
- package/src/utils.ts +0 -41
package/src/languages/ruby.tsx
DELETED
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type * as AST from '~/lib/json-spec-v2/RubyAST';
|
|
3
|
-
import { useDeclaration, useLanguage, useLanguageComponents, useSpec } from '../contexts';
|
|
4
|
-
import { useComponents } from '../contexts/use-components';
|
|
5
|
-
import style from '../style';
|
|
6
|
-
import { PropertyFn } from '.';
|
|
7
|
-
|
|
8
|
-
const ComplexTypes: Record<string, string> = {
|
|
9
|
-
RubyTypeObject: 'object',
|
|
10
|
-
RubyTypeUnion: 'union',
|
|
11
|
-
RubyTypeIntersection: 'intersection',
|
|
12
|
-
RubyTypeArray: 'array',
|
|
13
|
-
RubyTypeMap: 'hash',
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const Keywords: Record<string, string> = {
|
|
17
|
-
RubyTypeBinary: 'StringIO',
|
|
18
|
-
RubyTypeUnknown: 'untyped',
|
|
19
|
-
RubyTypeNull: 'nil',
|
|
20
|
-
RubyTypeInteger: 'Integer',
|
|
21
|
-
RubyTypeFloat: 'Float',
|
|
22
|
-
RubyTypeBoolean: 'bool',
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
type TypeProps = {
|
|
26
|
-
type: AST.RubyType;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export function TypeName({ type }: TypeProps) {
|
|
30
|
-
const Lang = useLanguageComponents();
|
|
31
|
-
return ComplexTypes[type.kind] ?? <Lang.Type type={type} />;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const VALID_IDENTIFIER = /^[_A-Za-z][_A-Za-z0-9]*$/;
|
|
35
|
-
|
|
36
|
-
function TypePreview({ path }: { path: string }) {
|
|
37
|
-
const spec = useSpec();
|
|
38
|
-
const language = useLanguage();
|
|
39
|
-
const decl = useDeclaration(path);
|
|
40
|
-
const { Join } = useComponents();
|
|
41
|
-
|
|
42
|
-
if (!(decl && 'children' in decl && decl.children.length > 0) || decl['type']?.['kind'] === 'RubyTypeUnion')
|
|
43
|
-
return;
|
|
44
|
-
|
|
45
|
-
const items = decl.children.map((prop, key) => (
|
|
46
|
-
<span key={key} className={style.TypePropertyName}>
|
|
47
|
-
<span className={style.TextIdentifier}>{spec?.decls?.[language]?.[prop]?.['ident']}</span>
|
|
48
|
-
</span>
|
|
49
|
-
));
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<span className={style.TypePreview} data-stldocs-type-preview="properties">
|
|
53
|
-
<span className={style.TypeBrace}>{' {'}</span>
|
|
54
|
-
<span className={style.TypePreviewContent}>
|
|
55
|
-
{' '}
|
|
56
|
-
<Join items={items} limit={3}>
|
|
57
|
-
<span className={style.TextOperator}>, </span>
|
|
58
|
-
</Join>{' '}
|
|
59
|
-
</span>
|
|
60
|
-
<span className={style.TypeBrace}>{'} '}</span>
|
|
61
|
-
</span>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function Type({ type }: TypeProps) {
|
|
66
|
-
const Lang = useLanguageComponents();
|
|
67
|
-
const { SDKReference, Join } = useComponents();
|
|
68
|
-
|
|
69
|
-
switch (type.kind) {
|
|
70
|
-
case 'RubyTypeBinary':
|
|
71
|
-
case 'RubyTypeUnknown':
|
|
72
|
-
case 'RubyTypeNull':
|
|
73
|
-
case 'RubyTypeInteger':
|
|
74
|
-
case 'RubyTypeFloat':
|
|
75
|
-
case 'RubyTypeBoolean':
|
|
76
|
-
return (
|
|
77
|
-
<span className={style.Type}>
|
|
78
|
-
<span className={style.TypeKeyword}>{Keywords[type.kind]}</span>
|
|
79
|
-
</span>
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
case 'RubyTypeString':
|
|
83
|
-
return (
|
|
84
|
-
<span className={style.Type}>
|
|
85
|
-
<span className={style.TypeString}>String</span>
|
|
86
|
-
</span>
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
case 'RubyTypeLiteral':
|
|
90
|
-
switch (typeof type.literal) {
|
|
91
|
-
case 'string':
|
|
92
|
-
return (
|
|
93
|
-
<span className={style.Type}>
|
|
94
|
-
<span className={style.LiteralString}>
|
|
95
|
-
{':'}
|
|
96
|
-
{type.literal.match(VALID_IDENTIFIER) ? type.literal : JSON.stringify(type.literal)}
|
|
97
|
-
</span>
|
|
98
|
-
</span>
|
|
99
|
-
);
|
|
100
|
-
case 'number':
|
|
101
|
-
return (
|
|
102
|
-
<span className={style.Type}>
|
|
103
|
-
<span className={style.LiteralNumeric}>{JSON.stringify(type.literal)}</span>
|
|
104
|
-
</span>
|
|
105
|
-
);
|
|
106
|
-
case 'boolean':
|
|
107
|
-
return (
|
|
108
|
-
<span className={style.Type}>
|
|
109
|
-
<span className={style.LiteralBoolean}>{JSON.stringify(type.literal)}</span>
|
|
110
|
-
</span>
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
case 'RubyTypeArray':
|
|
115
|
-
return (
|
|
116
|
-
<span className={style.Type}>
|
|
117
|
-
<span className={style.TypeArray}>{'Array['}</span>
|
|
118
|
-
<Lang.Type type={type.elementType} />
|
|
119
|
-
<span className={style.TypeArray}>{']'}</span>
|
|
120
|
-
</span>
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
case 'RubyTypeMap':
|
|
124
|
-
return (
|
|
125
|
-
<span className={style.Type}>
|
|
126
|
-
<span className={style.TypeArray}>{'Hash['}</span>
|
|
127
|
-
{type.indexType.kind === 'RubyTypeString' ? (
|
|
128
|
-
<span className={style.TypeString}>Symbol</span>
|
|
129
|
-
) : (
|
|
130
|
-
<Lang.Type type={type.indexType} />
|
|
131
|
-
)}
|
|
132
|
-
, <Lang.Type type={type.itemType} />
|
|
133
|
-
<span className={style.TypeArray}>{']'}</span>
|
|
134
|
-
</span>
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
case 'RubyTypeReference': {
|
|
138
|
-
const name = type.ident.split('.').at(-1);
|
|
139
|
-
if (!type.typeParameters || type.typeParameters.length === 0)
|
|
140
|
-
return (
|
|
141
|
-
<span className={style.Type}>
|
|
142
|
-
<SDKReference stainlessPath={type.$ref}>{name}</SDKReference>
|
|
143
|
-
<TypePreview path={type.$ref} />
|
|
144
|
-
</span>
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
const typeParameters = type.typeParameters.map((t, i) => <Lang.Type key={i} type={t} />);
|
|
148
|
-
|
|
149
|
-
return (
|
|
150
|
-
<span className={style.Type}>
|
|
151
|
-
<SDKReference stainlessPath={type.$ref}>{name}</SDKReference>
|
|
152
|
-
<span className={style.TypeBracket}>{'<'}</span>
|
|
153
|
-
<Join items={typeParameters}>
|
|
154
|
-
<span className={style.TextOperator}>, </span>
|
|
155
|
-
</Join>
|
|
156
|
-
<span className={style.TypeBracket}>{'>'}</span>
|
|
157
|
-
<TypePreview path={type.$ref} />
|
|
158
|
-
</span>
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
case 'RubyTypeIntersection':
|
|
163
|
-
case 'RubyTypeUnion': {
|
|
164
|
-
const items = type.types.map((t, key) => <Lang.Type key={key} type={t} />);
|
|
165
|
-
|
|
166
|
-
const delimiter = type.kind === 'RubyTypeUnion' ? '|' : '&';
|
|
167
|
-
|
|
168
|
-
return (
|
|
169
|
-
<span className={style.Type}>
|
|
170
|
-
<span className={style.TypePreview} data-stldocs-type-preview="union">
|
|
171
|
-
<span className={style.TypePreviewContent}>
|
|
172
|
-
<Join items={items} limit={3}>
|
|
173
|
-
<span className={style.TextOperator}> {delimiter} </span>
|
|
174
|
-
</Join>
|
|
175
|
-
</span>
|
|
176
|
-
</span>
|
|
177
|
-
</span>
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
case 'RubyTypeBuiltinClass':
|
|
182
|
-
return <span className={style.TypeReference}>{type.className}</span>;
|
|
183
|
-
|
|
184
|
-
case 'RubyTypeObject': {
|
|
185
|
-
const items = type.members.map((prop, key) => (
|
|
186
|
-
<span key={key} className={style.TextIdentifier}>
|
|
187
|
-
{prop.ident}
|
|
188
|
-
</span>
|
|
189
|
-
));
|
|
190
|
-
|
|
191
|
-
return (
|
|
192
|
-
<span className={style.Type}>
|
|
193
|
-
<span className={style.TypePreview} data-stldocs-type-preview="properties">
|
|
194
|
-
<span className={style.TypePreviewContent}>
|
|
195
|
-
<span className={style.TypeBrace}>{'{ '}</span>
|
|
196
|
-
<Join items={items} limit={3}>
|
|
197
|
-
<span className={style.TextOperator}>, </span>
|
|
198
|
-
</Join>
|
|
199
|
-
<span className={style.TypeBrace}>{'}'}</span>
|
|
200
|
-
</span>
|
|
201
|
-
</span>
|
|
202
|
-
</span>
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export type MethodSignatureProps = {
|
|
209
|
-
decl: AST.RubyDeclFunction;
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
export function MethodSignature({ decl }: MethodSignatureProps) {
|
|
213
|
-
const Lang = useLanguageComponents();
|
|
214
|
-
const { Join } = useComponents();
|
|
215
|
-
|
|
216
|
-
const params = decl.args.map((param, i) => (
|
|
217
|
-
<React.Fragment key={i}>
|
|
218
|
-
<span className={style.TextIdentifier}>{param.ident}</span>
|
|
219
|
-
</React.Fragment>
|
|
220
|
-
));
|
|
221
|
-
|
|
222
|
-
return (
|
|
223
|
-
<div className={style.MethodSignature}>
|
|
224
|
-
<span className={style.SignatureTitle}>
|
|
225
|
-
<span className={style.SignatureQualified}>
|
|
226
|
-
<span className={style.TextIdentifier}>{decl.qualified?.slice(0, -decl.ident.length)}</span>
|
|
227
|
-
</span>
|
|
228
|
-
<span className={style.SignatureName}>
|
|
229
|
-
<span className={style.TextIdentifier}>{decl.ident}</span>
|
|
230
|
-
</span>
|
|
231
|
-
<span className={style.MethodSignature}>
|
|
232
|
-
<span className={style.SignatureParen}>{'('}</span>
|
|
233
|
-
|
|
234
|
-
<span className={style.SignatureParams}>
|
|
235
|
-
<Join items={params}>
|
|
236
|
-
<span className={style.TextOperator}>{', '}</span>
|
|
237
|
-
</Join>
|
|
238
|
-
</span>
|
|
239
|
-
|
|
240
|
-
<span className={style.SignatureParen}>{')'}</span>
|
|
241
|
-
{' -> '}
|
|
242
|
-
{decl.returns ? <Lang.Type type={decl.returns} /> : 'void'}
|
|
243
|
-
</span>
|
|
244
|
-
</span>
|
|
245
|
-
</div>
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export type PropertyProps = {
|
|
250
|
-
decl: AST.RubyDeclaration;
|
|
251
|
-
children?: PropertyFn;
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
export function Property({ decl, children }: PropertyProps) {
|
|
255
|
-
const Lang = useLanguageComponents();
|
|
256
|
-
|
|
257
|
-
switch (decl.kind) {
|
|
258
|
-
case 'RubyDeclProperty':
|
|
259
|
-
return children({
|
|
260
|
-
name: decl.ident,
|
|
261
|
-
typeName: <Lang.TypeName type={decl.type} />,
|
|
262
|
-
type: decl.type.kind in ComplexTypes && <Lang.Type type={decl.type} />,
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
case 'RubyDeclTypeAlias':
|
|
266
|
-
return children({
|
|
267
|
-
name: decl.ident,
|
|
268
|
-
typeName: 'alias',
|
|
269
|
-
type: <Lang.Type type={decl.type} />,
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
case 'RubyDeclReference':
|
|
273
|
-
return children({ type: <Lang.Type type={decl.type} /> });
|
|
274
|
-
|
|
275
|
-
case 'RubyDeclClass':
|
|
276
|
-
return children({ name: decl.ident, typeName: 'class' });
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
export type DeclarationProps = { decl: AST.RubyDeclaration };
|
|
281
|
-
|
|
282
|
-
export function Declaration({ decl }: DeclarationProps) {
|
|
283
|
-
const Lang = useLanguageComponents();
|
|
284
|
-
|
|
285
|
-
if (!decl) return;
|
|
286
|
-
|
|
287
|
-
switch (decl.kind) {
|
|
288
|
-
case 'RubyDeclProperty':
|
|
289
|
-
return (
|
|
290
|
-
<>
|
|
291
|
-
<span className={style.TypePropertyName}>
|
|
292
|
-
<span className={style.TextIdentifier}>{decl.ident}</span>
|
|
293
|
-
</span>
|
|
294
|
-
<span className={style.TextPunctuation}>: </span>
|
|
295
|
-
<Lang.Type type={decl.type} />
|
|
296
|
-
</>
|
|
297
|
-
);
|
|
298
|
-
|
|
299
|
-
case 'RubyDeclTypeAlias':
|
|
300
|
-
return (
|
|
301
|
-
<>
|
|
302
|
-
<span className={style.TextIdentifier}>{decl.ident}</span>
|
|
303
|
-
<span className={style.TextOperator}> = </span>
|
|
304
|
-
<Lang.Type type={decl.type} />
|
|
305
|
-
</>
|
|
306
|
-
);
|
|
307
|
-
|
|
308
|
-
case 'RubyDeclClass':
|
|
309
|
-
return (
|
|
310
|
-
<>
|
|
311
|
-
<span className={style.TextKeyword}>class </span>
|
|
312
|
-
<span className={style.TextIdentifier}>{decl.ident}</span>
|
|
313
|
-
<TypePreview path={decl.stainlessPath} />
|
|
314
|
-
</>
|
|
315
|
-
);
|
|
316
|
-
|
|
317
|
-
case 'RubyDeclReference':
|
|
318
|
-
return <Lang.Type type={decl.type} />;
|
|
319
|
-
}
|
|
320
|
-
}
|