@stainless-api/docs 0.1.0-beta.59 → 0.1.0-beta.60
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 +10 -0
- package/locals.d.ts +2 -0
- package/package.json +4 -4
- package/plugin/index.ts +1 -0
- package/plugin/routes/Docs.astro +1 -0
- package/stl-docs/components/AiChatIsland.tsx +10 -0
- package/stl-docs/components/PageFrame.astro +14 -0
- package/stl-docs/index.ts +34 -23
- package/stl-docs/loadStlDocsConfig.ts +2 -0
- package/styles/code.css +5 -0
- package/virtual-module.d.ts +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @stainless-api/docs
|
|
2
2
|
|
|
3
|
+
## 0.1.0-beta.60
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2d00f0d: compatibility with the first alpha version of docs-ai-chat
|
|
8
|
+
- Updated dependencies [2d00f0d]
|
|
9
|
+
- @stainless-api/docs-ui@0.1.0-beta.50
|
|
10
|
+
- @stainless-api/ui-primitives@0.1.0-beta.37
|
|
11
|
+
- @stainless-api/docs-search@0.1.0-beta.2
|
|
12
|
+
|
|
3
13
|
## 0.1.0-beta.59
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/locals.d.ts
CHANGED
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.60",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"vite-plugin-prebundle-workers": "^0.2.0",
|
|
53
53
|
"web-worker": "^1.5.0",
|
|
54
54
|
"yaml": "^2.8.2",
|
|
55
|
-
"@stainless-api/docs-ui": "0.1.0-beta.
|
|
56
|
-
"@stainless-api/docs-search": "0.1.0-beta.
|
|
57
|
-
"@stainless-api/ui-primitives": "0.1.0-beta.
|
|
55
|
+
"@stainless-api/docs-ui": "0.1.0-beta.50",
|
|
56
|
+
"@stainless-api/docs-search": "0.1.0-beta.2",
|
|
57
|
+
"@stainless-api/ui-primitives": "0.1.0-beta.37"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@astrojs/check": "^0.9.6",
|
package/plugin/index.ts
CHANGED
|
@@ -301,6 +301,7 @@ async function stlStarlightAstroIntegration(
|
|
|
301
301
|
PROPERTY_SETTINGS: pluginConfig.propertySettings,
|
|
302
302
|
ENABLE_CONTEXT_MENU: pluginConfig.contextMenu,
|
|
303
303
|
EXPERIMENTAL_PLAYGROUNDS: !!pluginConfig.experimentalPlaygrounds,
|
|
304
|
+
STAINLESS_PROJECT: version.stainlessProject,
|
|
304
305
|
} satisfies Omit<typeof StlStarlightVirtualModule, 'MIDDLEWARE'>),
|
|
305
306
|
vmMiddlewareExport,
|
|
306
307
|
].join('\n');
|
package/plugin/routes/Docs.astro
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DocsLanguage } from '@stainless-api/docs-ui/routing';
|
|
2
|
+
import AiChat from 'virtual:stl-docs/components/AiChat.tsx';
|
|
3
|
+
// right now loading AiChat without API reference plugin is unsupported
|
|
4
|
+
// because the AiChat is for talking about the SDKs
|
|
5
|
+
import { STAINLESS_PROJECT } from 'virtual:stl-starlight-virtual-module';
|
|
6
|
+
|
|
7
|
+
export default function AiChatIsland({ currentLanguage }: { currentLanguage: DocsLanguage | undefined }) {
|
|
8
|
+
if (!AiChat) throw new Error('AiChatIsland was rendered but could not load AiChat component');
|
|
9
|
+
return <AiChat projectId={STAINLESS_PROJECT} language={currentLanguage} />;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Default from '@astrojs/starlight/components/PageFrame.astro';
|
|
3
|
+
import AiChat from 'virtual:stl-docs/components/AiChat.tsx'; // conditionally resolves to null if ai chat module is not injected
|
|
4
|
+
import AiChatIsland from './AiChatIsland.tsx'; // entrypoint for client island can’t be a virtual module
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<Default>
|
|
8
|
+
<slot name="header" slot="header" />
|
|
9
|
+
<slot name="sidebar" slot="sidebar" />
|
|
10
|
+
|
|
11
|
+
<slot />
|
|
12
|
+
|
|
13
|
+
{!!AiChat && <AiChatIsland client:load currentLanguage={Astro.locals.language} />}
|
|
14
|
+
</Default>
|
package/stl-docs/index.ts
CHANGED
|
@@ -48,12 +48,16 @@ function stainlessDocsStarlightIntegration(config: NormalizedStainlessDocsConfig
|
|
|
48
48
|
|
|
49
49
|
type ComponentOverrides = StarlightConfigDefined['components'];
|
|
50
50
|
const componentOverrides: ComponentOverrides = {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
PageFrame: resolveSrcFile(COMPONENTS_FOLDER, './PageFrame.astro'),
|
|
52
|
+
|
|
53
53
|
Head: resolveSrcFile(COMPONENTS_FOLDER, './Head.astro'),
|
|
54
|
+
Header: resolveSrcFile(COMPONENTS_FOLDER, './Header.astro'),
|
|
54
55
|
ThemeSelect: resolveSrcFile(COMPONENTS_FOLDER, './ThemeSelect.astro'),
|
|
56
|
+
|
|
57
|
+
Sidebar: resolveSrcFile(COMPONENTS_FOLDER, './sidebars/BaseSidebar.astro'),
|
|
55
58
|
ContentPanel: resolveSrcFile(COMPONENTS_FOLDER, './content-panel/ContentPanel.astro'),
|
|
56
59
|
TableOfContents: resolveSrcFile(COMPONENTS_FOLDER, './TableOfContents.astro'),
|
|
60
|
+
|
|
57
61
|
PageTitle: resolveSrcFile(COMPONENTS_FOLDER, './PageTitle.astro'),
|
|
58
62
|
Pagination: resolveSrcFile(COMPONENTS_FOLDER, './pagination/Pagination.astro'),
|
|
59
63
|
};
|
|
@@ -144,17 +148,38 @@ function stainlessDocsIntegration(
|
|
|
144
148
|
config: NormalizedStainlessDocsConfig,
|
|
145
149
|
apiReferenceBasePath: string | null,
|
|
146
150
|
): AstroIntegration {
|
|
147
|
-
const
|
|
151
|
+
const virtualModules = new Map(
|
|
152
|
+
Object.entries({
|
|
153
|
+
'virtual:stl-docs-virtual-module': buildVirtualModuleString({
|
|
154
|
+
TABS: config.tabs,
|
|
155
|
+
SPLIT_TABS_ENABLED: config.splitTabsEnabled,
|
|
156
|
+
HEADER_LINKS: config.header.links,
|
|
157
|
+
HEADER_LAYOUT: config.header.layout,
|
|
158
|
+
ENABLE_CLIENT_ROUTER: config.enableClientRouter,
|
|
159
|
+
API_REFERENCE_BASE_PATH: apiReferenceBasePath,
|
|
160
|
+
ENABLE_PROSE_MARKDOWN_RENDERING: config.enableProseMarkdownRendering,
|
|
161
|
+
// TODO: do not duplicate this between both virtual modules
|
|
162
|
+
ENABLE_CONTEXT_MENU: config.contextMenu,
|
|
163
|
+
RENDER_PAGE_DESCRIPTIONS: config.renderPageDescriptions,
|
|
164
|
+
} satisfies typeof StlDocsVirtualModule),
|
|
165
|
+
|
|
166
|
+
'virtual:stl-docs/components/AiChat.tsx': config.aiChat
|
|
167
|
+
? `export { default } from ${JSON.stringify(config.aiChat.chatComponentPath)};`
|
|
168
|
+
: // export null when no AI chat component is provided
|
|
169
|
+
`export default null;`,
|
|
170
|
+
}),
|
|
171
|
+
);
|
|
172
|
+
|
|
148
173
|
// The '\0' prefix tells Vite “this is a virtual module” and prevents it from being resolved again.
|
|
149
|
-
const
|
|
174
|
+
const resolveVirtualModuleId = (id: string) => `\0${id}`;
|
|
150
175
|
let redirects: NormalizedRedirectConfig | null = null;
|
|
151
176
|
|
|
152
177
|
return {
|
|
153
178
|
name: 'stl-docs-astro',
|
|
154
179
|
hooks: {
|
|
155
180
|
'astro:config:setup': ({ updateConfig, command, config: astroConfig }) => {
|
|
156
|
-
//
|
|
157
|
-
//
|
|
181
|
+
// we only handle redirects for builds
|
|
182
|
+
// in dev, Astro handles them for us
|
|
158
183
|
if (command === 'build' && astroConfig.redirects) {
|
|
159
184
|
redirects = normalizeRedirects(astroConfig.redirects);
|
|
160
185
|
}
|
|
@@ -165,25 +190,11 @@ function stainlessDocsIntegration(
|
|
|
165
190
|
{
|
|
166
191
|
name: 'stl-docs-vite',
|
|
167
192
|
resolveId(id) {
|
|
168
|
-
if (id
|
|
169
|
-
return resolvedId;
|
|
170
|
-
}
|
|
193
|
+
if (virtualModules.has(id)) return resolveVirtualModuleId(id);
|
|
171
194
|
},
|
|
172
195
|
load(id) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
TABS: config.tabs,
|
|
176
|
-
SPLIT_TABS_ENABLED: config.splitTabsEnabled,
|
|
177
|
-
HEADER_LINKS: config.header.links,
|
|
178
|
-
HEADER_LAYOUT: config.header.layout,
|
|
179
|
-
ENABLE_CLIENT_ROUTER: config.enableClientRouter,
|
|
180
|
-
API_REFERENCE_BASE_PATH: apiReferenceBasePath,
|
|
181
|
-
ENABLE_PROSE_MARKDOWN_RENDERING: config.enableProseMarkdownRendering,
|
|
182
|
-
// TODO: do not duplicate this between both virtual modules
|
|
183
|
-
ENABLE_CONTEXT_MENU: config.contextMenu,
|
|
184
|
-
RENDER_PAGE_DESCRIPTIONS: config.renderPageDescriptions,
|
|
185
|
-
} satisfies typeof StlDocsVirtualModule);
|
|
186
|
-
}
|
|
196
|
+
const bare = id.replace(/^\0/, '');
|
|
197
|
+
if (virtualModules.has(bare)) return virtualModules.get(bare);
|
|
187
198
|
},
|
|
188
199
|
},
|
|
189
200
|
],
|
|
@@ -75,6 +75,7 @@ export type StainlessDocsUserConfig = {
|
|
|
75
75
|
* @default false
|
|
76
76
|
*/
|
|
77
77
|
disableProseMarkdownRendering?: boolean;
|
|
78
|
+
aiChat?: { chatComponentPath: string };
|
|
78
79
|
};
|
|
79
80
|
/**
|
|
80
81
|
* Whether to show the context menu with options like "Copy as Markdown" and "Open in ChatGPT".
|
|
@@ -166,6 +167,7 @@ function normalizeConfig(userConfig: StainlessDocsUserConfig) {
|
|
|
166
167
|
expressiveCode: userConfig.expressiveCode,
|
|
167
168
|
renderPageDescriptions: userConfig.renderPageDescriptions ?? true,
|
|
168
169
|
plugins: userConfig.plugins ?? [],
|
|
170
|
+
aiChat: userConfig.experimental?.aiChat,
|
|
169
171
|
};
|
|
170
172
|
|
|
171
173
|
return configWithDefaults;
|
package/styles/code.css
CHANGED
|
@@ -131,6 +131,11 @@
|
|
|
131
131
|
.astro-code,
|
|
132
132
|
.stldocs-snippet-response-pane {
|
|
133
133
|
background-color: var(--shiki-background, var(--stl-color-faint-background)) !important;
|
|
134
|
+
.shiki,
|
|
135
|
+
.astro-code,
|
|
136
|
+
.stldocs-snippet-response-pane {
|
|
137
|
+
background-color: transparent !important;
|
|
138
|
+
}
|
|
134
139
|
}
|
|
135
140
|
|
|
136
141
|
:root[data-theme='dark'] {
|
package/virtual-module.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ declare module 'virtual:stl-starlight-virtual-module' {
|
|
|
23
23
|
export const PROPERTY_SETTINGS: PropertySettingsType;
|
|
24
24
|
export const MIDDLEWARE: StlStarlightMiddleware;
|
|
25
25
|
export const ENABLE_CONTEXT_MENU: boolean;
|
|
26
|
+
export const STAINLESS_PROJECT: string;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
declare module 'virtual:stl-docs-virtual-module' {
|
|
@@ -50,3 +51,13 @@ declare module 'virtual:stl-docs-virtual-module' {
|
|
|
50
51
|
export const ENABLE_CONTEXT_MENU: boolean;
|
|
51
52
|
export const RENDER_PAGE_DESCRIPTIONS: boolean;
|
|
52
53
|
}
|
|
54
|
+
|
|
55
|
+
declare module 'virtual:stl-docs/components/AiChat.tsx' {
|
|
56
|
+
const AiChatComponent:
|
|
57
|
+
| import('react').ComponentType<{
|
|
58
|
+
projectId: string;
|
|
59
|
+
language: import('@stainless-api/docs-ui/routing').DocsLanguage | undefined;
|
|
60
|
+
}>
|
|
61
|
+
| null;
|
|
62
|
+
export default AiChatComponent;
|
|
63
|
+
}
|