@stainless-api/docs-ui 0.1.0-beta.8 → 0.1.0-beta.80
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/chunk-BYypO7fO.js +18 -0
- package/dist/components/MaskedInput.d.ts +14 -0
- package/dist/components/MaskedInput.js +76 -0
- package/dist/components/breadcrumbs.d.ts +25 -0
- package/dist/components/breadcrumbs.js +64 -0
- package/dist/components/icons.d.ts +65 -0
- package/dist/components/icons.js +941 -0
- package/dist/components/index.d.ts +16 -0
- package/dist/components/index.js +75 -0
- package/dist/components/method.d.ts +59 -0
- package/dist/components/method.js +97 -0
- package/dist/components/overview.d.ts +39 -0
- package/dist/components/overview.js +139 -0
- package/dist/components/primitives.d.ts +107 -0
- package/dist/components/primitives.js +253 -0
- package/dist/components/properties.d.ts +54 -0
- package/dist/components/properties.js +140 -0
- package/dist/components/sdk-sidebar.d.ts +15 -0
- package/dist/components/sdk-sidebar.js +52 -0
- package/dist/components/sdk.d.ts +128 -0
- package/dist/components/sdk.js +490 -0
- package/dist/components/snippets.d.ts +71 -0
- package/dist/components/snippets.js +184 -0
- package/dist/components/stl-sidebar.d.ts +58 -0
- package/dist/components/stl-sidebar.js +114 -0
- package/dist/contexts/component-generics.d.ts +30 -0
- package/dist/contexts/component-generics.js +33 -0
- package/dist/contexts/component-types.d.ts +8 -0
- package/dist/contexts/component-types.js +0 -0
- package/dist/contexts/component.d.ts +21 -0
- package/dist/contexts/component.js +24 -0
- package/dist/contexts/docs.d.ts +62 -0
- package/dist/contexts/docs.js +91 -0
- package/dist/contexts/index.d.ts +13 -0
- package/dist/contexts/index.js +45 -0
- package/dist/contexts/markdown.d.ts +22 -0
- package/dist/contexts/markdown.js +49 -0
- package/dist/contexts/navigation.d.ts +29 -0
- package/dist/contexts/navigation.js +24 -0
- package/dist/contexts/use-components.d.ts +6 -0
- package/dist/contexts/use-components.js +8 -0
- package/dist/index-pvh-w1xa.d.ts +1776 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +9 -7542
- package/dist/languages/cli.d.ts +38 -0
- package/dist/languages/cli.js +167 -0
- package/dist/languages/csharp.d.ts +42 -0
- package/dist/languages/csharp.js +284 -0
- package/dist/languages/go.d.ts +40 -0
- package/dist/languages/go.js +304 -0
- package/dist/languages/http.d.ts +46 -0
- package/dist/languages/http.js +391 -0
- package/dist/languages/index.d.ts +51 -0
- package/dist/languages/index.js +33 -0
- package/dist/languages/java.d.ts +43 -0
- package/dist/languages/java.js +404 -0
- package/dist/languages/php.d.ts +40 -0
- package/dist/languages/php.js +313 -0
- package/dist/languages/python.d.ts +40 -0
- package/dist/languages/python.js +270 -0
- package/dist/languages/ruby.d.ts +40 -0
- package/dist/languages/ruby.js +388 -0
- package/dist/languages/terraform.d.ts +48 -0
- package/dist/languages/terraform.js +244 -0
- package/dist/languages/typescript.d.ts +40 -0
- package/dist/languages/typescript.js +450 -0
- package/dist/markdown/index.d.ts +11 -0
- package/dist/markdown/index.js +80 -0
- package/dist/markdown/md.d.ts +15 -0
- package/dist/markdown/md.js +41 -0
- package/dist/markdown/printer.d.ts +13 -0
- package/dist/markdown/printer.js +76 -0
- package/dist/markdown/utils.d.ts +21 -0
- package/dist/markdown/utils.js +31 -0
- package/dist/routing.d.ts +61 -0
- package/dist/routing.js +176 -150
- package/dist/spec.d.ts +65 -0
- package/dist/spec.js +167 -0
- package/dist/style.d.ts +177 -0
- package/dist/style.js +178 -0
- package/dist/styles/main.css +788 -752
- package/dist/styles/main.js +0 -0
- package/dist/styles/primitives.css +326 -458
- 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 +192 -270
- package/dist/styles/search.js +0 -0
- package/dist/styles/sidebar.css +182 -69
- package/dist/styles/sidebar.js +0 -0
- package/dist/styles/variables.css +28 -89
- package/dist/styles/variables.js +0 -0
- package/dist/styles.css +3333 -0
- package/dist/styles.mjs +1 -0
- package/dist/use-strict-context-L0c8JKg4.js +16 -0
- package/dist/utils.d.ts +20 -0
- package/dist/utils.js +54 -0
- package/package.json +74 -22
- 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 -146
- package/src/components/overview.tsx +0 -160
- 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 -403
- package/src/components/sidebar.tsx +0 -99
- package/src/components/snippets.tsx +0 -180
- 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 -182
- package/src/search/state.ts +0 -64
- package/src/search/types.ts +0 -116
- package/src/style.ts +0 -196
- package/src/styles/main.css +0 -986
- package/src/styles/primitives.css +0 -580
- package/src/styles/resets.css +0 -39
- package/src/styles/search.css +0 -341
- package/src/styles/sidebar.css +0 -85
- package/src/styles/snippets.css +0 -130
- package/src/styles/variables.css +0 -86
- package/src/utils.ts +0 -41
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { b as TSAST } from "../index-pvh-w1xa.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/typescript.d.ts
|
|
7
|
+
declare namespace typescript_d_exports {
|
|
8
|
+
export { Declaration, DeclarationProps, MethodSignature, MethodSignatureProps, Property, PropertyProps, Type, TypeName };
|
|
9
|
+
}
|
|
10
|
+
type TypeProps = {
|
|
11
|
+
type: TSAST.TSType;
|
|
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: TSAST.TSDeclFunction;
|
|
21
|
+
};
|
|
22
|
+
declare function MethodSignature({
|
|
23
|
+
decl
|
|
24
|
+
}: MethodSignatureProps): react_jsx_runtime0.JSX.Element;
|
|
25
|
+
type PropertyProps = {
|
|
26
|
+
decl: TSAST.TSDeclaration;
|
|
27
|
+
children: PropertyFn;
|
|
28
|
+
};
|
|
29
|
+
declare function Property({
|
|
30
|
+
decl,
|
|
31
|
+
children
|
|
32
|
+
}: PropertyProps): React$1.ReactNode;
|
|
33
|
+
type DeclarationProps = {
|
|
34
|
+
decl: TSAST.TSDeclaration;
|
|
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, typescript_d_exports as t };
|
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
import { t as __exportAll } from "../chunk-BYypO7fO.js";
|
|
2
|
+
import { useDeclaration, useLanguage, useSpec } from "../contexts/docs.js";
|
|
3
|
+
import "../use-strict-context-L0c8JKg4.js";
|
|
4
|
+
import { useLanguageComponents } from "../contexts/index.js";
|
|
5
|
+
import { useComponents } from "../contexts/use-components.js";
|
|
6
|
+
import style_default from "../style.js";
|
|
7
|
+
import * as React$1 from "react";
|
|
8
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
|
|
10
|
+
//#region src/languages/typescript.tsx
|
|
11
|
+
var typescript_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
Declaration: () => Declaration,
|
|
13
|
+
MethodSignature: () => MethodSignature,
|
|
14
|
+
Property: () => Property,
|
|
15
|
+
Type: () => Type,
|
|
16
|
+
TypeName: () => TypeName
|
|
17
|
+
});
|
|
18
|
+
const ComplexTypes = {
|
|
19
|
+
TSTypeObject: "object",
|
|
20
|
+
TSTypeUnion: "union",
|
|
21
|
+
TSTypeInterface: "interface",
|
|
22
|
+
TSTypeIntersection: "intersection",
|
|
23
|
+
TSTypeArray: "array"
|
|
24
|
+
};
|
|
25
|
+
const constStyle = {
|
|
26
|
+
string: style_default.LiteralString,
|
|
27
|
+
number: style_default.LiteralNumeric,
|
|
28
|
+
boolean: style_default.LiteralBoolean
|
|
29
|
+
};
|
|
30
|
+
function Identifier({ name, optional }) {
|
|
31
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
32
|
+
className: style_default.TextIdentifier,
|
|
33
|
+
children: /^[_a-zA-Z][_a-zA-Z0-9]*$/.test(name) ? name : JSON.stringify(name)
|
|
34
|
+
}), optional && /* @__PURE__ */ jsx("span", {
|
|
35
|
+
className: style_default.TextPunctuation,
|
|
36
|
+
children: "?"
|
|
37
|
+
})] });
|
|
38
|
+
}
|
|
39
|
+
function TypeParams({ params }) {
|
|
40
|
+
const Lang = useLanguageComponents();
|
|
41
|
+
const { Join } = useComponents();
|
|
42
|
+
if (!params?.length) return null;
|
|
43
|
+
const typeParams = params?.map((param, key) => param.constraint ? /* @__PURE__ */ jsxs(React$1.Fragment, { children: [
|
|
44
|
+
/* @__PURE__ */ jsx("span", {
|
|
45
|
+
className: style_default.TypeReference,
|
|
46
|
+
children: param.name
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ jsx("span", {
|
|
49
|
+
className: style_default.TextKeyword,
|
|
50
|
+
children: "extends "
|
|
51
|
+
}),
|
|
52
|
+
/* @__PURE__ */ jsx(Lang.Type, { type: param.constraint })
|
|
53
|
+
] }, key) : /* @__PURE__ */ jsx(React$1.Fragment, { children: "param.name" }, key));
|
|
54
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
55
|
+
/* @__PURE__ */ jsx("span", {
|
|
56
|
+
className: style_default.TypeBracket,
|
|
57
|
+
children: "<"
|
|
58
|
+
}),
|
|
59
|
+
/* @__PURE__ */ jsx(Join, {
|
|
60
|
+
items: typeParams,
|
|
61
|
+
limit: 3,
|
|
62
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
63
|
+
className: style_default.TextOperator,
|
|
64
|
+
children: ", "
|
|
65
|
+
})
|
|
66
|
+
}),
|
|
67
|
+
/* @__PURE__ */ jsx("span", {
|
|
68
|
+
className: style_default.TypeBracket,
|
|
69
|
+
children: ">"
|
|
70
|
+
})
|
|
71
|
+
] });
|
|
72
|
+
}
|
|
73
|
+
function TypePreview({ path }) {
|
|
74
|
+
const spec = useSpec();
|
|
75
|
+
const language = useLanguage();
|
|
76
|
+
const decl = useDeclaration(path, false);
|
|
77
|
+
const { Join } = useComponents();
|
|
78
|
+
if (!(decl && "children" in decl && decl.children && decl.children.length > 0) || decl && "type" in decl && decl.type !== void 0 && "kind" in decl["type"] && decl["type"]["kind"] === "TSTypeUnion") return;
|
|
79
|
+
const items = decl.children.map((prop, key) => {
|
|
80
|
+
const p = spec?.decls?.[language]?.[prop];
|
|
81
|
+
return /* @__PURE__ */ jsx("span", {
|
|
82
|
+
className: style_default.TypePropertyName,
|
|
83
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
84
|
+
className: style_default.TextIdentifier,
|
|
85
|
+
children: p && "key" in p ? p["key"] : null
|
|
86
|
+
})
|
|
87
|
+
}, key);
|
|
88
|
+
});
|
|
89
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
90
|
+
className: style_default.TypePreview,
|
|
91
|
+
"data-stldocs-type-preview": "properties",
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ jsx("span", {
|
|
94
|
+
className: style_default.TypeBrace,
|
|
95
|
+
children: " {"
|
|
96
|
+
}),
|
|
97
|
+
/* @__PURE__ */ jsxs("span", {
|
|
98
|
+
className: style_default.TypePreviewContent,
|
|
99
|
+
children: [
|
|
100
|
+
" ",
|
|
101
|
+
/* @__PURE__ */ jsx(Join, {
|
|
102
|
+
items,
|
|
103
|
+
limit: 3,
|
|
104
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
105
|
+
className: style_default.TextOperator,
|
|
106
|
+
children: ", "
|
|
107
|
+
})
|
|
108
|
+
}),
|
|
109
|
+
" "
|
|
110
|
+
]
|
|
111
|
+
}),
|
|
112
|
+
/* @__PURE__ */ jsx("span", {
|
|
113
|
+
className: style_default.TypeBrace,
|
|
114
|
+
children: "} "
|
|
115
|
+
})
|
|
116
|
+
]
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function TypeName({ type }) {
|
|
120
|
+
const Lang = useLanguageComponents();
|
|
121
|
+
return ComplexTypes[type.kind] ?? /* @__PURE__ */ jsx(Lang.Type, { type });
|
|
122
|
+
}
|
|
123
|
+
function Type({ type }) {
|
|
124
|
+
const Lang = useLanguageComponents();
|
|
125
|
+
const { Join, SDKReference } = useComponents();
|
|
126
|
+
switch (type.kind) {
|
|
127
|
+
case "TSTypeUnknown":
|
|
128
|
+
case "TSTypeUndefined":
|
|
129
|
+
case "TSTypeNever":
|
|
130
|
+
case "TSTypeVoid":
|
|
131
|
+
case "TSTypeNull":
|
|
132
|
+
case "TSTypeAny":
|
|
133
|
+
case "TSTypeBoolean":
|
|
134
|
+
case "TSTypeNumber": return /* @__PURE__ */ jsx("span", {
|
|
135
|
+
className: style_default.Type,
|
|
136
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
137
|
+
className: style_default.TypeKeyword,
|
|
138
|
+
children: type.kind.slice(6).toLowerCase()
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
case "TSTypeString": return /* @__PURE__ */ jsx("span", {
|
|
142
|
+
className: style_default.Type,
|
|
143
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
144
|
+
className: style_default.TypeString,
|
|
145
|
+
children: "string"
|
|
146
|
+
})
|
|
147
|
+
});
|
|
148
|
+
case "TSTypeLiteral": return /* @__PURE__ */ jsx("span", {
|
|
149
|
+
className: style_default.Type,
|
|
150
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
151
|
+
className: constStyle[typeof type.literal],
|
|
152
|
+
children: JSON.stringify(type.literal)
|
|
153
|
+
})
|
|
154
|
+
});
|
|
155
|
+
case "TSTypeArray": return /* @__PURE__ */ jsxs("span", {
|
|
156
|
+
className: style_default.Type,
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ jsx("span", {
|
|
159
|
+
className: style_default.TypeArray,
|
|
160
|
+
children: "Array<"
|
|
161
|
+
}),
|
|
162
|
+
/* @__PURE__ */ jsx(Lang.Type, { type: type.elementType }),
|
|
163
|
+
/* @__PURE__ */ jsx("span", {
|
|
164
|
+
className: style_default.TypeArray,
|
|
165
|
+
children: ">"
|
|
166
|
+
})
|
|
167
|
+
]
|
|
168
|
+
});
|
|
169
|
+
case "TSTypeReference": {
|
|
170
|
+
const name = type.ident.split(".").at(-1);
|
|
171
|
+
const params = type.typeParameters?.map((param, key) => /* @__PURE__ */ jsx(Lang.Type, { type: param }, key));
|
|
172
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
173
|
+
className: style_default.Type,
|
|
174
|
+
children: [
|
|
175
|
+
/* @__PURE__ */ jsx(SDKReference, {
|
|
176
|
+
stainlessPath: type.$ref,
|
|
177
|
+
children: name
|
|
178
|
+
}),
|
|
179
|
+
params && params.length > 0 && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
180
|
+
/* @__PURE__ */ jsx("span", {
|
|
181
|
+
className: style_default.TypeBracket,
|
|
182
|
+
children: "<"
|
|
183
|
+
}),
|
|
184
|
+
/* @__PURE__ */ jsx(Join, {
|
|
185
|
+
items: params,
|
|
186
|
+
limit: 3,
|
|
187
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
188
|
+
className: style_default.TextOperator,
|
|
189
|
+
children: ", "
|
|
190
|
+
})
|
|
191
|
+
}),
|
|
192
|
+
/* @__PURE__ */ jsx("span", {
|
|
193
|
+
className: style_default.TypeBracket,
|
|
194
|
+
children: ">"
|
|
195
|
+
})
|
|
196
|
+
] }),
|
|
197
|
+
/* @__PURE__ */ jsx(TypePreview, { path: type.$ref })
|
|
198
|
+
]
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
case "TSTypeIntersection":
|
|
202
|
+
case "TSTypeUnion": {
|
|
203
|
+
const items = type.types.map((t, key) => /* @__PURE__ */ jsx(Lang.Type, { type: t }, key));
|
|
204
|
+
const delimiter = type.kind === "TSTypeUnion" ? "|" : "&";
|
|
205
|
+
return /* @__PURE__ */ jsx("span", {
|
|
206
|
+
className: style_default.Type,
|
|
207
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
208
|
+
className: style_default.TypePreview,
|
|
209
|
+
"data-stldocs-type-preview": "union",
|
|
210
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
211
|
+
className: style_default.TypePreviewContent,
|
|
212
|
+
children: /* @__PURE__ */ jsx(Join, {
|
|
213
|
+
items,
|
|
214
|
+
limit: 3,
|
|
215
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
216
|
+
className: style_default.TextOperator,
|
|
217
|
+
children: [
|
|
218
|
+
" ",
|
|
219
|
+
delimiter,
|
|
220
|
+
" "
|
|
221
|
+
]
|
|
222
|
+
})
|
|
223
|
+
})
|
|
224
|
+
})
|
|
225
|
+
})
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
case "TSTypeObject":
|
|
229
|
+
case "TSTypeInterface": {
|
|
230
|
+
const extend = type.kind === "TSTypeObject" ? null : type.extends?.map((ref, key) => /* @__PURE__ */ jsx(Lang.Type, { type: ref }, key));
|
|
231
|
+
const items = type.members.map((prop, key) => /* @__PURE__ */ jsxs(React$1.Fragment, { children: [
|
|
232
|
+
/* @__PURE__ */ jsx("span", {
|
|
233
|
+
className: style_default.TypePropertyName,
|
|
234
|
+
children: /* @__PURE__ */ jsx(Identifier, {
|
|
235
|
+
name: prop.ident,
|
|
236
|
+
optional: prop.optional
|
|
237
|
+
})
|
|
238
|
+
}),
|
|
239
|
+
/* @__PURE__ */ jsx("span", {
|
|
240
|
+
className: style_default.TextPunctuation,
|
|
241
|
+
children: ": "
|
|
242
|
+
}),
|
|
243
|
+
/* @__PURE__ */ jsx(Lang.Type, { type: prop.type })
|
|
244
|
+
] }, key));
|
|
245
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
246
|
+
className: style_default.Type,
|
|
247
|
+
children: [extend?.length && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
248
|
+
className: style_default.TypeKeyword,
|
|
249
|
+
children: " extends "
|
|
250
|
+
}), /* @__PURE__ */ jsx(Join, {
|
|
251
|
+
items: extend,
|
|
252
|
+
limit: 3,
|
|
253
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
254
|
+
className: style_default.TextOperator,
|
|
255
|
+
children: ", "
|
|
256
|
+
})
|
|
257
|
+
})] }), /* @__PURE__ */ jsxs("span", {
|
|
258
|
+
className: style_default.TypePreview,
|
|
259
|
+
"data-stldocs-type-preview": "properties",
|
|
260
|
+
children: [
|
|
261
|
+
/* @__PURE__ */ jsx("span", {
|
|
262
|
+
className: style_default.TypeBrace,
|
|
263
|
+
children: "{ "
|
|
264
|
+
}),
|
|
265
|
+
/* @__PURE__ */ jsx("span", {
|
|
266
|
+
className: style_default.TypePreviewContent,
|
|
267
|
+
children: /* @__PURE__ */ jsx(Join, {
|
|
268
|
+
items,
|
|
269
|
+
limit: 3,
|
|
270
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
271
|
+
className: style_default.TextOperator,
|
|
272
|
+
children: ", "
|
|
273
|
+
})
|
|
274
|
+
})
|
|
275
|
+
}),
|
|
276
|
+
/* @__PURE__ */ jsx("span", {
|
|
277
|
+
className: style_default.TypeBrace,
|
|
278
|
+
children: "} "
|
|
279
|
+
})
|
|
280
|
+
]
|
|
281
|
+
})]
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
function MethodSignature({ decl }) {
|
|
287
|
+
const Lang = useLanguageComponents();
|
|
288
|
+
const { Join, Tooltip } = useComponents();
|
|
289
|
+
const params = decl.signature.parameters.map((param, i) => /* @__PURE__ */ jsxs(React$1.Fragment, { children: [/* @__PURE__ */ jsx(Tooltip, {
|
|
290
|
+
content: /* @__PURE__ */ jsx(Lang.Type, { type: param.type }),
|
|
291
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
292
|
+
className: style_default.TextIdentifier,
|
|
293
|
+
children: param.ident
|
|
294
|
+
})
|
|
295
|
+
}), param.optional && /* @__PURE__ */ jsx("span", {
|
|
296
|
+
className: style_default.TextPunctuation,
|
|
297
|
+
children: "?"
|
|
298
|
+
})] }, i));
|
|
299
|
+
return /* @__PURE__ */ jsx("div", {
|
|
300
|
+
className: style_default.MethodSignature,
|
|
301
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
302
|
+
className: style_default.SignatureTitle,
|
|
303
|
+
children: [
|
|
304
|
+
decl.signature.async && /* @__PURE__ */ jsx("span", {
|
|
305
|
+
className: style_default.TextKeyword,
|
|
306
|
+
children: "async "
|
|
307
|
+
}),
|
|
308
|
+
/* @__PURE__ */ jsx("span", {
|
|
309
|
+
className: style_default.SignatureQualified,
|
|
310
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
311
|
+
className: style_default.TextIdentifier,
|
|
312
|
+
children: decl.qualified?.slice(0, -decl.ident.length)
|
|
313
|
+
})
|
|
314
|
+
}),
|
|
315
|
+
/* @__PURE__ */ jsx("span", {
|
|
316
|
+
className: style_default.SignatureName,
|
|
317
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
318
|
+
className: style_default.TextIdentifier,
|
|
319
|
+
children: decl.ident
|
|
320
|
+
})
|
|
321
|
+
}),
|
|
322
|
+
/* @__PURE__ */ jsxs("span", {
|
|
323
|
+
className: style_default.MethodSignature,
|
|
324
|
+
children: [
|
|
325
|
+
decl.signature.typeParameters && /* @__PURE__ */ jsx(TypeParams, { params: decl.signature.typeParameters }),
|
|
326
|
+
/* @__PURE__ */ jsx("span", {
|
|
327
|
+
className: style_default.SignatureParen,
|
|
328
|
+
children: "("
|
|
329
|
+
}),
|
|
330
|
+
/* @__PURE__ */ jsx("span", {
|
|
331
|
+
className: style_default.SignatureParams,
|
|
332
|
+
children: /* @__PURE__ */ jsx(Join, {
|
|
333
|
+
items: params,
|
|
334
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
335
|
+
className: style_default.TextOperator,
|
|
336
|
+
children: ", "
|
|
337
|
+
})
|
|
338
|
+
})
|
|
339
|
+
}),
|
|
340
|
+
/* @__PURE__ */ jsx("span", {
|
|
341
|
+
className: style_default.SignatureParen,
|
|
342
|
+
children: ")"
|
|
343
|
+
}),
|
|
344
|
+
decl.signature.returns && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
345
|
+
className: style_default.TextPunctuation,
|
|
346
|
+
children: ": "
|
|
347
|
+
}), /* @__PURE__ */ jsx(Lang.Type, { type: decl.signature.returns })] })
|
|
348
|
+
]
|
|
349
|
+
})
|
|
350
|
+
]
|
|
351
|
+
})
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
function Property({ decl, children }) {
|
|
355
|
+
const Lang = useLanguageComponents();
|
|
356
|
+
if (!decl) return;
|
|
357
|
+
switch (decl.kind) {
|
|
358
|
+
case "TSDeclProperty": return children({
|
|
359
|
+
name: decl.key,
|
|
360
|
+
typeName: /* @__PURE__ */ jsx(Lang.TypeName, { type: decl.type }),
|
|
361
|
+
type: decl.type.kind in ComplexTypes && /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
|
|
362
|
+
});
|
|
363
|
+
case "TSDeclTypeAlias": return children({
|
|
364
|
+
name: decl.ident,
|
|
365
|
+
typeName: "alias",
|
|
366
|
+
type: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
|
|
367
|
+
});
|
|
368
|
+
case "TSDeclReference": return children({ type: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type }) });
|
|
369
|
+
case "TSDeclInterface": return children({ type: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
370
|
+
/* @__PURE__ */ jsx("span", {
|
|
371
|
+
className: style_default.TextIdentifier,
|
|
372
|
+
children: decl.ident
|
|
373
|
+
}),
|
|
374
|
+
decl.typeParameters && /* @__PURE__ */ jsx(TypeParams, { params: decl.typeParameters }),
|
|
375
|
+
decl.extends?.flatMap((t, key) => /* @__PURE__ */ jsxs(React$1.Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
376
|
+
className: style_default.TextKeyword,
|
|
377
|
+
children: " extends "
|
|
378
|
+
}), /* @__PURE__ */ jsx(Lang.Type, { type: t })] }, `extends:${key}`))
|
|
379
|
+
] }) });
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
function Declaration({ decl }) {
|
|
383
|
+
const Lang = useLanguageComponents();
|
|
384
|
+
if (!decl) return;
|
|
385
|
+
switch (decl.kind) {
|
|
386
|
+
case "TSDeclProperty": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
387
|
+
decl.declare && /* @__PURE__ */ jsx("span", {
|
|
388
|
+
className: style_default.TextKeyword,
|
|
389
|
+
children: "declare "
|
|
390
|
+
}),
|
|
391
|
+
/* @__PURE__ */ jsx("span", {
|
|
392
|
+
className: style_default.TypePropertyName,
|
|
393
|
+
children: /* @__PURE__ */ jsx(Identifier, {
|
|
394
|
+
name: decl.key,
|
|
395
|
+
optional: decl.optional
|
|
396
|
+
})
|
|
397
|
+
}),
|
|
398
|
+
/* @__PURE__ */ jsx("span", {
|
|
399
|
+
className: style_default.TextPunctuation,
|
|
400
|
+
children: ": "
|
|
401
|
+
}),
|
|
402
|
+
/* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
|
|
403
|
+
] });
|
|
404
|
+
case "TSDeclFunction": return /* @__PURE__ */ jsx(Lang.MethodSignature, { decl });
|
|
405
|
+
case "TSDeclTypeAlias": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
406
|
+
/* @__PURE__ */ jsx(Identifier, { name: decl.ident }),
|
|
407
|
+
/* @__PURE__ */ jsx(TypeParams, { params: decl.typeParameters }),
|
|
408
|
+
/* @__PURE__ */ jsx("span", {
|
|
409
|
+
className: style_default.TextOperator,
|
|
410
|
+
children: " = "
|
|
411
|
+
}),
|
|
412
|
+
/* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
|
|
413
|
+
] });
|
|
414
|
+
case "TSDeclReference": return /* @__PURE__ */ jsx(Lang.Type, { type: decl.type });
|
|
415
|
+
case "TSDeclInterface": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
416
|
+
/* @__PURE__ */ jsx("span", {
|
|
417
|
+
className: style_default.TextIdentifier,
|
|
418
|
+
children: decl.ident
|
|
419
|
+
}),
|
|
420
|
+
/* @__PURE__ */ jsx(TypeParams, { params: decl.typeParameters }),
|
|
421
|
+
decl.extends?.map((t, index) => /* @__PURE__ */ jsxs(React$1.Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
422
|
+
className: style_default.TextKeyword,
|
|
423
|
+
children: " extends "
|
|
424
|
+
}), /* @__PURE__ */ jsx(Lang.Type, { type: t })] }, index)),
|
|
425
|
+
/* @__PURE__ */ jsx(TypePreview, { path: decl.stainlessPath })
|
|
426
|
+
] });
|
|
427
|
+
case "TSDeclClass": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
428
|
+
/* @__PURE__ */ jsx("span", {
|
|
429
|
+
className: style_default.TextKeyword,
|
|
430
|
+
children: "class "
|
|
431
|
+
}),
|
|
432
|
+
/* @__PURE__ */ jsx("span", {
|
|
433
|
+
className: style_default.TextIdentifier,
|
|
434
|
+
children: decl.ident
|
|
435
|
+
}),
|
|
436
|
+
/* @__PURE__ */ jsx(TypeParams, { params: decl.typeParameters }),
|
|
437
|
+
decl.superClass ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
438
|
+
className: style_default.TextKeyword,
|
|
439
|
+
children: " extends "
|
|
440
|
+
}), /* @__PURE__ */ jsx(Lang.Type, { type: decl.superClass })] }) : null,
|
|
441
|
+
decl.implements?.map((t, index) => /* @__PURE__ */ jsxs(React$1.Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
442
|
+
className: style_default.TextKeyword,
|
|
443
|
+
children: " implements "
|
|
444
|
+
}), /* @__PURE__ */ jsx(Lang.Type, { type: t })] }, index))
|
|
445
|
+
] });
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
//#endregion
|
|
450
|
+
export { Declaration, MethodSignature, Property, Type, TypeName, typescript_exports as t };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { d as Method, f as Model, h as Resource, i as DeclarationNode } from "../index-pvh-w1xa.js";
|
|
2
|
+
import { EnvironmentType } from "./utils.js";
|
|
3
|
+
import { t as printer_d_exports } from "./printer.js";
|
|
4
|
+
import { Node } from "@markdoc/markdoc";
|
|
5
|
+
|
|
6
|
+
//#region src/markdown/index.d.ts
|
|
7
|
+
declare function declaration(env: EnvironmentType, decl: DeclarationNode): Node;
|
|
8
|
+
declare function render(env: EnvironmentType, node: Resource | Method | Model): Node[];
|
|
9
|
+
declare function renderMarkdown(env: EnvironmentType, node: Resource | Method | Model): string;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { declaration, printer_d_exports as printer, render, renderMarkdown };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import "../use-strict-context-L0c8JKg4.js";
|
|
2
|
+
import { code, fence, heading, item, list, paragraph, parse, strong, text } from "./md.js";
|
|
3
|
+
import { getDecl, getSnippet, stripMarkup } from "./utils.js";
|
|
4
|
+
import { declaration as declaration$1, methodSignature, t as printer_exports } from "./printer.js";
|
|
5
|
+
import Markdoc from "@markdoc/markdoc";
|
|
6
|
+
|
|
7
|
+
//#region src/markdown/index.ts
|
|
8
|
+
function declaration(env, decl) {
|
|
9
|
+
const content = declaration$1(env.language, decl);
|
|
10
|
+
return paragraph(code(stripMarkup(content)));
|
|
11
|
+
}
|
|
12
|
+
function renderChildren(env, children, nesting = []) {
|
|
13
|
+
return list(...children.map((child) => renderDecl(env, child, nesting)));
|
|
14
|
+
}
|
|
15
|
+
function renderDecl(env, path, nesting = []) {
|
|
16
|
+
const decl = getDecl(env, path);
|
|
17
|
+
const item$1 = item(declaration(env, decl));
|
|
18
|
+
const hasChildren = "children" in decl && decl.children && decl.children.length > 0;
|
|
19
|
+
const showModelProps = !("modelPath" in decl && decl["modelPath"]) || env.options.includeModelProperties;
|
|
20
|
+
if ("docstring" in decl && decl.docstring) item$1.children.push(...parse(decl.docstring));
|
|
21
|
+
if (hasChildren && showModelProps && !nesting.includes(path)) item$1.push(renderChildren(env, decl.children ?? [], [...nesting, path]));
|
|
22
|
+
return item$1;
|
|
23
|
+
}
|
|
24
|
+
function renderMethod(env, method) {
|
|
25
|
+
const decl = getDecl(env, method.stainlessPath);
|
|
26
|
+
if (!decl) return [paragraph(text("The method "), code(method.name), text(" is not available in this language."))];
|
|
27
|
+
const signature = methodSignature(env.language, decl);
|
|
28
|
+
const [httpMethod, endpoint] = method.endpoint.split(" ");
|
|
29
|
+
const output = [
|
|
30
|
+
heading(2, method.title),
|
|
31
|
+
...env.language === "http" ? [] : [paragraph(code(stripMarkup(signature)))],
|
|
32
|
+
paragraph(strong(text(httpMethod)), text(" "), code(endpoint))
|
|
33
|
+
];
|
|
34
|
+
if (method.description) output.push(...parse(method.description));
|
|
35
|
+
if (env.language === "http") {
|
|
36
|
+
const p = "paramsChildren" in decl && typeof decl.paramsChildren === "object" ? decl.paramsChildren : {};
|
|
37
|
+
for (const [location, value] of Object.entries(p)) {
|
|
38
|
+
if (value.length < 1) continue;
|
|
39
|
+
output.push(heading(3, [
|
|
40
|
+
text(location.at(0)?.toUpperCase() ?? ""),
|
|
41
|
+
text(location.slice(1)),
|
|
42
|
+
text(" Parameters")
|
|
43
|
+
]), renderChildren(env, value));
|
|
44
|
+
}
|
|
45
|
+
const bp = "bodyParamsChildren" in decl ? decl.bodyParamsChildren?.["application/json"] : [];
|
|
46
|
+
if (bp && bp.length > 0) output.push(heading(3, "Body Parameters"), renderChildren(env, bp));
|
|
47
|
+
}
|
|
48
|
+
if ("paramsChildren" in decl && Array.isArray(decl.paramsChildren) && decl.paramsChildren.length > 0) output.push(heading(3, "Parameters"), renderChildren(env, decl.paramsChildren));
|
|
49
|
+
if ("responseChildren" in decl && decl.responseChildren && decl.responseChildren.length > 0) output.push(heading(3, "Returns"), renderChildren(env, decl.responseChildren));
|
|
50
|
+
const snippet = getSnippet(env, method.stainlessPath);
|
|
51
|
+
if (snippet) output.push(heading(3, "Example"), fence(env.language, snippet));
|
|
52
|
+
return output;
|
|
53
|
+
}
|
|
54
|
+
function renderModel(env, model) {
|
|
55
|
+
return [heading(3, model.title), list(renderDecl(env, `${model.stainlessPath} > (schema)`))];
|
|
56
|
+
}
|
|
57
|
+
function renderResource(env, resource) {
|
|
58
|
+
const methods = Object.values(resource.methods).filter((method) => getDecl(env, method.stainlessPath)).flatMap((method) => renderMethod(env, method));
|
|
59
|
+
const models = Object.values(resource.models).filter((model) => getDecl(env, `${model.stainlessPath} > (schema)`)).flatMap((model) => renderModel(env, model));
|
|
60
|
+
const doc = [heading(1, resource.title), ...methods];
|
|
61
|
+
if (models.length > 0) doc.push(heading(2, "Domain Types"), ...models);
|
|
62
|
+
if (!env.options.renderNestedResources) return doc;
|
|
63
|
+
const children = Object.values(resource.subresources ?? {}).flatMap((resource) => renderResource(env, resource));
|
|
64
|
+
return [...doc, ...children];
|
|
65
|
+
}
|
|
66
|
+
function render(env, node) {
|
|
67
|
+
switch (node.kind) {
|
|
68
|
+
case "resource": return renderResource(env, node);
|
|
69
|
+
case "http_method": return renderMethod(env, node);
|
|
70
|
+
case "model": return renderModel(env, node);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function renderMarkdown(env, node) {
|
|
74
|
+
const content = render(env, node);
|
|
75
|
+
const doc = new Markdoc.Ast.Node("document", {}, content);
|
|
76
|
+
return Markdoc.format(doc);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
export { declaration, printer_exports as printer, render, renderMarkdown };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Node } from "@markdoc/markdoc";
|
|
2
|
+
|
|
3
|
+
//#region src/markdown/md.d.ts
|
|
4
|
+
declare function heading(level: number, children: string | Node[]): Node;
|
|
5
|
+
declare function text(content: string): Node;
|
|
6
|
+
declare function code(content: string): Node;
|
|
7
|
+
declare function paragraph(...children: Node[]): Node;
|
|
8
|
+
declare function list(...children: Node[]): Node;
|
|
9
|
+
declare function item(...children: Node[]): Node;
|
|
10
|
+
declare function strong(...children: Node[]): Node;
|
|
11
|
+
declare function inline(...children: Node[]): Node;
|
|
12
|
+
declare function fence(language: string, content: string): Node;
|
|
13
|
+
declare function parse(content: string): Node[];
|
|
14
|
+
//#endregion
|
|
15
|
+
export { code, fence, heading, inline, item, list, paragraph, parse, strong, text };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Markdoc from "@markdoc/markdoc";
|
|
2
|
+
|
|
3
|
+
//#region src/markdown/md.ts
|
|
4
|
+
function heading(level, children) {
|
|
5
|
+
const content = inline(...typeof children === "string" ? [text(children)] : children);
|
|
6
|
+
return new Markdoc.Ast.Node("heading", { level }, [content]);
|
|
7
|
+
}
|
|
8
|
+
function text(content) {
|
|
9
|
+
return new Markdoc.Ast.Node("text", { content });
|
|
10
|
+
}
|
|
11
|
+
function code(content) {
|
|
12
|
+
return new Markdoc.Ast.Node("code", { content });
|
|
13
|
+
}
|
|
14
|
+
function paragraph(...children) {
|
|
15
|
+
const inline = new Markdoc.Ast.Node("inline", {}, children);
|
|
16
|
+
return new Markdoc.Ast.Node("paragraph", {}, [inline]);
|
|
17
|
+
}
|
|
18
|
+
function list(...children) {
|
|
19
|
+
return new Markdoc.Ast.Node("list", { ordered: false }, children);
|
|
20
|
+
}
|
|
21
|
+
function item(...children) {
|
|
22
|
+
return new Markdoc.Ast.Node("item", {}, children);
|
|
23
|
+
}
|
|
24
|
+
function strong(...children) {
|
|
25
|
+
return new Markdoc.Ast.Node("strong", {}, children);
|
|
26
|
+
}
|
|
27
|
+
function inline(...children) {
|
|
28
|
+
return new Markdoc.Ast.Node("inline", {}, children);
|
|
29
|
+
}
|
|
30
|
+
function fence(language, content) {
|
|
31
|
+
return new Markdoc.Ast.Node("fence", {
|
|
32
|
+
language,
|
|
33
|
+
content
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function parse(content) {
|
|
37
|
+
return Markdoc.parse(content).children;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { code, fence, heading, inline, item, list, paragraph, parse, strong, text };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { S as Type, i as DeclarationNode } from "../index-pvh-w1xa.js";
|
|
2
|
+
import { DocsLanguage } from "../routing.js";
|
|
3
|
+
|
|
4
|
+
//#region src/markdown/printer.d.ts
|
|
5
|
+
declare namespace printer_d_exports {
|
|
6
|
+
export { declaration, methodSignature, type, typeName };
|
|
7
|
+
}
|
|
8
|
+
declare function typeName(language: DocsLanguage, type: Type): string;
|
|
9
|
+
declare function type(language: DocsLanguage, type: Type): string;
|
|
10
|
+
declare function declaration(language: DocsLanguage, decl: DeclarationNode): string;
|
|
11
|
+
declare function methodSignature(language: DocsLanguage, decl: DeclarationNode): string;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { declaration, methodSignature, printer_d_exports as t, type, typeName };
|