@stainless-api/docs-ui 0.1.0-beta.73 → 0.1.0-beta.75

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 (124) hide show
  1. package/dist/{chunk-BN_g-Awi.js → chunk-BYypO7fO.js} +3 -3
  2. package/dist/components/MaskedInput.d.ts +3 -3
  3. package/dist/components/MaskedInput.js +1 -1
  4. package/dist/components/breadcrumbs.d.ts +24 -1
  5. package/dist/components/breadcrumbs.js +62 -7
  6. package/dist/components/icons.d.ts +18 -13
  7. package/dist/components/icons.js +940 -2
  8. package/dist/components/index.d.ts +16 -14
  9. package/dist/components/index.js +72 -18
  10. package/dist/components/method.d.ts +58 -1
  11. package/dist/components/method.js +95 -8
  12. package/dist/components/overview.d.ts +38 -1
  13. package/dist/components/overview.js +137 -9
  14. package/dist/components/primitives.d.ts +104 -1
  15. package/dist/components/primitives.js +250 -6
  16. package/dist/components/properties.d.ts +53 -1
  17. package/dist/components/properties.js +138 -7
  18. package/dist/components/sdk-sidebar.d.ts +14 -1
  19. package/dist/components/sdk-sidebar.js +50 -8
  20. package/dist/components/sdk.d.ts +121 -1
  21. package/dist/components/sdk.js +405 -8
  22. package/dist/components/snippets.d.ts +70 -13
  23. package/dist/components/snippets.js +182 -7
  24. package/dist/components/stl-sidebar.d.ts +57 -1
  25. package/dist/components/stl-sidebar.js +105 -3
  26. package/dist/contexts/component-generics.d.ts +29 -1
  27. package/dist/contexts/component-generics.js +31 -1
  28. package/dist/contexts/component-types.d.ts +4 -15
  29. package/dist/contexts/component.d.ts +7 -17
  30. package/dist/contexts/component.js +22 -28
  31. package/dist/contexts/docs.d.ts +61 -1
  32. package/dist/contexts/docs.js +89 -1
  33. package/dist/contexts/index.d.ts +13 -14
  34. package/dist/contexts/index.js +44 -6
  35. package/dist/contexts/markdown.d.ts +21 -1
  36. package/dist/contexts/markdown.js +47 -2
  37. package/dist/contexts/navigation.d.ts +28 -1
  38. package/dist/contexts/navigation.js +22 -1
  39. package/dist/contexts/use-components.d.ts +1 -13
  40. package/dist/contexts/use-components.js +6 -2
  41. package/dist/{index-HDt5wRiR.d.ts → index-Cl6Gny0o.d.ts} +37 -2
  42. package/dist/index.d.ts +4 -14
  43. package/dist/index.js +7 -30
  44. package/dist/languages/cli.d.ts +38 -14
  45. package/dist/languages/cli.js +166 -20
  46. package/dist/languages/csharp.d.ts +42 -14
  47. package/dist/languages/csharp.js +283 -8
  48. package/dist/languages/go.d.ts +40 -14
  49. package/dist/languages/go.js +303 -8
  50. package/dist/languages/http.d.ts +46 -14
  51. package/dist/languages/http.js +390 -19
  52. package/dist/languages/index.d.ts +51 -14
  53. package/dist/languages/index.js +32 -28
  54. package/dist/languages/java.d.ts +43 -14
  55. package/dist/languages/java.js +403 -8
  56. package/dist/languages/php.d.ts +40 -0
  57. package/dist/languages/php.js +313 -0
  58. package/dist/languages/python.d.ts +40 -14
  59. package/dist/languages/python.js +269 -8
  60. package/dist/languages/ruby.d.ts +40 -14
  61. package/dist/languages/ruby.js +387 -8
  62. package/dist/languages/terraform.d.ts +48 -14
  63. package/dist/languages/terraform.js +243 -8
  64. package/dist/languages/typescript.d.ts +40 -14
  65. package/dist/languages/typescript.js +449 -8
  66. package/dist/markdown/index.d.ts +1 -2
  67. package/dist/markdown/index.js +1 -28
  68. package/dist/markdown/printer.d.ts +2 -2
  69. package/dist/markdown/printer.js +6 -30
  70. package/dist/markdown/utils.d.ts +3 -3
  71. package/dist/routing.d.ts +61 -2
  72. package/dist/routing.js +205 -2
  73. package/dist/spec.d.ts +2 -2
  74. package/dist/spec.js +2 -2
  75. package/dist/style.js +176 -1
  76. package/dist/use-strict-context-L0c8JKg4.js +16 -0
  77. package/dist/utils.d.ts +1 -1
  78. package/dist/utils.js +53 -2
  79. package/package.json +3 -3
  80. package/dist/breadcrumbs-Dei_5sHd.d.ts +0 -25
  81. package/dist/breadcrumbs-oUp-6oJK.js +0 -63
  82. package/dist/cli-BX9ofVCR.js +0 -166
  83. package/dist/component-Dl5ZEHxB.js +0 -23
  84. package/dist/component-generics-C9ALAcZI.d.ts +0 -30
  85. package/dist/component-generics-POFirVVb.js +0 -45
  86. package/dist/components-DQPlXEwE.js +0 -72
  87. package/dist/contexts-_NNW5yqC.js +0 -44
  88. package/dist/csharp-sn5CJu9t.js +0 -283
  89. package/dist/docs-YgoQ3bzY.js +0 -81
  90. package/dist/docs-x-kfjRMc.d.ts +0 -66
  91. package/dist/go-BoaAVmP0.js +0 -303
  92. package/dist/http-Ccj1dOvE.js +0 -389
  93. package/dist/icons-BYKn5X8E.js +0 -885
  94. package/dist/index-OCM-LZIo.d.ts +0 -428
  95. package/dist/java-BiLRuLuD.js +0 -403
  96. package/dist/languages-COjc0Nwx.js +0 -30
  97. package/dist/markdown-BszOPZhh.d.ts +0 -22
  98. package/dist/markdown-Cq3XEhrR.js +0 -49
  99. package/dist/method-DjzVBzZe.js +0 -96
  100. package/dist/method-KkWyhvKa.d.ts +0 -59
  101. package/dist/navigation-BZjwfN2P.d.ts +0 -29
  102. package/dist/navigation-aoYZ_tl4.js +0 -24
  103. package/dist/overview-BNmMeDUE.d.ts +0 -39
  104. package/dist/overview-Clq5psZe.js +0 -138
  105. package/dist/primitives-B8OnSXRP.d.ts +0 -105
  106. package/dist/primitives-BBUs_flm.js +0 -250
  107. package/dist/properties-BhlRtWo4.d.ts +0 -54
  108. package/dist/properties-DQU0NBzb.js +0 -138
  109. package/dist/python-nqOBH7GS.js +0 -269
  110. package/dist/routing-GvhEMw6E.js +0 -205
  111. package/dist/routing-qJMPICGo.d.ts +0 -61
  112. package/dist/ruby-BBc8HdIt.js +0 -387
  113. package/dist/sdk-C8C6IRQp.d.ts +0 -122
  114. package/dist/sdk-DzCHhEoX.js +0 -405
  115. package/dist/sdk-sidebar-CkjSLggl.js +0 -50
  116. package/dist/sdk-sidebar-lgNmf-ns.d.ts +0 -15
  117. package/dist/snippets-CLpNVNlA.js +0 -181
  118. package/dist/stl-sidebar-8jF9cdnn.d.ts +0 -58
  119. package/dist/stl-sidebar-DC5UOJiT.js +0 -106
  120. package/dist/style-DJIYkFhO.js +0 -178
  121. package/dist/terraform-DVx2ea2h.js +0 -243
  122. package/dist/typescript-Cmk-jBBw.js +0 -449
  123. package/dist/use-components-BUz3GbO4.js +0 -7
  124. package/dist/utils-D6zJxUZ9.js +0 -54
@@ -0,0 +1,313 @@
1
+ import { t as __exportAll } from "../chunk-BYypO7fO.js";
2
+ import "../use-strict-context-L0c8JKg4.js";
3
+ import { useLanguageComponents } from "../contexts/index.js";
4
+ import { useComponents } from "../contexts/use-components.js";
5
+ import style_default from "../style.js";
6
+ import * as React$1 from "react";
7
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
+
9
+ //#region src/languages/php.tsx
10
+ var php_exports = /* @__PURE__ */ __exportAll({
11
+ Declaration: () => Declaration,
12
+ MethodSignature: () => MethodSignature,
13
+ Property: () => Property,
14
+ Type: () => Type,
15
+ TypeName: () => TypeName
16
+ });
17
+ const ComplexTypes = {
18
+ PHPTypeMapArray: "array",
19
+ PhpTypeListArray: "list",
20
+ PhpTypeUnion: "union"
21
+ };
22
+ const constStyle = {
23
+ string: style_default.LiteralString,
24
+ number: style_default.LiteralNumeric,
25
+ boolean: style_default.LiteralBoolean
26
+ };
27
+ function TypeName({ type }) {
28
+ const Lang = useLanguageComponents();
29
+ return ComplexTypes[type.kind] ?? /* @__PURE__ */ jsx(Lang.Type, { type });
30
+ }
31
+ function Type({ type }) {
32
+ const Docs = useComponents();
33
+ const Lang = useLanguageComponents();
34
+ const { Join } = useComponents();
35
+ switch (type.kind) {
36
+ case "PhpTypeFloat":
37
+ case "PhpTypeInt":
38
+ case "PhpTypeBool":
39
+ case "PhpTypeNull":
40
+ case "PhpTypeMixed": return /* @__PURE__ */ jsx("span", {
41
+ className: style_default.Type,
42
+ children: /* @__PURE__ */ jsx("span", {
43
+ className: style_default.TypeKeyword,
44
+ children: type.kind.slice(7).toLowerCase()
45
+ })
46
+ });
47
+ case "PhpTypeString": return /* @__PURE__ */ jsx("span", {
48
+ className: style_default.Type,
49
+ children: /* @__PURE__ */ jsx("span", {
50
+ className: style_default.TypeString,
51
+ children: "string"
52
+ })
53
+ });
54
+ case "PhpTypeComplexBuiltin": return /* @__PURE__ */ jsx("span", {
55
+ className: style_default.Type,
56
+ children: /* @__PURE__ */ jsx("span", {
57
+ className: style_default.TypeKeyword,
58
+ children: type.typeName
59
+ })
60
+ });
61
+ case "PhpTypeLiteral": return /* @__PURE__ */ jsx("span", {
62
+ className: style_default.Type,
63
+ children: /* @__PURE__ */ jsx("span", {
64
+ className: constStyle[typeof type.literal],
65
+ children: JSON.stringify(type.literal)
66
+ })
67
+ });
68
+ case "PhpTypeDatetime": return /* @__PURE__ */ jsx("span", {
69
+ className: style_default.Type,
70
+ children: /* @__PURE__ */ jsx("span", {
71
+ className: style_default.TypeReference,
72
+ children: "\\Datetime"
73
+ })
74
+ });
75
+ case "PhpTypeReference": {
76
+ const params = type.typeParameters?.map((param, key) => /* @__PURE__ */ jsx(Lang.Type, { type: param }, key));
77
+ return /* @__PURE__ */ jsxs("span", {
78
+ className: style_default.Type,
79
+ children: [/* @__PURE__ */ jsx(Docs.SDKReference, {
80
+ stainlessPath: type.$ref,
81
+ children: type.typeName
82
+ }), params && params.length > 0 && /* @__PURE__ */ jsxs(Fragment$1, { children: [
83
+ /* @__PURE__ */ jsx("span", {
84
+ className: style_default.TypeBracket,
85
+ children: "<"
86
+ }),
87
+ /* @__PURE__ */ jsx(Join, {
88
+ items: params,
89
+ limit: 3,
90
+ children: /* @__PURE__ */ jsx("span", {
91
+ className: style_default.TextOperator,
92
+ children: ", "
93
+ })
94
+ }),
95
+ /* @__PURE__ */ jsx("span", {
96
+ className: style_default.TypeBracket,
97
+ children: ">"
98
+ })
99
+ ] })]
100
+ });
101
+ }
102
+ case "PhpTypeMapArray": return /* @__PURE__ */ jsxs("span", {
103
+ className: style_default.Type,
104
+ children: [
105
+ /* @__PURE__ */ jsx("span", {
106
+ className: style_default.TypeArray,
107
+ children: "array<string,"
108
+ }),
109
+ /* @__PURE__ */ jsx(Lang.Type, { type: type.elementType }),
110
+ /* @__PURE__ */ jsx("span", {
111
+ className: style_default.TypeArray,
112
+ children: ">"
113
+ })
114
+ ]
115
+ });
116
+ case "PhpTypeListArray": return /* @__PURE__ */ jsxs("span", {
117
+ className: style_default.Type,
118
+ children: [
119
+ /* @__PURE__ */ jsx("span", {
120
+ className: style_default.TypeArray,
121
+ children: "list<"
122
+ }),
123
+ /* @__PURE__ */ jsx(Lang.Type, { type: type.elementType }),
124
+ /* @__PURE__ */ jsx("span", {
125
+ className: style_default.TypeArray,
126
+ children: ">"
127
+ })
128
+ ]
129
+ });
130
+ case "PhpTypeUnion": {
131
+ const items = type.types.map((t, key) => /* @__PURE__ */ jsx(Lang.Type, { type: t }, key));
132
+ return /* @__PURE__ */ jsx("span", {
133
+ className: style_default.Type,
134
+ children: /* @__PURE__ */ jsx("span", {
135
+ className: style_default.TypePreview,
136
+ "data-stldocs-type-preview": "union",
137
+ children: /* @__PURE__ */ jsx("span", {
138
+ className: style_default.TypePreviewContent,
139
+ children: /* @__PURE__ */ jsx(Join, {
140
+ items,
141
+ limit: 3,
142
+ children: /* @__PURE__ */ jsx("span", {
143
+ className: style_default.TextOperator,
144
+ children: " | "
145
+ })
146
+ })
147
+ })
148
+ })
149
+ });
150
+ }
151
+ }
152
+ }
153
+ function MethodSignature({ decl }) {
154
+ const Lang = useLanguageComponents();
155
+ const { Join } = useComponents();
156
+ const params = decl.parameters.map((param, i) => /* @__PURE__ */ jsxs(React$1.Fragment, { children: [
157
+ param.optional && /* @__PURE__ */ jsx("span", {
158
+ className: style_default.TextPunctuation,
159
+ children: "?"
160
+ }),
161
+ /* @__PURE__ */ jsx(Lang.Type, { type: param.typeAnnotation }),
162
+ " ",
163
+ /* @__PURE__ */ jsx("span", {
164
+ className: style_default.TextIdentifier,
165
+ children: param.ident
166
+ }),
167
+ param.hasDefault && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
168
+ className: style_default.TextPunctuation,
169
+ children: " = "
170
+ }), /* @__PURE__ */ jsx("span", {
171
+ className: style_default.TextKeyword,
172
+ children: "default"
173
+ })] })
174
+ ] }, i));
175
+ return /* @__PURE__ */ jsx("div", {
176
+ className: style_default.MethodSignature,
177
+ children: /* @__PURE__ */ jsxs("span", {
178
+ className: style_default.SignatureTitle,
179
+ children: [
180
+ decl.qualified && /* @__PURE__ */ jsx("span", {
181
+ className: style_default.SignatureQualified,
182
+ children: /* @__PURE__ */ jsxs("span", {
183
+ className: style_default.TextIdentifier,
184
+ children: ["$client->", decl.qualified?.slice(0, -decl.ident.length)]
185
+ })
186
+ }),
187
+ /* @__PURE__ */ jsx("span", {
188
+ className: style_default.SignatureName,
189
+ children: /* @__PURE__ */ jsx("span", {
190
+ className: style_default.TextIdentifier,
191
+ children: decl.ident
192
+ })
193
+ }),
194
+ /* @__PURE__ */ jsxs("span", {
195
+ className: style_default.MethodSignature,
196
+ children: [
197
+ /* @__PURE__ */ jsx("span", {
198
+ className: style_default.SignatureParen,
199
+ children: "("
200
+ }),
201
+ /* @__PURE__ */ jsx("span", {
202
+ className: style_default.SignatureParams,
203
+ children: /* @__PURE__ */ jsx(Join, {
204
+ items: params,
205
+ children: /* @__PURE__ */ jsx("span", {
206
+ className: style_default.TextOperator,
207
+ children: ", "
208
+ })
209
+ })
210
+ }),
211
+ /* @__PURE__ */ jsx("span", {
212
+ className: style_default.SignatureParen,
213
+ children: ")"
214
+ }),
215
+ /* @__PURE__ */ jsx("span", {
216
+ className: style_default.TextPunctuation,
217
+ children: ": "
218
+ }),
219
+ decl.returnType ? /* @__PURE__ */ jsx(Lang.Type, { type: decl.returnType }) : /* @__PURE__ */ jsx("span", {
220
+ className: style_default.Type,
221
+ children: /* @__PURE__ */ jsx("span", {
222
+ className: style_default.TypeKeyword,
223
+ children: "void"
224
+ })
225
+ })
226
+ ]
227
+ })
228
+ ]
229
+ })
230
+ });
231
+ }
232
+ function Property({ decl, children }) {
233
+ const Lang = useLanguageComponents();
234
+ if (!decl) return;
235
+ switch (decl.kind) {
236
+ case "PhpDeclReference": return children({ type: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type }) });
237
+ case "PhpDeclClassProperty":
238
+ case "PhpDeclParam": return children({
239
+ name: decl.ident,
240
+ typeName: /* @__PURE__ */ jsx(Lang.TypeName, { type: decl.type }),
241
+ type: decl.type.kind in ComplexTypes && /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
242
+ });
243
+ }
244
+ }
245
+ function Declaration({ decl }) {
246
+ const Lang = useLanguageComponents();
247
+ if (!decl) return;
248
+ switch (decl.kind) {
249
+ case "PhpDeclClass":
250
+ case "PhpDeclAssocArray":
251
+ case "PhpDeclEnum": return /* @__PURE__ */ jsx(Fragment$1, { children: "Not yet implemented." });
252
+ case "PhpDeclReference": return /* @__PURE__ */ jsxs(Fragment$1, { children: [decl.scope && /* @__PURE__ */ jsxs("span", {
253
+ className: style_default.TextKeyword,
254
+ children: [decl.scope, " "]
255
+ }), /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })] });
256
+ case "PhpDeclParam": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
257
+ /* @__PURE__ */ jsx("span", {
258
+ className: style_default.TextIdentifier,
259
+ children: decl.ident
260
+ }),
261
+ decl.isPositional ? /* @__PURE__ */ jsx("span", {
262
+ className: style_default.TextOperator,
263
+ children: ": "
264
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
265
+ className: style_default.TextOperator,
266
+ children: decl.optional ? "?:" : ": "
267
+ }), decl.optional && /* @__PURE__ */ jsx("span", {
268
+ className: style_default.TextOperator,
269
+ children: "optional "
270
+ })] }),
271
+ /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
272
+ ] });
273
+ case "PhpDeclAssocArrayProperty": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
274
+ /* @__PURE__ */ jsxs("span", {
275
+ className: style_default.LiteralString,
276
+ children: [
277
+ "'",
278
+ decl.ident,
279
+ "'"
280
+ ]
281
+ }),
282
+ decl.optional && /* @__PURE__ */ jsx("span", {
283
+ className: style_default.TextOperator,
284
+ children: "?"
285
+ }),
286
+ /* @__PURE__ */ jsx("span", {
287
+ className: style_default.TextOperator,
288
+ children: ": "
289
+ }),
290
+ decl.optional && /* @__PURE__ */ jsx("span", {
291
+ className: style_default.TextKeyword,
292
+ children: "optional "
293
+ }),
294
+ /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
295
+ ] });
296
+ case "PhpDeclClassProperty": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
297
+ decl.nullable && /* @__PURE__ */ jsx("span", {
298
+ className: style_default.TextOperator,
299
+ children: "?"
300
+ }),
301
+ /* @__PURE__ */ jsx(Lang.Type, { type: decl.type }),
302
+ " ",
303
+ /* @__PURE__ */ jsx("span", {
304
+ className: style_default.TextIdentifier,
305
+ children: decl.ident
306
+ })
307
+ ] });
308
+ case "PhpDeclMethod": return /* @__PURE__ */ jsx(Lang.MethodSignature, { decl });
309
+ }
310
+ }
311
+
312
+ //#endregion
313
+ export { Declaration, MethodSignature, Property, Type, TypeName, php_exports as t };
@@ -1,14 +1,40 @@
1
- import "../primitives-B8OnSXRP.js";
2
- import "../breadcrumbs-Dei_5sHd.js";
3
- import "../method-KkWyhvKa.js";
4
- import "../properties-BhlRtWo4.js";
5
- import "../sdk-C8C6IRQp.js";
6
- import { Ct as Type, St as PropertyProps, _t as Declaration, bt as MethodSignatureProps, vt as DeclarationProps, wt as TypeName, xt as Property, yt as MethodSignature } from "../index-OCM-LZIo.js";
7
- import "../navigation-BZjwfN2P.js";
8
- import "../markdown-BszOPZhh.js";
9
- import "../component-generics-C9ALAcZI.js";
10
- import "../docs-x-kfjRMc.js";
11
- import "../overview-BNmMeDUE.js";
12
- import "../sdk-sidebar-lgNmf-ns.js";
13
- import "../stl-sidebar-8jF9cdnn.js";
14
- export { Declaration, DeclarationProps, MethodSignature, MethodSignatureProps, Property, PropertyProps, Type, TypeName };
1
+ import { m as PythonAST } from "../index-Cl6Gny0o.js";
2
+ import { PropertyFn } from "./index.js";
3
+ import * as React$1 from "react";
4
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
5
+
6
+ //#region src/languages/python.d.ts
7
+ declare namespace python_d_exports {
8
+ export { Declaration, DeclarationProps, MethodSignature, MethodSignatureProps, Property, PropertyProps, Type, TypeName };
9
+ }
10
+ type TypeProps = {
11
+ type: PythonAST.PythonType;
12
+ };
13
+ declare function TypeName({
14
+ type
15
+ }: TypeProps): string | react_jsx_runtime0.JSX.Element;
16
+ declare function Type({
17
+ type
18
+ }: TypeProps): react_jsx_runtime0.JSX.Element;
19
+ type MethodSignatureProps = {
20
+ decl: PythonAST.PythonDeclFunction;
21
+ };
22
+ declare function MethodSignature({
23
+ decl
24
+ }: MethodSignatureProps): react_jsx_runtime0.JSX.Element;
25
+ type PropertyProps = {
26
+ decl: PythonAST.PythonDeclaration;
27
+ children: PropertyFn;
28
+ };
29
+ declare function Property({
30
+ decl,
31
+ children
32
+ }: PropertyProps): React$1.ReactNode;
33
+ type DeclarationProps = {
34
+ decl: PythonAST.PythonDeclaration;
35
+ };
36
+ declare function Declaration({
37
+ decl
38
+ }: DeclarationProps): react_jsx_runtime0.JSX.Element | undefined;
39
+ //#endregion
40
+ export { Declaration, DeclarationProps, MethodSignature, MethodSignatureProps, Property, PropertyProps, Type, TypeName, python_d_exports as t };
@@ -1,9 +1,270 @@
1
- import "../docs-YgoQ3bzY.js";
2
- import "../component-generics-POFirVVb.js";
3
- import "../navigation-aoYZ_tl4.js";
4
- import "../markdown-Cq3XEhrR.js";
5
- import "../contexts-_NNW5yqC.js";
6
- import "../use-components-BUz3GbO4.js";
7
- import { a as TypeName, i as Type, n as MethodSignature, r as Property, t as Declaration } from "../python-nqOBH7GS.js";
1
+ import { t as __exportAll } from "../chunk-BYypO7fO.js";
2
+ import "../use-strict-context-L0c8JKg4.js";
3
+ import { useLanguageComponents } from "../contexts/index.js";
4
+ import { useComponents } from "../contexts/use-components.js";
5
+ import style_default from "../style.js";
6
+ import * as React$1 from "react";
7
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
8
 
9
- export { Declaration, MethodSignature, Property, Type, TypeName };
9
+ //#region src/languages/python.tsx
10
+ var python_exports = /* @__PURE__ */ __exportAll({
11
+ Declaration: () => Declaration,
12
+ MethodSignature: () => MethodSignature,
13
+ Property: () => Property,
14
+ Type: () => Type,
15
+ TypeName: () => TypeName
16
+ });
17
+ const constStyle = {
18
+ string: style_default.LiteralString,
19
+ number: style_default.LiteralNumeric,
20
+ boolean: style_default.LiteralBoolean
21
+ };
22
+ function showFullType(type) {
23
+ if (type.kind !== "PythonTypeReference") return false;
24
+ return type.typeName === "Optional" ? showFullType(type.typeParameters[0]) : type.typeParameters.length > 0;
25
+ }
26
+ function TypeName({ type }) {
27
+ const Lang = useLanguageComponents();
28
+ if (type.kind === "PythonTypeReference") switch (type.typeName) {
29
+ case "Optional": return /* @__PURE__ */ jsx(Lang.TypeName, { type: type.typeParameters[0] });
30
+ case "List":
31
+ case "Iterable":
32
+ case "Literal":
33
+ case "Union": return type.typeName.toLowerCase();
34
+ }
35
+ return /* @__PURE__ */ jsx(Lang.Type, { type });
36
+ }
37
+ function Type({ type }) {
38
+ const Lang = useLanguageComponents();
39
+ const { Join, SDKReference } = useComponents();
40
+ switch (type.kind) {
41
+ case "PythonTypeAny":
42
+ case "PythonTypeUnknown":
43
+ case "PythonTypeInt":
44
+ case "PythonTypeFloat":
45
+ case "PythonTypeBool": return /* @__PURE__ */ jsx("span", {
46
+ className: style_default.Type,
47
+ children: /* @__PURE__ */ jsx("span", {
48
+ className: style_default.TypeKeyword,
49
+ children: type.kind.slice(10).toLowerCase()
50
+ })
51
+ });
52
+ case "PythonTypeString": return /* @__PURE__ */ jsx("span", {
53
+ className: style_default.Type,
54
+ children: /* @__PURE__ */ jsx("span", {
55
+ className: style_default.TypeString,
56
+ children: "str"
57
+ })
58
+ });
59
+ case "PythonTypeLiteral": return /* @__PURE__ */ jsx("span", {
60
+ className: style_default.Type,
61
+ children: /* @__PURE__ */ jsx("span", {
62
+ className: constStyle[typeof type.literal.value],
63
+ children: JSON.stringify(type.literal.value)
64
+ })
65
+ });
66
+ case "PythonTypeArray": return /* @__PURE__ */ jsxs("span", {
67
+ className: style_default.Type,
68
+ children: [
69
+ /* @__PURE__ */ jsx("span", {
70
+ className: style_default.TypeArray,
71
+ children: "Array<"
72
+ }),
73
+ /* @__PURE__ */ jsx(Lang.Type, { type: type.elementType }),
74
+ /* @__PURE__ */ jsx("span", {
75
+ className: style_default.TypeArray,
76
+ children: ">"
77
+ })
78
+ ]
79
+ });
80
+ case "PythonTypeClass": return /* @__PURE__ */ jsx("span", {
81
+ className: style_default.Type,
82
+ children: /* @__PURE__ */ jsx("span", {
83
+ className: style_default.TypeKeyword,
84
+ children: "class"
85
+ })
86
+ });
87
+ case "PythonTypeMap": return /* @__PURE__ */ jsx("span", {
88
+ className: style_default.Type,
89
+ children: /* @__PURE__ */ jsx("span", {
90
+ className: style_default.TypeKeyword,
91
+ children: "Dict"
92
+ })
93
+ });
94
+ case "PythonTypeReference": {
95
+ const params = type.typeParameters?.map((param, key) => /* @__PURE__ */ jsx(Lang.Type, { type: param }, key));
96
+ return /* @__PURE__ */ jsxs("span", {
97
+ className: style_default.Type,
98
+ children: [/* @__PURE__ */ jsx("span", {
99
+ className: type.typeName === "Optional" ? style_default.TypeArray : "",
100
+ children: /* @__PURE__ */ jsx(SDKReference, {
101
+ stainlessPath: type.$ref,
102
+ children: type.typeName
103
+ })
104
+ }), params && params.length > 0 && /* @__PURE__ */ jsxs(Fragment$1, { children: [
105
+ /* @__PURE__ */ jsx("span", {
106
+ className: style_default.TypeBracket,
107
+ children: "["
108
+ }),
109
+ /* @__PURE__ */ jsx(Join, {
110
+ items: params,
111
+ limit: 3,
112
+ children: /* @__PURE__ */ jsx("span", {
113
+ className: style_default.TextOperator,
114
+ children: ", "
115
+ })
116
+ }),
117
+ /* @__PURE__ */ jsx("span", {
118
+ className: style_default.TypeBracket,
119
+ children: "]"
120
+ })
121
+ ] })]
122
+ });
123
+ }
124
+ }
125
+ }
126
+ function MethodSignature({ decl }) {
127
+ const Lang = useLanguageComponents();
128
+ const { Join, Tooltip } = useComponents();
129
+ const params = decl.parameters.map((param, i) => /* @__PURE__ */ jsx(React$1.Fragment, { children: /* @__PURE__ */ jsx(Tooltip, {
130
+ content: /* @__PURE__ */ jsx(Lang.Type, { type: param.type }),
131
+ children: /* @__PURE__ */ jsx("span", {
132
+ className: style_default.TextIdentifier,
133
+ children: param.ident
134
+ })
135
+ }) }, i));
136
+ return /* @__PURE__ */ jsx("div", {
137
+ className: style_default.MethodSignature,
138
+ children: /* @__PURE__ */ jsxs("span", {
139
+ className: style_default.SignatureTitle,
140
+ children: [
141
+ decl.async && /* @__PURE__ */ jsx("span", {
142
+ className: style_default.TextKeyword,
143
+ children: "async "
144
+ }),
145
+ decl.qualified && /* @__PURE__ */ jsx("span", {
146
+ className: style_default.SignatureQualified,
147
+ children: /* @__PURE__ */ jsx("span", {
148
+ className: style_default.TextIdentifier,
149
+ children: decl.qualified?.slice(0, -decl.ident.length)
150
+ })
151
+ }),
152
+ /* @__PURE__ */ jsx("span", {
153
+ className: style_default.SignatureName,
154
+ children: /* @__PURE__ */ jsx("span", {
155
+ className: style_default.TextIdentifier,
156
+ children: decl.ident
157
+ })
158
+ }),
159
+ /* @__PURE__ */ jsxs("span", {
160
+ className: style_default.MethodSignature,
161
+ children: [
162
+ /* @__PURE__ */ jsx("span", {
163
+ className: style_default.SignatureParen,
164
+ children: "("
165
+ }),
166
+ /* @__PURE__ */ jsx("span", {
167
+ className: style_default.SignatureParams,
168
+ children: /* @__PURE__ */ jsx(Join, {
169
+ items: params,
170
+ children: /* @__PURE__ */ jsx("span", {
171
+ className: style_default.TextOperator,
172
+ children: ", "
173
+ })
174
+ })
175
+ }),
176
+ /* @__PURE__ */ jsxs("span", {
177
+ className: style_default.SignatureParen,
178
+ children: [")", " "]
179
+ }),
180
+ decl.returns && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
181
+ className: style_default.TextOperator,
182
+ children: " -> "
183
+ }), /* @__PURE__ */ jsx(Lang.Type, { type: decl.returns })] })
184
+ ]
185
+ })
186
+ ]
187
+ })
188
+ });
189
+ }
190
+ function Property({ decl, children }) {
191
+ const Lang = useLanguageComponents();
192
+ if (!decl) return;
193
+ switch (decl.kind) {
194
+ case "PythonDeclProperty": return children({
195
+ name: decl.ident,
196
+ typeName: /* @__PURE__ */ jsx(Lang.TypeName, { type: decl.type }),
197
+ type: showFullType(decl.type) && /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
198
+ });
199
+ case "PythonDeclClass": return children({
200
+ name: decl.ident,
201
+ typeName: "class"
202
+ });
203
+ case "PythonDeclType": return children({
204
+ name: decl.ident,
205
+ typeName: "type",
206
+ type: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
207
+ });
208
+ case "PythonDeclReference": return children({ type: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type }) });
209
+ }
210
+ }
211
+ function Declaration({ decl }) {
212
+ const Lang = useLanguageComponents();
213
+ if (!decl) return;
214
+ switch (decl.kind) {
215
+ case "PythonDeclProperty": {
216
+ const nullable = decl.type.kind === "PythonTypeReference" && decl.type.typeName === "Optional" && (decl.type.typeParameters ?? []).length > 0;
217
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
218
+ /* @__PURE__ */ jsx("span", {
219
+ className: style_default.TypePropertyName,
220
+ children: /* @__PURE__ */ jsx("span", {
221
+ className: style_default.TextIdentifier,
222
+ children: decl.ident
223
+ })
224
+ }),
225
+ /* @__PURE__ */ jsx("span", {
226
+ className: style_default.TextPunctuation,
227
+ children: ": "
228
+ }),
229
+ decl.optional && !nullable ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
230
+ /* @__PURE__ */ jsx("span", {
231
+ className: style_default.TypePlain,
232
+ children: "Optional"
233
+ }),
234
+ /* @__PURE__ */ jsx("span", {
235
+ className: style_default.TypeBracket,
236
+ children: "["
237
+ }),
238
+ /* @__PURE__ */ jsx(Lang.Type, { type: decl.type }),
239
+ /* @__PURE__ */ jsx("span", {
240
+ className: style_default.TypeBrace,
241
+ children: "]"
242
+ })
243
+ ] }) : /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
244
+ ] });
245
+ }
246
+ case "PythonDeclClass": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
247
+ /* @__PURE__ */ jsx("span", {
248
+ className: style_default.TextKeyword,
249
+ children: "class "
250
+ }),
251
+ /* @__PURE__ */ jsx("span", {
252
+ className: style_default.TextIdentifier,
253
+ children: decl.ident
254
+ }),
255
+ /* @__PURE__ */ jsx("span", {
256
+ className: style_default.TextPunctuation,
257
+ children: ": "
258
+ }),
259
+ /* @__PURE__ */ jsx("span", {
260
+ className: `${style_default.TypePreviewContent} ${style_default.TextPunctuation}`,
261
+ children: "…"
262
+ })
263
+ ] });
264
+ case "PythonDeclType": return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type }) });
265
+ case "PythonDeclReference": return /* @__PURE__ */ jsx(Lang.Type, { type: decl.type });
266
+ }
267
+ }
268
+
269
+ //#endregion
270
+ export { Declaration, MethodSignature, Property, Type, TypeName, python_exports as t };