@stainless-api/docs 0.1.0-beta.85 → 0.1.0-beta.87
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/CHANGELOG.md +27 -0
- package/package.json +6 -6
- package/plugin/components/SDKSelect.astro +0 -1
- package/plugin/components/SnippetCode.tsx +6 -1
- package/plugin/index.ts +3 -3
- package/plugin/routes/Docs.astro +4 -12
- package/plugin/routes/Overview.astro +9 -7
- package/stl-docs/components/sidebars/BaseSidebar.astro +3 -1
- package/stl-docs/components/sidebars/convertAstroSidebarToStl.tsx +46 -0
- package/styles/page.css +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @stainless-api/docs
|
|
2
2
|
|
|
3
|
+
## 0.1.0-beta.87
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b62eb05: improved support for webhooks and functions
|
|
8
|
+
- Updated dependencies [b62eb05]
|
|
9
|
+
- Updated dependencies [d42dd8f]
|
|
10
|
+
- @stainless-api/ui-primitives@0.1.0-beta.46
|
|
11
|
+
- @stainless-api/docs-ui@0.1.0-beta.65
|
|
12
|
+
- @stainless-api/docs-search@0.1.0-beta.18
|
|
13
|
+
|
|
14
|
+
## 0.1.0-beta.86
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- 7439be7: Adds Terraform rendering to docs
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- c8fb9b3: fix layout shift on api pages
|
|
23
|
+
- 3411ffe: Add underlying capabilities to the sidebar: collapsible/icon
|
|
24
|
+
- 509a074: bump astro & starlight for pagefind fix
|
|
25
|
+
- Updated dependencies [3411ffe]
|
|
26
|
+
- Updated dependencies [7439be7]
|
|
27
|
+
- @stainless-api/docs-ui@0.1.0-beta.64
|
|
28
|
+
- @stainless-api/docs-search@0.1.0-beta.17
|
|
29
|
+
|
|
3
30
|
## 0.1.0-beta.85
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stainless-api/docs",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.87",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"node": ">=18.17.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@astrojs/starlight": ">=0.37.
|
|
33
|
+
"@astrojs/starlight": ">=0.37.5",
|
|
34
34
|
"astro": ">=5.15.3",
|
|
35
35
|
"react": ">=19.0.0",
|
|
36
36
|
"react-dom": ">=19.0.0",
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"vite-plugin-prebundle-workers": "^0.2.0",
|
|
59
59
|
"web-worker": "^1.5.0",
|
|
60
60
|
"yaml": "^2.8.2",
|
|
61
|
-
"@stainless-api/docs-search": "0.1.0-beta.
|
|
62
|
-
"@stainless-api/docs-ui": "0.1.0-beta.
|
|
63
|
-
"@stainless-api/ui-primitives": "0.1.0-beta.
|
|
61
|
+
"@stainless-api/docs-search": "0.1.0-beta.18",
|
|
62
|
+
"@stainless-api/docs-ui": "0.1.0-beta.65",
|
|
63
|
+
"@stainless-api/ui-primitives": "0.1.0-beta.46"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@astrojs/check": "^0.9.6",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"vite": "^6.4.1",
|
|
76
76
|
"zod": "^4.3.5",
|
|
77
77
|
"@stainless/eslint-config": "0.1.0-beta.1",
|
|
78
|
-
"@stainless/sdk-json": "^0.1.0-beta.
|
|
78
|
+
"@stainless/sdk-json": "^0.1.0-beta.4"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"vendor-deps": "tsx scripts/vendor_deps.ts",
|
|
@@ -24,7 +24,6 @@ const spec = await cmsClient.getSpec();
|
|
|
24
24
|
// TODO: should not force unwrap this
|
|
25
25
|
const languages: DocsLanguage[] = spec.docs!.languages ?? ['http'];
|
|
26
26
|
const options = languages
|
|
27
|
-
.filter((language) => language !== 'terraform')
|
|
28
27
|
.filter((language) => !EXCLUDE_LANGUAGES.includes(language))
|
|
29
28
|
.map((value) => ({
|
|
30
29
|
value,
|
|
@@ -16,6 +16,7 @@ import { Button } from '@stainless-api/ui-primitives';
|
|
|
16
16
|
import { CopyIcon, PlayIcon } from 'lucide-react';
|
|
17
17
|
import React from 'react';
|
|
18
18
|
import { RequestBuilder } from './RequestBuilder';
|
|
19
|
+
import { Method } from '@stainless/sdk-json';
|
|
19
20
|
|
|
20
21
|
function PlaygroundIcon() {
|
|
21
22
|
return (
|
|
@@ -152,13 +153,17 @@ function useIsCollapsible({ signature }: { signature?: string }): boolean {
|
|
|
152
153
|
return Boolean(EXPERIMENTAL_COLLAPSIBLE_SNIPPETS && signature && language);
|
|
153
154
|
}
|
|
154
155
|
|
|
156
|
+
function isActualMethod(value: object): value is Method {
|
|
157
|
+
return 'kind' in value && value.kind === 'http_method';
|
|
158
|
+
}
|
|
159
|
+
|
|
155
160
|
export function SnippetContainer({ children, signature, method }: SnippetContainerProps) {
|
|
156
161
|
const isCollapsible = useIsCollapsible({ signature });
|
|
157
162
|
const className = clsx(
|
|
158
163
|
style.Snippet,
|
|
159
164
|
isCollapsible ? 'stl-snippet-collapsible' : 'stl-snippet-non-collapsible',
|
|
160
165
|
);
|
|
161
|
-
return EXPERIMENTAL_REQUEST_BUILDER ? (
|
|
166
|
+
return EXPERIMENTAL_REQUEST_BUILDER && isActualMethod(method) ? (
|
|
162
167
|
<RequestBuilder className={className} method={method}>
|
|
163
168
|
{children}
|
|
164
169
|
</RequestBuilder>
|
package/plugin/index.ts
CHANGED
|
@@ -149,9 +149,9 @@ async function stlStarlightAstroIntegration(
|
|
|
149
149
|
).json()) as SpecResp;
|
|
150
150
|
if (!spec || !auth) throw new Error('expected spec');
|
|
151
151
|
|
|
152
|
-
const langs = (spec.docs?.languages ?? ['http'])
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
const langs = (spec.docs?.languages ?? ['http']).filter(
|
|
153
|
+
(lang) => !pluginConfig.excludeLanguages?.includes(lang),
|
|
154
|
+
);
|
|
155
155
|
|
|
156
156
|
await buildPlaygrounds!({
|
|
157
157
|
spec,
|
package/plugin/routes/Docs.astro
CHANGED
|
@@ -66,7 +66,10 @@ if (props.kind === 'http_method' && props.stainlessPath) {
|
|
|
66
66
|
frontmatter={{
|
|
67
67
|
title: props.title,
|
|
68
68
|
pagefind: false,
|
|
69
|
-
tableOfContents:
|
|
69
|
+
tableOfContents:
|
|
70
|
+
props.kind === 'readme' || (props.kind === 'resource' && props.language !== 'terraform')
|
|
71
|
+
? { maxHeadingLevel: 6 }
|
|
72
|
+
: false,
|
|
70
73
|
}}
|
|
71
74
|
>
|
|
72
75
|
{
|
|
@@ -81,17 +84,6 @@ if (props.kind === 'http_method' && props.stainlessPath) {
|
|
|
81
84
|
contentPanelLayout={CONTENT_PANEL_LAYOUT}
|
|
82
85
|
transformRequestSnippet={MIDDLEWARE.transformRequestSnippet}
|
|
83
86
|
/>
|
|
84
|
-
|
|
85
|
-
{/* TODO: we should not set inline styles here? */}
|
|
86
|
-
<style
|
|
87
|
-
is:inline
|
|
88
|
-
set:text={`
|
|
89
|
-
|
|
90
|
-
[data-has-sidebar]:not([data-has-toc]) .sl-container {
|
|
91
|
-
max-width: 1428px;
|
|
92
|
-
}
|
|
93
|
-
`}
|
|
94
|
-
/>
|
|
95
87
|
</div>
|
|
96
88
|
) : (
|
|
97
89
|
<>
|
|
@@ -26,16 +26,18 @@ Astro.locals._stlStarlightPage = {
|
|
|
26
26
|
tableOfContents: false,
|
|
27
27
|
}}
|
|
28
28
|
>
|
|
29
|
-
<
|
|
29
|
+
<div class="stl-overview">
|
|
30
|
+
<h3>Libraries</h3>
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
<div class="stldocs-root language-blocks stl-ui-not-prose not-content">
|
|
33
|
+
<RenderLibraries metadata={metadata} />
|
|
34
|
+
</div>
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
<h3>API Overview</h3>
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
<div class="stldocs-root api-overview stl-ui-not-prose">
|
|
39
|
+
<RenderSpecOverview spec={spec} language="http" />
|
|
40
|
+
</div>
|
|
39
41
|
</div>
|
|
40
42
|
</StarlightPage>
|
|
41
43
|
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
import HeaderLinks from '../headers/HeaderLinks.astro';
|
|
3
3
|
import { SidebarWithComponents } from './SidebarWithComponents';
|
|
4
4
|
import SidebarPersister from '@astrojs/starlight/components/SidebarPersister.astro';
|
|
5
|
+
import { convertAstroSidebarToStl } from './convertAstroSidebarToStl';
|
|
5
6
|
|
|
6
7
|
const { sidebar } = Astro.locals.starlightRoute;
|
|
8
|
+
const stlSidebar = convertAstroSidebarToStl(sidebar);
|
|
7
9
|
---
|
|
8
10
|
|
|
9
11
|
<div class="stl-sidebar-header-links">
|
|
@@ -11,5 +13,5 @@ const { sidebar } = Astro.locals.starlightRoute;
|
|
|
11
13
|
</div>
|
|
12
14
|
<slot name="sdk-select" />
|
|
13
15
|
<SidebarPersister>
|
|
14
|
-
<SidebarWithComponents entries={
|
|
16
|
+
<SidebarWithComponents entries={stlSidebar} withStarlightRestoration />
|
|
15
17
|
</SidebarPersister>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { StlSidebarEntry } from '@stainless-api/docs-ui/components';
|
|
2
|
+
import { SidebarEntry } from '../pagination/util';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import { Badge, getHttpMethod } from '@stainless-api/ui-primitives';
|
|
5
|
+
import { FunctionIcon } from '@stainless-api/ui-primitives/icons';
|
|
6
|
+
|
|
7
|
+
export function convertAstroSidebarToStl(entries: SidebarEntry[]): StlSidebarEntry[] {
|
|
8
|
+
return entries.map((entry): StlSidebarEntry => {
|
|
9
|
+
if (entry.type === 'link') {
|
|
10
|
+
let icon: ReactNode | undefined;
|
|
11
|
+
|
|
12
|
+
const methodAttr = entry.attrs['data-stldocs-method'];
|
|
13
|
+
const httpMethod = getHttpMethod(methodAttr);
|
|
14
|
+
if (httpMethod) {
|
|
15
|
+
icon = <Badge.HTTP method={httpMethod} iconOnly size="sm" />;
|
|
16
|
+
}
|
|
17
|
+
// Support empty string as method to show generic "Function" badge
|
|
18
|
+
else if (methodAttr === '') {
|
|
19
|
+
icon = (
|
|
20
|
+
<Badge size="sm" icon={<FunctionIcon />} intent="info">
|
|
21
|
+
{''}
|
|
22
|
+
</Badge>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
type: 'link',
|
|
28
|
+
attrs: entry.attrs,
|
|
29
|
+
label: entry.label,
|
|
30
|
+
target: {
|
|
31
|
+
type: 'href',
|
|
32
|
+
href: entry.href,
|
|
33
|
+
},
|
|
34
|
+
isCurrent: entry.isCurrent,
|
|
35
|
+
icon,
|
|
36
|
+
};
|
|
37
|
+
} else {
|
|
38
|
+
return {
|
|
39
|
+
type: 'group',
|
|
40
|
+
label: entry.label,
|
|
41
|
+
collapsed: entry.collapsed,
|
|
42
|
+
entries: convertAstroSidebarToStl(entry.entries),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
package/styles/page.css
CHANGED
|
@@ -79,6 +79,14 @@
|
|
|
79
79
|
padding: 1rem 0 0 var(--stldocs-content-padding);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
[data-has-sidebar]:not([data-has-toc]) .sl-container {
|
|
83
|
+
max-width: 1428px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.stl-overview {
|
|
87
|
+
max-width: var(--sl-content-width);
|
|
88
|
+
}
|
|
89
|
+
|
|
82
90
|
@media (min-width: 50rem) {
|
|
83
91
|
:root[data-has-sidebar] {
|
|
84
92
|
--sl-content-inline-start: calc(var(--sl-sidebar-width) + 2rem);
|