@stainless-api/docs-ui 0.1.0-beta.10 → 0.1.0-beta.11
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-Z-hEqjcp.d.ts +19 -0
- package/dist/chunk-Bp6m_JJh.js +13 -0
- package/dist/component-generics-DzI21jRn.js +35 -0
- package/dist/component-generics-q5Dqiu2D.d.ts +30 -0
- package/dist/components/breadcrumbs.d.ts +2 -11
- package/dist/components/breadcrumbs.js +16 -52
- package/dist/components/chat.d.ts +13 -5
- package/dist/components/chat.js +138 -74
- package/dist/components/dropdown.d.ts +2 -17
- package/dist/components/dropdown.js +4 -18
- package/dist/components/icons.d.ts +50 -27
- package/dist/components/icons.js +3 -34
- package/dist/components/index.d.ts +12 -9
- package/dist/components/index.js +16 -10
- package/dist/components/method.d.ts +2 -41
- package/dist/components/method.js +16 -44
- package/dist/components/overview.d.ts +2 -21
- package/dist/components/overview.js +16 -49
- package/dist/components/primitives.d.ts +2 -60
- package/dist/components/primitives.js +16 -117
- package/dist/components/properties.d.ts +2 -24
- package/dist/components/properties.js +16 -24
- package/dist/components/scripts/dropdown.d.ts +11 -4
- package/dist/components/scripts/dropdown.js +49 -63
- package/dist/components/sdk.d.ts +3 -78
- package/dist/components/sdk.js +16 -153
- package/dist/components/sidebar.d.ts +2 -22
- package/dist/components/sidebar.js +16 -30
- package/dist/components/snippets.d.ts +4 -28
- package/dist/components/snippets.js +16 -76
- package/dist/contexts/component-generics.d.ts +2 -25
- package/dist/contexts/component-generics.js +3 -24
- package/dist/contexts/component-types.d.ts +18 -4
- package/dist/contexts/component-types.js +1 -2
- package/dist/contexts/component.d.ts +31 -14
- package/dist/contexts/component.js +16 -14
- package/dist/contexts/docs.d.ts +2 -34
- package/dist/contexts/docs.js +3 -43
- package/dist/contexts/index.d.ts +20 -7
- package/dist/contexts/index.js +16 -15
- package/dist/contexts/markdown.d.ts +2 -13
- package/dist/contexts/markdown.js +4 -29
- package/dist/contexts/navigation.d.ts +3 -19
- package/dist/contexts/navigation.js +3 -14
- package/dist/contexts/search.d.ts +4 -13
- package/dist/contexts/search.js +16 -15
- package/dist/contexts/use-components.d.ts +16 -1
- package/dist/contexts/use-components.js +4 -3
- package/dist/contexts-DRxRO-xO.js +3747 -0
- package/dist/docs-Dh8kE1va.js +50 -0
- package/dist/docs-EUy-wfbA.d.ts +43 -0
- package/dist/dropdown-B7VyGMOw.d.ts +43 -0
- package/dist/dropdown-DtgAi6lb.js +62 -0
- package/dist/icons-DdKM-01E.js +753 -0
- package/dist/index-AicgPYKB.d.ts +239 -0
- package/dist/index-BhwLhiWk.d.ts +14 -0
- package/dist/index-YnpUtXLB.d.ts +16 -0
- package/dist/index.d.ts +22 -6
- package/dist/index.js +16 -7
- package/dist/languages/go.d.ts +13 -21
- package/dist/languages/go.js +16 -116
- package/dist/languages/http.d.ts +13 -25
- package/dist/languages/http.js +16 -130
- package/dist/languages/index.d.ts +13 -37
- package/dist/languages/index.js +16 -10
- package/dist/languages/java.d.ts +13 -23
- package/dist/languages/java.js +16 -120
- package/dist/languages/python.d.ts +13 -22
- package/dist/languages/python.js +16 -104
- package/dist/languages/ruby.d.ts +13 -22
- package/dist/languages/ruby.js +16 -125
- package/dist/languages/typescript.d.ts +13 -22
- package/dist/languages/typescript.js +16 -134
- package/dist/markdown/index.d.ts +11 -6
- package/dist/markdown/index.js +16 -80
- package/dist/markdown/md.d.ts +15 -11
- package/dist/markdown/md.js +3 -34
- package/dist/markdown/utils.d.ts +4 -17
- package/dist/markdown/utils.js +3 -30
- package/dist/markdown-BXfX1D7C.js +42 -0
- package/dist/markdown-nFyAEX_K.d.ts +22 -0
- package/dist/md-Dg8aOyMA.js +41 -0
- package/dist/method-DpsVuzZW.d.ts +71 -0
- package/dist/navigation-aoYZ_tl4.js +24 -0
- package/dist/navigation-nyXBY-75.d.ts +29 -0
- package/dist/overview-C8e-6jGr.d.ts +38 -0
- package/dist/pagefind-ChrPfuVv.js +15 -0
- package/dist/primitives-DWz23_Ub.d.ts +99 -0
- package/dist/properties-CF71V58d.d.ts +46 -0
- package/dist/routing-DQjbRxdJ.js +189 -0
- package/dist/routing-qc0V00-j.d.ts +51 -0
- package/dist/routing.d.ts +2 -44
- package/dist/routing.js +3 -169
- package/dist/sdk-Zg3Rggk3.d.ts +118 -0
- package/dist/search/index.d.ts +26 -1
- package/dist/search/index.js +332 -2
- package/dist/search/providers/algolia.d.ts +22 -7
- package/dist/search/providers/algolia.js +16 -64
- package/dist/search/providers/fuse.d.ts +16 -9
- package/dist/search/providers/fuse.js +29 -12
- package/dist/search/providers/pagefind.d.ts +7 -2
- package/dist/search/providers/pagefind.js +3 -19
- package/dist/search/providers/walker.d.ts +8 -5
- package/dist/search/providers/walker.js +28 -19
- package/dist/search/types.d.ts +3 -79
- package/dist/search/types.js +3 -24
- package/dist/search-B6loAGmB.d.ts +21 -0
- package/dist/sidebar-C8KirYjg.d.ts +35 -0
- package/dist/snippets-EUzM4fRO.d.ts +45 -0
- package/dist/style-pN9hCoec.d.ts +181 -0
- package/dist/style-rYbbxIR_.js +182 -0
- package/dist/style.d.ts +2 -179
- package/dist/style.js +3 -179
- package/dist/styles/main.css +740 -746
- package/dist/styles/main.js +1 -0
- package/dist/styles/primitives.css +436 -428
- package/dist/styles/primitives.js +1 -0
- package/dist/styles/resets.css +34 -41
- package/dist/styles/resets.js +1 -0
- package/dist/styles/search.css +248 -248
- package/dist/styles/search.js +1 -0
- package/dist/styles/sidebar.css +59 -60
- package/dist/styles/sidebar.js +1 -0
- package/dist/styles/snippets.css +87 -88
- package/dist/styles/snippets.js +1 -0
- package/dist/styles/variables.css +86 -89
- package/dist/styles/variables.js +1 -0
- package/dist/types-CTBDtD34.d.ts +82 -0
- package/dist/types-DFN4M1Sp.js +34 -0
- package/dist/use-components-D9E85p5x.js +7 -0
- package/dist/utils-BHwvUDKn.js +30 -0
- package/dist/utils-CJfFBNgT.js +32 -0
- package/dist/utils-DQhEbvUC.d.ts +20 -0
- package/dist/utils-nDazhti8.d.ts +11 -0
- package/dist/utils.d.ts +2 -7
- package/dist/utils.js +4 -27
- package/package.json +2 -2
- package/dist/components/breadcrumbs.js.map +0 -1
- package/dist/components/chat.js.map +0 -1
- package/dist/components/dropdown.js.map +0 -1
- package/dist/components/icons.js.map +0 -1
- package/dist/components/index.js.map +0 -1
- package/dist/components/method.js.map +0 -1
- package/dist/components/overview.js.map +0 -1
- package/dist/components/primitives.js.map +0 -1
- package/dist/components/properties.js.map +0 -1
- package/dist/components/scripts/dropdown.js.map +0 -1
- package/dist/components/sdk.js.map +0 -1
- package/dist/components/sidebar.js.map +0 -1
- package/dist/components/snippets.js.map +0 -1
- package/dist/contexts/component-generics.js.map +0 -1
- package/dist/contexts/component-types.js.map +0 -1
- package/dist/contexts/component.js.map +0 -1
- package/dist/contexts/docs.js.map +0 -1
- package/dist/contexts/index.js.map +0 -1
- package/dist/contexts/markdown.js.map +0 -1
- package/dist/contexts/navigation.js.map +0 -1
- package/dist/contexts/search.js.map +0 -1
- package/dist/contexts/use-components.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/languages/go.js.map +0 -1
- package/dist/languages/http.js.map +0 -1
- package/dist/languages/index.js.map +0 -1
- package/dist/languages/java.js.map +0 -1
- package/dist/languages/python.js.map +0 -1
- package/dist/languages/ruby.js.map +0 -1
- package/dist/languages/typescript.js.map +0 -1
- package/dist/markdown/index.js.map +0 -1
- package/dist/markdown/md.js.map +0 -1
- package/dist/markdown/utils.js.map +0 -1
- package/dist/mcp.js +0 -16105
- package/dist/routing.js.map +0 -1
- package/dist/search/form.d.ts +0 -13
- package/dist/search/form.js +0 -55
- package/dist/search/form.js.map +0 -1
- package/dist/search/index.js.map +0 -1
- package/dist/search/indexer.d.ts +0 -31
- package/dist/search/indexer.js +0 -212
- package/dist/search/indexer.js.map +0 -1
- package/dist/search/mcp.d.ts +0 -8
- package/dist/search/mcp.js +0 -43
- package/dist/search/mcp.js.map +0 -1
- package/dist/search/printer.d.ts +0 -6
- package/dist/search/printer.js +0 -43
- package/dist/search/printer.js.map +0 -1
- package/dist/search/providers/algolia.js.map +0 -1
- package/dist/search/providers/fuse.js.map +0 -1
- package/dist/search/providers/pagefind.js.map +0 -1
- package/dist/search/providers/walker.js.map +0 -1
- package/dist/search/results.d.ts +0 -21
- package/dist/search/results.js +0 -58
- package/dist/search/results.js.map +0 -1
- package/dist/search/state.d.ts +0 -29
- package/dist/search/state.js +0 -38
- package/dist/search/state.js.map +0 -1
- package/dist/search/types.js.map +0 -1
- package/dist/style.js.map +0 -1
- package/dist/types/sdkjson.d.ts +0 -1
- package/dist/types/sdkjson.js +0 -2
- package/dist/types/sdkjson.js.map +0 -1
- package/dist/types/stainless-alias/lib/json-spec-v2/GoAST.d.ts +0 -120
- package/dist/types/stainless-alias/lib/json-spec-v2/GoAST.js +0 -2
- package/dist/types/stainless-alias/lib/json-spec-v2/GoAST.js.map +0 -1
- package/dist/types/stainless-alias/lib/json-spec-v2/HttpAST.d.ts +0 -100
- package/dist/types/stainless-alias/lib/json-spec-v2/HttpAST.js +0 -3
- package/dist/types/stainless-alias/lib/json-spec-v2/HttpAST.js.map +0 -1
- package/dist/types/stainless-alias/lib/json-spec-v2/JavaAST.d.ts +0 -87
- package/dist/types/stainless-alias/lib/json-spec-v2/JavaAST.js +0 -2
- package/dist/types/stainless-alias/lib/json-spec-v2/JavaAST.js.map +0 -1
- package/dist/types/stainless-alias/lib/json-spec-v2/PythonAST.d.ts +0 -110
- package/dist/types/stainless-alias/lib/json-spec-v2/PythonAST.js +0 -3
- package/dist/types/stainless-alias/lib/json-spec-v2/PythonAST.js.map +0 -1
- package/dist/types/stainless-alias/lib/json-spec-v2/RubyAST.d.ts +0 -122
- package/dist/types/stainless-alias/lib/json-spec-v2/RubyAST.js +0 -2
- package/dist/types/stainless-alias/lib/json-spec-v2/RubyAST.js.map +0 -1
- package/dist/types/stainless-alias/lib/json-spec-v2/TSAST.d.ts +0 -146
- package/dist/types/stainless-alias/lib/json-spec-v2/TSAST.js +0 -3
- package/dist/types/stainless-alias/lib/json-spec-v2/TSAST.js.map +0 -1
- package/dist/types/stainless-alias/lib/json-spec-v2/TerraformAST.d.ts +0 -89
- package/dist/types/stainless-alias/lib/json-spec-v2/TerraformAST.js +0 -3
- package/dist/types/stainless-alias/lib/json-spec-v2/TerraformAST.js.map +0 -1
- package/dist/types/stainless-alias/lib/json-spec-v2/types.d.ts +0 -190
- package/dist/types/stainless-alias/lib/json-spec-v2/types.js +0 -105
- package/dist/types/stainless-alias/lib/json-spec-v2/types.js.map +0 -1
- package/dist/utils.js.map +0 -1
package/dist/languages/ruby.js
CHANGED
|
@@ -1,125 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
RubyTypeInteger: 'Integer',
|
|
18
|
-
RubyTypeFloat: 'Float',
|
|
19
|
-
RubyTypeBoolean: 'bool',
|
|
20
|
-
};
|
|
21
|
-
export function TypeName({ type }) {
|
|
22
|
-
const Lang = useLanguageComponents();
|
|
23
|
-
return ComplexTypes[type.kind] ?? _jsx(Lang.Type, { type: type });
|
|
24
|
-
}
|
|
25
|
-
const VALID_IDENTIFIER = /^[_A-Za-z][_A-Za-z0-9]*$/;
|
|
26
|
-
function TypePreview({ path }) {
|
|
27
|
-
const spec = useSpec();
|
|
28
|
-
const language = useLanguage();
|
|
29
|
-
const decl = useDeclaration(path);
|
|
30
|
-
const { Join } = useComponents();
|
|
31
|
-
if (!(decl && 'children' in decl && decl.children.length > 0) || decl['type']?.['kind'] === 'RubyTypeUnion')
|
|
32
|
-
return;
|
|
33
|
-
const items = decl.children.map((prop, key) => (_jsx("span", { className: style.TypePropertyName, children: _jsx("span", { className: style.TextIdentifier, children: spec?.decls?.[language]?.[prop]?.['ident'] }) }, key)));
|
|
34
|
-
return (_jsxs("span", { className: style.TypePreview, "data-stldocs-type-preview": "properties", children: [_jsx("span", { className: style.TypeBrace, children: ' {' }), _jsxs("span", { className: style.TypePreviewContent, children: [' ', _jsx(Join, { items: items, limit: 3, children: _jsx("span", { className: style.TextOperator, children: ", " }) }), ' '] }), _jsx("span", { className: style.TypeBrace, children: '} ' })] }));
|
|
35
|
-
}
|
|
36
|
-
export function Type({ type }) {
|
|
37
|
-
const Lang = useLanguageComponents();
|
|
38
|
-
const { SDKReference, Join } = useComponents();
|
|
39
|
-
switch (type.kind) {
|
|
40
|
-
case 'RubyTypeBinary':
|
|
41
|
-
case 'RubyTypeUnknown':
|
|
42
|
-
case 'RubyTypeNull':
|
|
43
|
-
case 'RubyTypeInteger':
|
|
44
|
-
case 'RubyTypeFloat':
|
|
45
|
-
case 'RubyTypeBoolean':
|
|
46
|
-
return (_jsx("span", { className: style.Type, children: _jsx("span", { className: style.TypeKeyword, children: Keywords[type.kind] }) }));
|
|
47
|
-
case 'RubyTypeString':
|
|
48
|
-
return (_jsx("span", { className: style.Type, children: _jsx("span", { className: style.TypeString, children: "String" }) }));
|
|
49
|
-
case 'RubyTypeLiteral':
|
|
50
|
-
switch (typeof type.literal) {
|
|
51
|
-
case 'string':
|
|
52
|
-
return (_jsx("span", { className: style.Type, children: _jsxs("span", { className: style.LiteralString, children: [':', type.literal.match(VALID_IDENTIFIER) ? type.literal : JSON.stringify(type.literal)] }) }));
|
|
53
|
-
case 'number':
|
|
54
|
-
return (_jsx("span", { className: style.Type, children: _jsx("span", { className: style.LiteralNumeric, children: JSON.stringify(type.literal) }) }));
|
|
55
|
-
case 'boolean':
|
|
56
|
-
return (_jsx("span", { className: style.Type, children: _jsx("span", { className: style.LiteralBoolean, children: JSON.stringify(type.literal) }) }));
|
|
57
|
-
}
|
|
58
|
-
case 'RubyTypeArray':
|
|
59
|
-
return (_jsxs("span", { className: style.Type, children: [_jsx("span", { className: style.TypeArray, children: 'Array[' }), _jsx(Lang.Type, { type: type.elementType }), _jsx("span", { className: style.TypeArray, children: ']' })] }));
|
|
60
|
-
case 'RubyTypeMap':
|
|
61
|
-
return (_jsxs("span", { className: style.Type, children: [_jsx("span", { className: style.TypeArray, children: 'Hash[' }), type.indexType.kind === 'RubyTypeString' ? (_jsx("span", { className: style.TypeString, children: "Symbol" })) : (_jsx(Lang.Type, { type: type.indexType })), ", ", _jsx(Lang.Type, { type: type.itemType }), _jsx("span", { className: style.TypeArray, children: ']' })] }));
|
|
62
|
-
case 'RubyTypeReference': {
|
|
63
|
-
const name = type.ident.split('.').at(-1);
|
|
64
|
-
if (!type.typeParameters || type.typeParameters.length === 0)
|
|
65
|
-
return (_jsxs("span", { className: style.Type, children: [_jsx(SDKReference, { stainlessPath: type.$ref, children: name }), _jsx(TypePreview, { path: type.$ref })] }));
|
|
66
|
-
const typeParameters = type.typeParameters.map((t, i) => _jsx(Lang.Type, { type: t }, i));
|
|
67
|
-
return (_jsxs("span", { className: style.Type, children: [_jsx(SDKReference, { stainlessPath: type.$ref, children: name }), _jsx("span", { className: style.TypeBracket, children: '<' }), _jsx(Join, { items: typeParameters, children: _jsx("span", { className: style.TextOperator, children: ", " }) }), _jsx("span", { className: style.TypeBracket, children: '>' }), _jsx(TypePreview, { path: type.$ref })] }));
|
|
68
|
-
}
|
|
69
|
-
case 'RubyTypeIntersection':
|
|
70
|
-
case 'RubyTypeUnion': {
|
|
71
|
-
const items = type.types.map((t, key) => _jsx(Lang.Type, { type: t }, key));
|
|
72
|
-
const delimiter = type.kind === 'RubyTypeUnion' ? '|' : '&';
|
|
73
|
-
return (_jsx("span", { className: style.Type, children: _jsx("span", { className: style.TypePreview, "data-stldocs-type-preview": "union", children: _jsx("span", { className: style.TypePreviewContent, children: _jsx(Join, { items: items, limit: 3, children: _jsxs("span", { className: style.TextOperator, children: [" ", delimiter, " "] }) }) }) }) }));
|
|
74
|
-
}
|
|
75
|
-
case 'RubyTypeBuiltinClass':
|
|
76
|
-
return _jsx("span", { className: style.TypeReference, children: type.className });
|
|
77
|
-
case 'RubyTypeObject': {
|
|
78
|
-
const items = type.members.map((prop, key) => (_jsx("span", { className: style.TextIdentifier, children: prop.ident }, key)));
|
|
79
|
-
return (_jsx("span", { className: style.Type, children: _jsx("span", { className: style.TypePreview, "data-stldocs-type-preview": "properties", children: _jsxs("span", { className: style.TypePreviewContent, children: [_jsx("span", { className: style.TypeBrace, children: '{ ' }), _jsx(Join, { items: items, limit: 3, children: _jsx("span", { className: style.TextOperator, children: ", " }) }), _jsx("span", { className: style.TypeBrace, children: '}' })] }) }) }));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
export function MethodSignature({ decl }) {
|
|
84
|
-
const Lang = useLanguageComponents();
|
|
85
|
-
const { Join } = useComponents();
|
|
86
|
-
const params = decl.args.map((param, i) => (_jsx(React.Fragment, { children: _jsx("span", { className: style.TextIdentifier, children: param.ident }) }, i)));
|
|
87
|
-
return (_jsx("div", { className: style.MethodSignature, children: _jsxs("span", { className: style.SignatureTitle, children: [_jsx("span", { className: style.SignatureQualified, children: _jsx("span", { className: style.TextIdentifier, children: decl.qualified?.slice(0, -decl.ident.length) }) }), _jsx("span", { className: style.SignatureName, children: _jsx("span", { className: style.TextIdentifier, children: decl.ident }) }), _jsxs("span", { className: style.MethodSignature, children: [_jsx("span", { className: style.SignatureParen, children: '(' }), _jsx("span", { className: style.SignatureParams, children: _jsx(Join, { items: params, children: _jsx("span", { className: style.TextOperator, children: ', ' }) }) }), _jsx("span", { className: style.SignatureParen, children: ')' }), ' -> ', decl.returns ? _jsx(Lang.Type, { type: decl.returns }) : 'void'] })] }) }));
|
|
88
|
-
}
|
|
89
|
-
export function Property({ decl, children }) {
|
|
90
|
-
const Lang = useLanguageComponents();
|
|
91
|
-
switch (decl.kind) {
|
|
92
|
-
case 'RubyDeclProperty':
|
|
93
|
-
return children({
|
|
94
|
-
name: decl.ident,
|
|
95
|
-
typeName: _jsx(Lang.TypeName, { type: decl.type }),
|
|
96
|
-
type: decl.type.kind in ComplexTypes && _jsx(Lang.Type, { type: decl.type }),
|
|
97
|
-
});
|
|
98
|
-
case 'RubyDeclTypeAlias':
|
|
99
|
-
return children({
|
|
100
|
-
name: decl.ident,
|
|
101
|
-
typeName: 'alias',
|
|
102
|
-
type: _jsx(Lang.Type, { type: decl.type }),
|
|
103
|
-
});
|
|
104
|
-
case 'RubyDeclReference':
|
|
105
|
-
return children({ type: _jsx(Lang.Type, { type: decl.type }) });
|
|
106
|
-
case 'RubyDeclClass':
|
|
107
|
-
return children({ name: decl.ident, typeName: 'class' });
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
export function Declaration({ decl }) {
|
|
111
|
-
const Lang = useLanguageComponents();
|
|
112
|
-
if (!decl)
|
|
113
|
-
return;
|
|
114
|
-
switch (decl.kind) {
|
|
115
|
-
case 'RubyDeclProperty':
|
|
116
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { className: style.TypePropertyName, children: _jsx("span", { className: style.TextIdentifier, children: decl.ident }) }), _jsx("span", { className: style.TextPunctuation, children: ": " }), _jsx(Lang.Type, { type: decl.type })] }));
|
|
117
|
-
case 'RubyDeclTypeAlias':
|
|
118
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { className: style.TextIdentifier, children: decl.ident }), _jsx("span", { className: style.TextOperator, children: " = " }), _jsx(Lang.Type, { type: decl.type })] }));
|
|
119
|
-
case 'RubyDeclClass':
|
|
120
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { className: style.TextKeyword, children: "class " }), _jsx("span", { className: style.TextIdentifier, children: decl.ident }), _jsx(TypePreview, { path: decl.stainlessPath })] }));
|
|
121
|
-
case 'RubyDeclReference':
|
|
122
|
-
return _jsx(Lang.Type, { type: decl.type });
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
//# sourceMappingURL=ruby.js.map
|
|
1
|
+
import "../component-generics-DzI21jRn.js";
|
|
2
|
+
import "../docs-Dh8kE1va.js";
|
|
3
|
+
import "../navigation-aoYZ_tl4.js";
|
|
4
|
+
import "../markdown-BXfX1D7C.js";
|
|
5
|
+
import "../routing-DQjbRxdJ.js";
|
|
6
|
+
import "../style-rYbbxIR_.js";
|
|
7
|
+
import "../use-components-D9E85p5x.js";
|
|
8
|
+
import { D as Property, E as MethodSignature, O as Type, T as Declaration, k as TypeName } from "../contexts-DRxRO-xO.js";
|
|
9
|
+
import "../icons-DdKM-01E.js";
|
|
10
|
+
import "../utils-CJfFBNgT.js";
|
|
11
|
+
import "../dropdown-DtgAi6lb.js";
|
|
12
|
+
import "../md-Dg8aOyMA.js";
|
|
13
|
+
import "../utils-BHwvUDKn.js";
|
|
14
|
+
import "../types-DFN4M1Sp.js";
|
|
15
|
+
|
|
16
|
+
export { Declaration, MethodSignature, Property, Type, TypeName };
|
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
decl: TSAST.TSDeclaration;
|
|
15
|
-
children?: PropertyFn;
|
|
16
|
-
};
|
|
17
|
-
export declare function Property({ decl, children }: PropertyProps): React.ReactNode;
|
|
18
|
-
export type DeclarationProps = {
|
|
19
|
-
decl: TSAST.TSDeclaration;
|
|
20
|
-
};
|
|
21
|
-
export declare function Declaration({ decl }: DeclarationProps): import("react/jsx-runtime").JSX.Element | undefined;
|
|
22
|
-
export {};
|
|
1
|
+
import "../breadcrumbs-Z-hEqjcp.js";
|
|
2
|
+
import "../dropdown-B7VyGMOw.js";
|
|
3
|
+
import "../method-DpsVuzZW.js";
|
|
4
|
+
import "../primitives-DWz23_Ub.js";
|
|
5
|
+
import "../properties-CF71V58d.js";
|
|
6
|
+
import "../routing-qc0V00-j.js";
|
|
7
|
+
import "../sdk-Zg3Rggk3.js";
|
|
8
|
+
import "../snippets-EUzM4fRO.js";
|
|
9
|
+
import "../overview-C8e-6jGr.js";
|
|
10
|
+
import "../sidebar-C8KirYjg.js";
|
|
11
|
+
import "../index-YnpUtXLB.js";
|
|
12
|
+
import { $ as Declaration, at as Type, et as DeclarationProps, it as PropertyProps, nt as MethodSignatureProps, ot as TypeName, rt as Property, tt as MethodSignature } from "../index-AicgPYKB.js";
|
|
13
|
+
export { Declaration, DeclarationProps, MethodSignature, MethodSignatureProps, Property, PropertyProps, Type, TypeName };
|
|
@@ -1,134 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
function Identifier({ name, optional }) {
|
|
19
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { className: style.TextIdentifier, children: /^[_a-zA-Z][_a-zA-Z0-9]*$/.test(name) ? name : JSON.stringify(name) }), optional && _jsx("span", { className: style.TextPunctuation, children: "?" })] }));
|
|
20
|
-
}
|
|
21
|
-
function TypeParams({ params }) {
|
|
22
|
-
const Lang = useLanguageComponents();
|
|
23
|
-
const { Join } = useComponents();
|
|
24
|
-
if (!params?.length)
|
|
25
|
-
return null;
|
|
26
|
-
const typeParams = params?.map((param, key) => param.constraint ? (_jsxs(React.Fragment, { children: [_jsx("span", { className: style.TypeReference, children: param.name }), _jsx("span", { className: style.TextKeyword, children: "extends " }), _jsx(Lang.Type, { type: param.constraint })] }, key)) : (_jsx(React.Fragment, { children: "param.name" }, key)));
|
|
27
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { className: style.TypeBracket, children: '<' }), _jsx(Join, { items: typeParams, limit: 3, children: _jsx("span", { className: style.TextOperator, children: ", " }) }), _jsx("span", { className: style.TypeBracket, children: '>' })] }));
|
|
28
|
-
}
|
|
29
|
-
function TypePreview({ path }) {
|
|
30
|
-
const spec = useSpec();
|
|
31
|
-
const language = useLanguage();
|
|
32
|
-
const decl = useDeclaration(path);
|
|
33
|
-
const { Join } = useComponents();
|
|
34
|
-
if (!(decl && 'children' in decl && decl.children.length > 0) || decl['type']?.['kind'] === 'TSTypeUnion')
|
|
35
|
-
return;
|
|
36
|
-
const items = decl.children.map((prop, key) => (_jsx("span", { className: style.TypePropertyName, children: _jsx("span", { className: style.TextIdentifier, children: spec?.decls?.[language]?.[prop]?.['key'] }) }, key)));
|
|
37
|
-
return (_jsxs("span", { className: style.TypePreview, "data-stldocs-type-preview": "properties", children: [_jsx("span", { className: style.TypeBrace, children: ' {' }), _jsxs("span", { className: style.TypePreviewContent, children: [' ', _jsx(Join, { items: items, limit: 3, children: _jsx("span", { className: style.TextOperator, children: ", " }) }), ' '] }), _jsx("span", { className: style.TypeBrace, children: '} ' })] }));
|
|
38
|
-
}
|
|
39
|
-
export function TypeName({ type }) {
|
|
40
|
-
const Lang = useLanguageComponents();
|
|
41
|
-
return ComplexTypes[type.kind] ?? _jsx(Lang.Type, { type: type });
|
|
42
|
-
}
|
|
43
|
-
export function Type({ type }) {
|
|
44
|
-
const Lang = useLanguageComponents();
|
|
45
|
-
const { Join, SDKReference } = useComponents();
|
|
46
|
-
switch (type.kind) {
|
|
47
|
-
case 'TSTypeUnknown':
|
|
48
|
-
case 'TSTypeUndefined':
|
|
49
|
-
case 'TSTypeNever':
|
|
50
|
-
case 'TSTypeVoid':
|
|
51
|
-
case 'TSTypeNull':
|
|
52
|
-
case 'TSTypeAny':
|
|
53
|
-
case 'TSTypeBoolean':
|
|
54
|
-
case 'TSTypeNumber':
|
|
55
|
-
return (_jsx("span", { className: style.Type, children: _jsx("span", { className: style.TypeKeyword, children: type.kind.slice(6).toLowerCase() }) }));
|
|
56
|
-
case 'TSTypeString':
|
|
57
|
-
return (_jsx("span", { className: style.Type, children: _jsx("span", { className: style.TypeString, children: "string" }) }));
|
|
58
|
-
case 'TSTypeLiteral':
|
|
59
|
-
return (_jsx("span", { className: style.Type, children: _jsx("span", { className: constStyle[typeof type.literal], children: JSON.stringify(type.literal) }) }));
|
|
60
|
-
case 'TSTypeArray': {
|
|
61
|
-
return (_jsxs("span", { className: style.Type, children: [_jsx("span", { className: style.TypeArray, children: 'Array<' }), _jsx(Lang.Type, { type: type.elementType }), _jsx("span", { className: style.TypeArray, children: '>' })] }));
|
|
62
|
-
}
|
|
63
|
-
case 'TSTypeReference': {
|
|
64
|
-
const name = type.ident.split('.').at(-1);
|
|
65
|
-
const params = type.typeParameters?.map((param, key) => _jsx(Lang.Type, { type: param }, key));
|
|
66
|
-
return (_jsxs("span", { className: style.Type, children: [_jsx(SDKReference, { stainlessPath: type.$ref, children: name }), params && params.length > 0 && (_jsxs(_Fragment, { children: [_jsx("span", { className: style.TypeBracket, children: '<' }), _jsx(Join, { items: params, limit: 3, children: _jsx("span", { className: style.TextOperator, children: ", " }) }), _jsx("span", { className: style.TypeBracket, children: '>' })] })), _jsx(TypePreview, { path: type.$ref })] }));
|
|
67
|
-
}
|
|
68
|
-
case 'TSTypeIntersection':
|
|
69
|
-
case 'TSTypeUnion': {
|
|
70
|
-
const items = type.types.map((t, key) => _jsx(Lang.Type, { type: t }, key));
|
|
71
|
-
const delimiter = type.kind === 'TSTypeUnion' ? '|' : '&';
|
|
72
|
-
return (_jsx("span", { className: style.Type, children: _jsx("span", { className: style.TypePreview, "data-stldocs-type-preview": "union", children: _jsx("span", { className: style.TypePreviewContent, children: _jsx(Join, { items: items, limit: 3, children: _jsxs("span", { className: style.TextOperator, children: [" ", delimiter, " "] }) }) }) }) }));
|
|
73
|
-
}
|
|
74
|
-
case 'TSTypeObject':
|
|
75
|
-
case 'TSTypeInterface': {
|
|
76
|
-
const extend = type.kind === 'TSTypeObject'
|
|
77
|
-
? null
|
|
78
|
-
: type.extends?.map((ref, key) => _jsx(Lang.Type, { type: ref }, key));
|
|
79
|
-
const items = type.members.map((prop, key) => (_jsxs(React.Fragment, { children: [_jsx("span", { className: style.TypePropertyName, children: _jsx(Identifier, { name: prop.ident, optional: prop.optional }) }), _jsx("span", { className: style.TextPunctuation, children: ": " }), _jsx(Lang.Type, { type: prop.type })] }, key)));
|
|
80
|
-
return (_jsxs("span", { className: style.Type, children: [extend?.length && (_jsxs(_Fragment, { children: [_jsx("span", { className: style.TypeKeyword, children: " extends " }), _jsx(Join, { items: extend, limit: 3, children: _jsx("span", { className: style.TextOperator, children: ", " }) })] })), _jsxs("span", { className: style.TypePreview, "data-stldocs-type-preview": "properties", children: [_jsx("span", { className: style.TypeBrace, children: '{ ' }), _jsx("span", { className: style.TypePreviewContent, children: _jsx(Join, { items: items, limit: 3, children: _jsx("span", { className: style.TextOperator, children: ", " }) }) }), _jsx("span", { className: style.TypeBrace, children: '} ' })] })] }));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
export function MethodSignature({ decl }) {
|
|
85
|
-
const Lang = useLanguageComponents();
|
|
86
|
-
const { Join, Tooltip } = useComponents();
|
|
87
|
-
const params = decl.signature.parameters.map((param, i) => (_jsxs(React.Fragment, { children: [_jsx(Tooltip, { content: _jsx(Lang.Type, { type: param.type }), children: _jsx("span", { className: style.TextIdentifier, children: param.ident }) }), param.optional && _jsx("span", { className: style.TextPunctuation, children: "?" })] }, i)));
|
|
88
|
-
return (_jsx("div", { className: style.MethodSignature, children: _jsxs("span", { className: style.SignatureTitle, children: [decl.signature.async && _jsx("span", { className: style.TextKeyword, children: "async " }), _jsx("span", { className: style.SignatureQualified, children: _jsx("span", { className: style.TextIdentifier, children: decl.qualified?.slice(0, -decl.ident.length) }) }), _jsx("span", { className: style.SignatureName, children: _jsx("span", { className: style.TextIdentifier, children: decl.ident }) }), _jsxs("span", { className: style.MethodSignature, children: [decl.signature.typeParameters && _jsx(TypeParams, { params: decl.signature.typeParameters }), _jsx("span", { className: style.SignatureParen, children: '(' }), _jsx("span", { className: style.SignatureParams, children: _jsx(Join, { items: params, children: _jsx("span", { className: style.TextOperator, children: ', ' }) }) }), _jsx("span", { className: style.SignatureParen, children: ')' }), decl.signature.returns && (_jsxs(_Fragment, { children: [_jsx("span", { className: style.TextPunctuation, children: ": " }), _jsx(Lang.Type, { type: decl.signature.returns })] }))] })] }) }));
|
|
89
|
-
}
|
|
90
|
-
export function Property({ decl, children }) {
|
|
91
|
-
const Lang = useLanguageComponents();
|
|
92
|
-
if (!decl)
|
|
93
|
-
return;
|
|
94
|
-
switch (decl.kind) {
|
|
95
|
-
case 'TSDeclProperty':
|
|
96
|
-
return children({
|
|
97
|
-
name: decl.key,
|
|
98
|
-
typeName: _jsx(Lang.TypeName, { type: decl.type }),
|
|
99
|
-
type: decl.type.kind in ComplexTypes && _jsx(Lang.Type, { type: decl.type }),
|
|
100
|
-
});
|
|
101
|
-
case 'TSDeclTypeAlias':
|
|
102
|
-
return children({
|
|
103
|
-
name: decl.ident,
|
|
104
|
-
typeName: 'alias',
|
|
105
|
-
type: _jsx(Lang.Type, { type: decl.type }),
|
|
106
|
-
});
|
|
107
|
-
case 'TSDeclReference':
|
|
108
|
-
return children({ type: _jsx(Lang.Type, { type: decl.type }) });
|
|
109
|
-
case 'TSDeclInterface':
|
|
110
|
-
return children({
|
|
111
|
-
type: (_jsxs(_Fragment, { children: [_jsx("span", { className: style.TextIdentifier, children: decl.ident }), decl.typeParameters && _jsx(TypeParams, { params: decl.typeParameters }), decl.extends?.flatMap((t, key) => (_jsxs(React.Fragment, { children: [_jsx("span", { className: style.TextKeyword, children: " extends " }), _jsx(Lang.Type, { type: t })] }, `extends:${key}`)))] })),
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
export function Declaration({ decl }) {
|
|
116
|
-
const Lang = useLanguageComponents();
|
|
117
|
-
if (!decl)
|
|
118
|
-
return;
|
|
119
|
-
switch (decl.kind) {
|
|
120
|
-
case 'TSDeclProperty':
|
|
121
|
-
return (_jsxs(_Fragment, { children: [decl.declare && _jsx("span", { className: style.TextKeyword, children: "declare " }), _jsx("span", { className: style.TypePropertyName, children: _jsx(Identifier, { name: decl.key, optional: decl.optional }) }), _jsx("span", { className: style.TextPunctuation, children: ": " }), _jsx(Lang.Type, { type: decl.type })] }));
|
|
122
|
-
case 'TSDeclFunction':
|
|
123
|
-
return _jsx(Lang.MethodSignature, { decl: decl });
|
|
124
|
-
case 'TSDeclTypeAlias':
|
|
125
|
-
return (_jsxs(_Fragment, { children: [_jsx(Identifier, { name: decl.ident }), _jsx(TypeParams, { params: decl.typeParameters }), _jsx("span", { className: style.TextOperator, children: " = " }), _jsx(Lang.Type, { type: decl.type })] }));
|
|
126
|
-
case 'TSDeclReference':
|
|
127
|
-
return _jsx(Lang.Type, { type: decl.type });
|
|
128
|
-
case 'TSDeclInterface':
|
|
129
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { className: style.TextIdentifier, children: decl.ident }), _jsx(TypeParams, { params: decl.typeParameters }), decl.extends?.map((t, index) => (_jsxs(React.Fragment, { children: [_jsx("span", { className: style.TextKeyword, children: " extends " }), _jsx(Lang.Type, { type: t })] }, index))), _jsx(TypePreview, { path: decl.stainlessPath })] }));
|
|
130
|
-
case 'TSDeclClass':
|
|
131
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { className: style.TextKeyword, children: "class " }), _jsx("span", { className: style.TextIdentifier, children: decl.ident }), _jsx(TypeParams, { params: decl.typeParameters }), decl.superClass ? (_jsxs(_Fragment, { children: [_jsx("span", { className: style.TextKeyword, children: " extends " }), _jsx(Lang.Type, { type: decl.superClass })] })) : null, decl.implements?.map((t, index) => (_jsxs(React.Fragment, { children: [_jsx("span", { className: style.TextKeyword, children: " implements " }), _jsx(Lang.Type, { type: t })] }, index)))] }));
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
//# sourceMappingURL=typescript.js.map
|
|
1
|
+
import "../component-generics-DzI21jRn.js";
|
|
2
|
+
import "../docs-Dh8kE1va.js";
|
|
3
|
+
import "../navigation-aoYZ_tl4.js";
|
|
4
|
+
import "../markdown-BXfX1D7C.js";
|
|
5
|
+
import "../routing-DQjbRxdJ.js";
|
|
6
|
+
import "../style-rYbbxIR_.js";
|
|
7
|
+
import "../use-components-D9E85p5x.js";
|
|
8
|
+
import { $ as TypeName, Q as Type, X as MethodSignature, Y as Declaration, Z as Property } from "../contexts-DRxRO-xO.js";
|
|
9
|
+
import "../icons-DdKM-01E.js";
|
|
10
|
+
import "../utils-CJfFBNgT.js";
|
|
11
|
+
import "../dropdown-DtgAi6lb.js";
|
|
12
|
+
import "../md-Dg8aOyMA.js";
|
|
13
|
+
import "../utils-BHwvUDKn.js";
|
|
14
|
+
import "../types-DFN4M1Sp.js";
|
|
15
|
+
|
|
16
|
+
export { Declaration, MethodSignature, Property, Type, TypeName };
|
package/dist/markdown/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import "../routing-qc0V00-j.js";
|
|
2
|
+
import "../sdk-Zg3Rggk3.js";
|
|
3
|
+
import { t as EnvironmentType } from "../utils-DQhEbvUC.js";
|
|
4
|
+
import { Node } from "@markdoc/markdoc";
|
|
5
|
+
|
|
6
|
+
//#region src/markdown/index.d.ts
|
|
7
|
+
declare function declaration(env: EnvironmentType, decl: SDKJSON.DeclarationNode): Node;
|
|
8
|
+
declare function render(env: EnvironmentType, node: SDKJSON.Resource | SDKJSON.Method | SDKJSON.Model): any;
|
|
9
|
+
declare function renderMarkdown(env: EnvironmentType, node: SDKJSON.Resource | SDKJSON.Method | SDKJSON.Model): string;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { declaration, render, renderMarkdown };
|
package/dist/markdown/index.js
CHANGED
|
@@ -1,80 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if ('docstring' in decl && decl.docstring)
|
|
18
|
-
item.children.push(...md.parse(decl.docstring));
|
|
19
|
-
if (hasChildren && showModelProps && !nesting.includes(path))
|
|
20
|
-
item.push(renderChildren(env, decl.children, [...nesting, path]));
|
|
21
|
-
return item;
|
|
22
|
-
}
|
|
23
|
-
function renderMethod(env, method) {
|
|
24
|
-
const decl = getDecl(env, method.stainlessPath);
|
|
25
|
-
if (!decl)
|
|
26
|
-
return [
|
|
27
|
-
md.paragraph(md.text('The method '), md.code(method.name), md.text(' is not available in this language.')),
|
|
28
|
-
];
|
|
29
|
-
const signature = printer.methodSignature(env.language, decl);
|
|
30
|
-
const [httpMethod, endpoint] = method.endpoint.split(' ');
|
|
31
|
-
const output = [
|
|
32
|
-
md.heading(2, method.title),
|
|
33
|
-
env.language === 'http' ? null : md.paragraph(md.code(stripMarkup(signature))),
|
|
34
|
-
md.paragraph(md.strong(md.text(httpMethod)), md.text(' '), md.code(endpoint)),
|
|
35
|
-
];
|
|
36
|
-
if (method.description)
|
|
37
|
-
output.push(...md.parse(method.description));
|
|
38
|
-
if ('paramsChildren' in decl && Array.isArray(decl.paramsChildren) && decl.paramsChildren.length > 0)
|
|
39
|
-
output.push(md.heading(3, 'Parameters'), renderChildren(env, decl.paramsChildren));
|
|
40
|
-
if ('responseChildren' in decl && decl.responseChildren.length > 0)
|
|
41
|
-
output.push(md.heading(3, 'Returns'), renderChildren(env, decl.responseChildren));
|
|
42
|
-
const snippet = getSnippet(env, method.stainlessPath);
|
|
43
|
-
if (snippet)
|
|
44
|
-
output.push(md.heading(3, 'Example'), md.fence(env.language, snippet));
|
|
45
|
-
return output;
|
|
46
|
-
}
|
|
47
|
-
function renderModel(env, model) {
|
|
48
|
-
return [md.heading(3, model.title), md.list(renderDecl(env, `${model.stainlessPath} > (schema)`))];
|
|
49
|
-
}
|
|
50
|
-
function renderResource(env, resource) {
|
|
51
|
-
const methods = Object.values(resource.methods)
|
|
52
|
-
.filter((method) => getDecl(env, method.stainlessPath))
|
|
53
|
-
.flatMap((method) => renderMethod(env, method));
|
|
54
|
-
const models = Object.values(resource.models)
|
|
55
|
-
.filter((model) => getDecl(env, `${model.stainlessPath} > (schema)`))
|
|
56
|
-
.flatMap((model) => renderModel(env, model));
|
|
57
|
-
const doc = [md.heading(1, resource.title), ...methods];
|
|
58
|
-
if (models.length > 0)
|
|
59
|
-
doc.push(md.heading(2, 'Domain Types'), ...models);
|
|
60
|
-
if (!env.options.renderNestedResources)
|
|
61
|
-
return doc;
|
|
62
|
-
const children = Object.values(resource.subresources).map((resource) => renderResource(env, resource));
|
|
63
|
-
return [...doc, ...children];
|
|
64
|
-
}
|
|
65
|
-
export function render(env, node) {
|
|
66
|
-
switch (node.kind) {
|
|
67
|
-
case 'resource':
|
|
68
|
-
return renderResource(env, node);
|
|
69
|
-
case 'http_method':
|
|
70
|
-
return renderMethod(env, node);
|
|
71
|
-
case 'model':
|
|
72
|
-
return renderModel(env, node);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
export function renderMarkdown(env, node) {
|
|
76
|
-
const content = render(env, node);
|
|
77
|
-
const doc = new Markdoc.Ast.Node('document', {}, content);
|
|
78
|
-
return Markdoc.format(doc);
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import "../component-generics-DzI21jRn.js";
|
|
2
|
+
import "../docs-Dh8kE1va.js";
|
|
3
|
+
import "../navigation-aoYZ_tl4.js";
|
|
4
|
+
import "../markdown-BXfX1D7C.js";
|
|
5
|
+
import "../routing-DQjbRxdJ.js";
|
|
6
|
+
import "../style-rYbbxIR_.js";
|
|
7
|
+
import "../use-components-D9E85p5x.js";
|
|
8
|
+
import { d as render, f as renderMarkdown, u as declaration } from "../contexts-DRxRO-xO.js";
|
|
9
|
+
import "../icons-DdKM-01E.js";
|
|
10
|
+
import "../utils-CJfFBNgT.js";
|
|
11
|
+
import "../dropdown-DtgAi6lb.js";
|
|
12
|
+
import "../md-Dg8aOyMA.js";
|
|
13
|
+
import "../utils-BHwvUDKn.js";
|
|
14
|
+
import "../types-DFN4M1Sp.js";
|
|
15
|
+
|
|
16
|
+
export { declaration, render, renderMarkdown };
|
package/dist/markdown/md.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 };
|
package/dist/markdown/md.js
CHANGED
|
@@ -1,34 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return new Markdoc.Ast.Node('heading', { level }, [content]);
|
|
5
|
-
}
|
|
6
|
-
export function text(content) {
|
|
7
|
-
return new Markdoc.Ast.Node('text', { content });
|
|
8
|
-
}
|
|
9
|
-
export function code(content) {
|
|
10
|
-
return new Markdoc.Ast.Node('code', { content });
|
|
11
|
-
}
|
|
12
|
-
export function paragraph(...children) {
|
|
13
|
-
const inline = new Markdoc.Ast.Node('inline', {}, children);
|
|
14
|
-
return new Markdoc.Ast.Node('paragraph', {}, [inline]);
|
|
15
|
-
}
|
|
16
|
-
export function list(...children) {
|
|
17
|
-
return new Markdoc.Ast.Node('list', { ordered: false }, children);
|
|
18
|
-
}
|
|
19
|
-
export function item(...children) {
|
|
20
|
-
return new Markdoc.Ast.Node('item', {}, children);
|
|
21
|
-
}
|
|
22
|
-
export function strong(...children) {
|
|
23
|
-
return new Markdoc.Ast.Node('strong', {}, children);
|
|
24
|
-
}
|
|
25
|
-
export function inline(...children) {
|
|
26
|
-
return new Markdoc.Ast.Node('inline', {}, children);
|
|
27
|
-
}
|
|
28
|
-
export function fence(language, content) {
|
|
29
|
-
return new Markdoc.Ast.Node('fence', { language, content });
|
|
30
|
-
}
|
|
31
|
-
export function parse(content) {
|
|
32
|
-
return Markdoc.parse(content).children;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=md.js.map
|
|
1
|
+
import { a as item, c as parse, i as inline, l as strong, n as fence, o as list, r as heading, s as paragraph, t as code, u as text } from "../md-Dg8aOyMA.js";
|
|
2
|
+
|
|
3
|
+
export { code, fence, heading, inline, item, list, paragraph, parse, strong, text };
|
package/dist/markdown/utils.d.ts
CHANGED
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
export
|
|
5
|
-
spec: SDKJSON.Spec;
|
|
6
|
-
language: DocsLanguage;
|
|
7
|
-
transforms?: {
|
|
8
|
-
transformRequestSnippet?: TransformRequestSnippetFn;
|
|
9
|
-
};
|
|
10
|
-
options: {
|
|
11
|
-
renderNestedResources?: boolean;
|
|
12
|
-
includeModelProperties?: boolean;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export declare function getDecl(env: EnvironmentType, path: string): any;
|
|
16
|
-
export declare function getSnippet(env: EnvironmentType, path: string): any;
|
|
17
|
-
export declare function stripMarkup(content: string): string;
|
|
1
|
+
import "../routing-qc0V00-j.js";
|
|
2
|
+
import "../sdk-Zg3Rggk3.js";
|
|
3
|
+
import { i as stripMarkup, n as getDecl, r as getSnippet, t as EnvironmentType } from "../utils-DQhEbvUC.js";
|
|
4
|
+
export { EnvironmentType, getDecl, getSnippet, stripMarkup };
|
package/dist/markdown/utils.js
CHANGED
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (decl?.kind?.endsWith('Reference')) {
|
|
5
|
-
const refId = decl['type']['$ref'];
|
|
6
|
-
if (refId === path)
|
|
7
|
-
return decl;
|
|
8
|
-
if (refId)
|
|
9
|
-
return getDecl(env, refId);
|
|
10
|
-
}
|
|
11
|
-
return decl;
|
|
12
|
-
}
|
|
13
|
-
export function getSnippet(env, path) {
|
|
14
|
-
let snippet = env.spec?.snippets?.[`${env.language}.default`]?.[path];
|
|
15
|
-
if (typeof snippet === 'string' && env.transforms?.transformRequestSnippet) {
|
|
16
|
-
snippet = env.transforms.transformRequestSnippet({ snippet, language: env.language });
|
|
17
|
-
}
|
|
18
|
-
return snippet;
|
|
19
|
-
}
|
|
20
|
-
export function stripMarkup(content) {
|
|
21
|
-
let output = '';
|
|
22
|
-
const parser = new Parser({
|
|
23
|
-
ontext(content) {
|
|
24
|
-
output += content;
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
parser.parseComplete(content);
|
|
28
|
-
return output;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=utils.js.map
|
|
1
|
+
import { n as getSnippet, r as stripMarkup, t as getDecl } from "../utils-BHwvUDKn.js";
|
|
2
|
+
|
|
3
|
+
export { getDecl, getSnippet, stripMarkup };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { a as useLanguage } from "./docs-Dh8kE1va.js";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/contexts/markdown.tsx
|
|
6
|
+
const HighlightLanguageMappings = {
|
|
7
|
+
node: "typescript",
|
|
8
|
+
http: "bash"
|
|
9
|
+
};
|
|
10
|
+
const MarkdownContext = React$1.createContext({
|
|
11
|
+
highlight: (content) => content,
|
|
12
|
+
render: (content) => content
|
|
13
|
+
});
|
|
14
|
+
const useMarkdownContext = () => React$1.useContext(MarkdownContext);
|
|
15
|
+
function useRenderMarkdown(content) {
|
|
16
|
+
const { render } = React$1.useContext(MarkdownContext);
|
|
17
|
+
return React$1.useMemo(() => content ? render(content) : void 0, [content, render]);
|
|
18
|
+
}
|
|
19
|
+
function useHighlight(content, language) {
|
|
20
|
+
const { highlight } = React$1.useContext(MarkdownContext);
|
|
21
|
+
const lang = language ?? useLanguage();
|
|
22
|
+
return React$1.useMemo(() => {
|
|
23
|
+
const rendered = highlight(content, HighlightLanguageMappings[lang] ?? lang);
|
|
24
|
+
return typeof rendered === "string" ? rendered : React$1.use(rendered);
|
|
25
|
+
}, [
|
|
26
|
+
content,
|
|
27
|
+
language,
|
|
28
|
+
highlight
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
function MarkdownProvider({ render, highlight, children }) {
|
|
32
|
+
return /* @__PURE__ */ jsx(MarkdownContext.Provider, {
|
|
33
|
+
value: {
|
|
34
|
+
render,
|
|
35
|
+
highlight
|
|
36
|
+
},
|
|
37
|
+
children
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { useRenderMarkdown as a, useMarkdownContext as i, MarkdownProvider as n, useHighlight as r, MarkdownContext as t };
|