@stainless-api/docs 0.1.0-beta.99 → 1.0.0-beta.140
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 +390 -0
- package/ambient.d.ts +6 -0
- package/eslint-suppressions.json +22 -6
- package/{eslint.config.js → eslint.config.ts} +1 -7
- package/package.json +57 -40
- package/plugin/buildAlgoliaIndex.ts +6 -12
- package/plugin/components/SDKSelect.astro +0 -6
- package/plugin/components/SnippetCode.tsx +6 -37
- package/plugin/components/search/SearchAlgolia.astro +1 -1
- package/plugin/components/search/SearchIsland.tsx +19 -13
- package/plugin/generateAPIReferenceLink.ts +0 -40
- package/plugin/globalJs/ai-dropdown-options.ts +22 -9
- package/plugin/globalJs/code-snippets.ts +5 -5
- package/plugin/globalJs/copy.ts +20 -91
- package/plugin/globalJs/navigation.ts +13 -13
- package/plugin/globalJs/summary-selection-tweak.ts +29 -0
- package/plugin/index.ts +107 -163
- package/plugin/loadPluginConfig.ts +49 -151
- package/plugin/markdown/highlighter.ts +100 -0
- package/plugin/markdown/index.ts +39 -0
- package/plugin/middlewareBuilder/stainlessMiddleware.d.ts +2 -0
- package/plugin/react/Routing.tsx +10 -244
- package/plugin/referencePlaceholderUtils.ts +1 -1
- package/plugin/replaceSidebarPlaceholderMiddleware.ts +1 -1
- package/plugin/routes/Docs.astro +3 -1
- package/plugin/routes/Overview.astro +14 -7
- package/plugin/routes/llms.ts +186 -0
- package/plugin/routes/markdown.ts +62 -13
- package/plugin/sidebar-utils/sidebar-builder.ts +38 -12
- package/plugin/specs/defaultSpecLoader.ts +192 -0
- package/plugin/specs/fetchSpecSSR.ts +1 -1
- package/plugin/specs/utils.ts +86 -0
- package/shared/conditionalIntegration.ts +28 -0
- package/shared/getProsePages.ts +6 -7
- package/shared/virtualModule.ts +1 -26
- package/stl-docs/aiChatExamples.ts +31 -0
- package/stl-docs/chat/docs-chat-handler.ts +17 -0
- package/stl-docs/chat/hook.ts +225 -0
- package/stl-docs/chat/schemas.ts +27 -0
- package/stl-docs/chat/ui/AiChat.module.css +591 -0
- package/stl-docs/chat/ui/AiChat.tsx +175 -0
- package/stl-docs/chat/ui/Trigger.tsx +154 -0
- package/stl-docs/chat/ui/components/ChatControls.tsx +51 -0
- package/stl-docs/chat/ui/components/ChatEmpty.tsx +42 -0
- package/stl-docs/chat/ui/components/ChatLog.tsx +93 -0
- package/stl-docs/chat/ui/components/ChatMessage.tsx +47 -0
- package/stl-docs/chat/ui/components/CodeBlock.tsx +33 -0
- package/stl-docs/chat/ui/components/MessageFeedback.tsx +106 -0
- package/stl-docs/chat/ui/components/Table.tsx +15 -0
- package/stl-docs/chat/ui/components/ToolCall.tsx +34 -0
- package/stl-docs/chat/ui/components/hljs-github.css +81 -0
- package/stl-docs/chat/ui/scroll-manager.ts +86 -0
- package/stl-docs/chat/ui/types.ts +45 -0
- package/stl-docs/components/AiChatIsland.tsx +10 -12
- package/stl-docs/components/ContentPanel.astro +9 -0
- package/stl-docs/components/Footer.astro +89 -0
- package/stl-docs/components/Header.astro +0 -5
- package/stl-docs/components/PageFrame.astro +23 -8
- package/stl-docs/components/PageSidebar.astro +11 -0
- package/stl-docs/components/StainlessLogo.svg +4 -0
- package/stl-docs/components/TwoColumnContent.astro +2 -0
- package/stl-docs/components/headers/DefaultHeader.astro +6 -8
- package/stl-docs/components/headers/StackedHeader.astro +5 -53
- package/stl-docs/components/mintlify-compat/Accordion.astro +2 -2
- package/stl-docs/components/mintlify-compat/AccordionGroup.astro +0 -4
- package/stl-docs/components/mintlify-compat/Columns.astro +2 -2
- package/stl-docs/components/mintlify-compat/Frame.astro +2 -2
- package/stl-docs/components/mintlify-compat/Tab.astro +2 -2
- package/stl-docs/components/mintlify-compat/callouts/Callout.astro +2 -2
- package/stl-docs/components/mintlify-compat/callouts/Check.astro +0 -4
- package/stl-docs/components/mintlify-compat/callouts/Danger.astro +0 -4
- package/stl-docs/components/mintlify-compat/callouts/Info.astro +0 -4
- package/stl-docs/components/mintlify-compat/callouts/Note.astro +0 -4
- package/stl-docs/components/mintlify-compat/callouts/Tip.astro +0 -4
- package/stl-docs/components/mintlify-compat/callouts/Warning.astro +0 -4
- package/stl-docs/components/nav-tabs/NavDropdown.astro +12 -7
- package/stl-docs/components/nav-tabs/NavTabs.astro +5 -3
- package/stl-docs/components/nav-tabs/buildNavLinks.ts +2 -0
- package/stl-docs/components/pagination/Pagination.astro +4 -2
- package/stl-docs/components/pagination/PaginationLinkEmphasized.astro +2 -2
- package/stl-docs/components/pagination/PaginationLinkQuiet.astro +2 -2
- package/stl-docs/components/pagination/util.ts +3 -3
- package/stl-docs/components/sidebars/BaseSidebar.astro +72 -1
- package/stl-docs/disableCalloutSyntax.ts +1 -1
- package/stl-docs/fonts.ts +5 -5
- package/stl-docs/index.ts +76 -53
- package/stl-docs/loadStlDocsConfig.ts +38 -8
- package/stl-docs/og-image/components/OpenGraphFunctionSignature.tsx +64 -0
- package/stl-docs/og-image/components/OpenGraphImage.tsx +126 -0
- package/stl-docs/og-image/config.ts +56 -0
- package/stl-docs/og-image/image-gen/generate-api-reference-og-image.tsx +188 -0
- package/stl-docs/og-image/image-gen/generate-og-image.tsx +119 -0
- package/stl-docs/og-image/image-gen/get-logo-url.ts +47 -0
- package/stl-docs/og-image/index.ts +135 -0
- package/stl-docs/og-image/routes/add-og-image.ts +45 -0
- package/stl-docs/og-image/routes/get-api-reference-og-image.ts +36 -0
- package/stl-docs/og-image/routes/get-og-image.ts +28 -0
- package/stl-docs/og-image/theme.ts +43 -0
- package/stl-docs/og-image/utils.ts +14 -0
- package/stl-docs/proseDocSync.test.ts +74 -0
- package/stl-docs/proseDocSync.ts +344 -0
- package/stl-docs/proseMarkdown/proseMarkdownIntegration.ts +4 -12
- package/stl-docs/schema-extension.ts +12 -0
- package/stl-docs/tabsMiddleware.ts +1 -1
- package/styles/overrides.css +2 -14
- package/styles/page.css +210 -71
- package/styles/sidebar.css +30 -17
- package/styles/sl-variables.css +3 -8
- package/styles/stldocs-variables.css +2 -2
- package/styles/toc.css +8 -0
- package/tsconfig.json +1 -1
- package/virtual-module.d.ts +35 -11
- package/playground-virtual-modules.d.ts +0 -96
- package/plugin/globalJs/create-playground.shim.ts +0 -3
- package/plugin/globalJs/playground-data.shim.ts +0 -1
- package/plugin/globalJs/playground-data.ts +0 -14
- package/plugin/specs/FileCache.ts +0 -99
- package/plugin/specs/generateSpec.ts +0 -112
- package/plugin/specs/index.ts +0 -132
- package/plugin/specs/inputResolver.ts +0 -146
- package/plugin/specs/worker.ts +0 -199
- package/plugin/vendor/preview.worker.docs.js +0 -26108
- package/plugin/vendor/templates/cli.md +0 -1
- package/plugin/vendor/templates/go.md +0 -316
- package/plugin/vendor/templates/java.md +0 -89
- package/plugin/vendor/templates/kotlin.md +0 -89
- package/plugin/vendor/templates/node.md +0 -235
- package/plugin/vendor/templates/python.md +0 -251
- package/plugin/vendor/templates/ruby.md +0 -147
- package/plugin/vendor/templates/terraform.md +0 -60
- package/plugin/vendor/templates/typescript.md +0 -319
- package/scripts/vendor_deps.ts +0 -50
- package/stl-docs/components/ClientRouterHead.astro +0 -41
- package/stl-docs/components/content-panel/ContentPanel.astro +0 -42
- package/stl-docs/components/headers/SplashMobileMenuToggle.astro +0 -65
- package/stl-docs/proseSearchIndexing.ts +0 -606
package/plugin/index.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import react from '@astrojs/react';
|
|
2
2
|
import type { StarlightPlugin } from '@astrojs/starlight/types';
|
|
3
3
|
import type { AstroIntegration } from 'astro';
|
|
4
|
-
import type { BundledTheme } from 'shiki';
|
|
5
4
|
import { config } from 'dotenv';
|
|
6
|
-
// import { buildAlgoliaIndex } from './buildAlgoliaIndex';
|
|
7
5
|
import {
|
|
8
6
|
getAPIReferencePlaceholderItemFromSidebarConfig,
|
|
9
7
|
makePlaceholderItems,
|
|
@@ -28,12 +26,17 @@ import { getSharedLogger } from '../shared/getSharedLogger';
|
|
|
28
26
|
import { resolveSrcFile } from '../resolveSrcFile';
|
|
29
27
|
import { mkdir, writeFile } from 'fs/promises';
|
|
30
28
|
import { fileURLToPath } from 'url';
|
|
31
|
-
import prebundleWorkers from 'vite-plugin-prebundle-workers';
|
|
32
|
-
import { SpecLoader, startSpecLoader } from './specs';
|
|
33
29
|
|
|
34
30
|
import type * as ReferenceSidebarsVirtualModule from 'virtual:stl-starlight-reference-sidebars';
|
|
35
|
-
import
|
|
31
|
+
import type * as VirtualManifestModule from 'virtual:stainless-apis-manifest';
|
|
32
|
+
|
|
33
|
+
import {
|
|
34
|
+
generateMissingRouteList,
|
|
35
|
+
isSupportedLanguage,
|
|
36
|
+
type DocsLanguage,
|
|
37
|
+
} from '@stainless-api/docs-ui/routing';
|
|
36
38
|
import { buildAlgoliaIndex } from './buildAlgoliaIndex';
|
|
39
|
+
import { flatSpecsList, loadAllSpecs, LoadedSpecs } from './specs/utils';
|
|
37
40
|
|
|
38
41
|
export { generateAPILink } from './generateAPIReferenceLink';
|
|
39
42
|
export type { ReferenceSidebarConfigItem };
|
|
@@ -91,58 +94,24 @@ export function generateAPIReferenceItems(
|
|
|
91
94
|
return makePlaceholderItems(id);
|
|
92
95
|
}
|
|
93
96
|
|
|
94
|
-
|
|
95
|
-
pluginConfig: NormalizedStainlessStarlightConfig,
|
|
96
|
-
): Promise<AstroIntegration> {
|
|
97
|
+
function stlStarlightAstroIntegration(pluginConfig: NormalizedStainlessStarlightConfig): AstroIntegration {
|
|
97
98
|
const virtualId = `virtual:stl-starlight-virtual-module`;
|
|
98
99
|
// The '\0' prefix tells Vite “this is a virtual module” and prevents it from being resolved again.
|
|
99
100
|
const resolvedId = `\0${virtualId}`;
|
|
100
|
-
let playgroundsBase: string | undefined;
|
|
101
|
-
let buildPlaygrounds;
|
|
102
101
|
let astroBase = '/';
|
|
103
102
|
|
|
104
|
-
let
|
|
105
|
-
async function
|
|
106
|
-
if (!
|
|
107
|
-
const result = await
|
|
108
|
-
return result.specComposite;
|
|
109
|
-
}
|
|
103
|
+
let specsPromise: Promise<LoadedSpecs> | undefined;
|
|
104
|
+
async function specsPromiseResolved() {
|
|
105
|
+
if (!specsPromise) throw new Error('Expected spec promise to exist');
|
|
106
|
+
const result = await specsPromise;
|
|
110
107
|
|
|
111
|
-
|
|
112
|
-
let reportError: ((message: string) => void) | null = null;
|
|
113
|
-
let collectedErrors: string[] | null = null;
|
|
114
|
-
|
|
115
|
-
function startPlaygroundsBuild(playgroundsCachePath: string) {
|
|
116
|
-
if (!pluginConfig.experimentalPlaygrounds) return;
|
|
117
|
-
if (building) return building;
|
|
118
|
-
return (building = (async () => {
|
|
119
|
-
const specComposite = await resolveSpecs();
|
|
120
|
-
|
|
121
|
-
if (specComposite.listUniqueSpecs().length > 1) {
|
|
122
|
-
throw new Error('Multiple specs found. This is not supported for Playgrounds.');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const spec = specComposite.listUniqueSpecs()[0]!.data.sdkJson;
|
|
126
|
-
const auth = specComposite.listUniqueSpecs()[0]!.data.auth;
|
|
127
|
-
|
|
128
|
-
const langs = specComposite.getLanguages();
|
|
129
|
-
|
|
130
|
-
await buildPlaygrounds!({
|
|
131
|
-
spec,
|
|
132
|
-
langs,
|
|
133
|
-
auth,
|
|
134
|
-
playPath: playgroundsCachePath,
|
|
135
|
-
reportError(message: string) {
|
|
136
|
-
(reportError ?? console.error)(message);
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
})());
|
|
108
|
+
return result;
|
|
140
109
|
}
|
|
141
110
|
|
|
142
111
|
return {
|
|
143
112
|
name: 'stl-starlight-astro',
|
|
144
113
|
hooks: {
|
|
145
|
-
'astro:config:setup':
|
|
114
|
+
'astro:config:setup': ({
|
|
146
115
|
injectRoute,
|
|
147
116
|
updateConfig,
|
|
148
117
|
logger: localLogger,
|
|
@@ -154,18 +123,24 @@ async function stlStarlightAstroIntegration(
|
|
|
154
123
|
const projectDir = astroConfig.root.pathname;
|
|
155
124
|
astroBase = astroConfig.base;
|
|
156
125
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
126
|
+
specsPromise = loadAllSpecs(
|
|
127
|
+
pluginConfig.loadSpecs({
|
|
128
|
+
stainlessProject: pluginConfig.stainlessProject,
|
|
129
|
+
branch: pluginConfig.branch,
|
|
130
|
+
apiKey: pluginConfig.apiKey?.value ?? null,
|
|
131
|
+
excludeLanguages: pluginConfig.excludeLanguages,
|
|
132
|
+
logger,
|
|
133
|
+
createCodegenDir,
|
|
134
|
+
}),
|
|
135
|
+
);
|
|
164
136
|
|
|
165
|
-
const
|
|
137
|
+
const middlewareFileBase = path.join(projectDir, 'middleware.stainless');
|
|
138
|
+
const middlewareFile = ['.tsx', '.ts']
|
|
139
|
+
.map((ext) => middlewareFileBase + ext)
|
|
140
|
+
.find((f) => fs.existsSync(f));
|
|
166
141
|
|
|
167
142
|
let vmMiddlewareExport = 'export const MIDDLEWARE = {};';
|
|
168
|
-
if (
|
|
143
|
+
if (middlewareFile) {
|
|
169
144
|
logger.debug(`Loading middleware from ${middlewareFile}`);
|
|
170
145
|
vmMiddlewareExport = `export { default as MIDDLEWARE } from '${middlewareFile}';`;
|
|
171
146
|
}
|
|
@@ -176,6 +151,12 @@ async function stlStarlightAstroIntegration(
|
|
|
176
151
|
prerender: pluginConfig.experimentalPrerender ? command === 'build' : false,
|
|
177
152
|
});
|
|
178
153
|
|
|
154
|
+
injectRoute({
|
|
155
|
+
pattern: `${pluginConfig.basePath}/index.md`,
|
|
156
|
+
entrypoint: resolveSrcFile('/plugin/routes/markdown.ts'),
|
|
157
|
+
prerender: pluginConfig.experimentalPrerender ? command === 'build' : false,
|
|
158
|
+
});
|
|
159
|
+
|
|
179
160
|
const astroFile = command === 'build' ? 'DocsStatic' : 'Docs';
|
|
180
161
|
injectRoute({
|
|
181
162
|
pattern: `${pluginConfig.basePath}/[...slug]`,
|
|
@@ -189,6 +170,16 @@ async function stlStarlightAstroIntegration(
|
|
|
189
170
|
prerender: pluginConfig.experimentalPrerender ? command === 'build' : false,
|
|
190
171
|
});
|
|
191
172
|
|
|
173
|
+
if (pluginConfig.llmsTxt.enabled) {
|
|
174
|
+
injectRoute({
|
|
175
|
+
pattern: '/llms.txt',
|
|
176
|
+
entrypoint: resolveSrcFile('/plugin/routes/llms.ts'),
|
|
177
|
+
prerender: pluginConfig.experimentalPrerender ? command === 'build' : false,
|
|
178
|
+
});
|
|
179
|
+
} else {
|
|
180
|
+
logger.info('LLMS.txt generation is disabled.');
|
|
181
|
+
}
|
|
182
|
+
|
|
192
183
|
updateConfig({
|
|
193
184
|
vite: {
|
|
194
185
|
plugins: [
|
|
@@ -196,24 +187,28 @@ async function stlStarlightAstroIntegration(
|
|
|
196
187
|
'virtual:stl-starlight-reference-sidebars',
|
|
197
188
|
async () => {
|
|
198
189
|
// we know specLoader exists here
|
|
199
|
-
const
|
|
190
|
+
const specs = await specsPromiseResolved();
|
|
200
191
|
|
|
201
192
|
const sidebars = [...sidebarConfigs.entries()]
|
|
202
193
|
// produce all { id, language } combos with the attached config
|
|
203
194
|
// flattens to one item per language * id combo
|
|
204
195
|
.flatMap(([id, config]) =>
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
196
|
+
flatSpecsList(specs)
|
|
197
|
+
.filter((res): res is typeof res & { language: DocsLanguage } =>
|
|
198
|
+
isSupportedLanguage(res.language),
|
|
199
|
+
)
|
|
200
|
+
.map((res) => ({
|
|
201
|
+
id,
|
|
202
|
+
config,
|
|
203
|
+
language: res.language,
|
|
204
|
+
sdkJson: res.sdkJson,
|
|
205
|
+
})),
|
|
211
206
|
)
|
|
212
207
|
// produce a sidebar for each
|
|
213
208
|
// later we will .find() the sidebar that matches the (id, language)
|
|
214
|
-
.map(({ id, config, language,
|
|
209
|
+
.map(({ id, config, language, sdkJson }) => {
|
|
215
210
|
const configItemsBuilder = new SidebarConfigItemsBuilder(
|
|
216
|
-
|
|
211
|
+
sdkJson,
|
|
217
212
|
language,
|
|
218
213
|
config.options,
|
|
219
214
|
);
|
|
@@ -227,11 +222,11 @@ async function stlStarlightAstroIntegration(
|
|
|
227
222
|
return {
|
|
228
223
|
id,
|
|
229
224
|
language,
|
|
230
|
-
// this has to run
|
|
225
|
+
// this has to run multiple times because it depends on the
|
|
231
226
|
// userSidebarConfig (which is per-id) and the language
|
|
232
227
|
entries: toStarlightSidebar({
|
|
233
228
|
basePath: path.posix.join(astroBase, pluginConfig.basePath),
|
|
234
|
-
spec,
|
|
229
|
+
spec: sdkJson,
|
|
235
230
|
entries: userSidebarConfig,
|
|
236
231
|
currentLanguage: language,
|
|
237
232
|
}),
|
|
@@ -241,58 +236,33 @@ async function stlStarlightAstroIntegration(
|
|
|
241
236
|
return { sidebars };
|
|
242
237
|
},
|
|
243
238
|
),
|
|
244
|
-
|
|
239
|
+
makeAsyncVirtualModPlugin<typeof VirtualManifestModule>(
|
|
240
|
+
'virtual:stainless-apis-manifest',
|
|
241
|
+
async () => {
|
|
242
|
+
// this virtual module only resolves when the specs are loaded
|
|
243
|
+
// this prevents the SSR module from trying to read the spec file before it's generated
|
|
244
|
+
const specs = await specsPromiseResolved();
|
|
245
|
+
|
|
246
|
+
return {
|
|
247
|
+
api: {
|
|
248
|
+
languages: specs
|
|
249
|
+
.map((s) =>
|
|
250
|
+
s.languages
|
|
251
|
+
.filter(isSupportedLanguage)
|
|
252
|
+
.map((lang) => ({ language: lang, sdkJSONFilePath: s.filePath })),
|
|
253
|
+
)
|
|
254
|
+
.flat(),
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
},
|
|
258
|
+
),
|
|
245
259
|
{
|
|
246
260
|
name: 'stl-starlight-vite',
|
|
247
|
-
|
|
248
|
-
building = undefined;
|
|
249
|
-
},
|
|
250
|
-
async configureServer(server) {
|
|
251
|
-
if (playgroundsBase) {
|
|
252
|
-
buildPlaygrounds = (await server.ssrLoadModule(playgroundsBase + '/src/build.ts'))
|
|
253
|
-
.buildPlaygrounds;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// TODO: eventually - re-add support for watching local input changes (eg. reloading when OAS/config files change)
|
|
257
|
-
},
|
|
261
|
+
// TODO: eventually - re-add support for watching local input changes (eg. reloading when OAS/config files change)
|
|
258
262
|
resolveId(id) {
|
|
259
263
|
if (id === virtualId) {
|
|
260
264
|
return resolvedId;
|
|
261
265
|
}
|
|
262
|
-
if (id === 'virtual:stl-playground/unstable-update-language') {
|
|
263
|
-
return resolveSrcFile('plugin/languages.ts');
|
|
264
|
-
}
|
|
265
|
-
if (id === 'virtual:stl-playground/create') {
|
|
266
|
-
return fileURLToPath(
|
|
267
|
-
new URL(
|
|
268
|
-
pluginConfig.experimentalPlaygrounds
|
|
269
|
-
? path.join(playgroundsBase!, '/src/create.tsx')
|
|
270
|
-
: './globalJs/create-playground.shim.ts',
|
|
271
|
-
import.meta.url,
|
|
272
|
-
),
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
if (id === 'virtual:stl-playground/data') {
|
|
276
|
-
return fileURLToPath(
|
|
277
|
-
new URL(
|
|
278
|
-
pluginConfig.experimentalPlaygrounds
|
|
279
|
-
? './globalJs/playground-data.ts'
|
|
280
|
-
: './globalJs/playground-data.shim.ts',
|
|
281
|
-
import.meta.url,
|
|
282
|
-
),
|
|
283
|
-
);
|
|
284
|
-
}
|
|
285
|
-
if (id.startsWith('virtual:stl-playground/')) {
|
|
286
|
-
const result = path.join(
|
|
287
|
-
this.environment.getTopLevelConfig().cacheDir,
|
|
288
|
-
'stl-playground',
|
|
289
|
-
id.slice('virtual:stl-playground/'.length),
|
|
290
|
-
);
|
|
291
|
-
const config = this.environment.getTopLevelConfig();
|
|
292
|
-
return startPlaygroundsBuild(path.join(config.cacheDir, 'stl-playground'))?.then(
|
|
293
|
-
() => result,
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
266
|
},
|
|
297
267
|
load(id) {
|
|
298
268
|
if (id === resolvedId) {
|
|
@@ -309,62 +279,39 @@ async function stlStarlightAstroIntegration(
|
|
|
309
279
|
EXPERIMENTAL_COLLAPSIBLE_METHOD_DESCRIPTIONS:
|
|
310
280
|
pluginConfig.experimentalCollapsibleMethodDescriptions,
|
|
311
281
|
PROPERTY_SETTINGS: pluginConfig.propertySettings,
|
|
312
|
-
ENABLE_CONTEXT_MENU: pluginConfig.contextMenu,
|
|
313
|
-
|
|
282
|
+
ENABLE_CONTEXT_MENU: !!pluginConfig.contextMenu,
|
|
283
|
+
CONTEXT_MENU_ENABLE_THIRD_PARTY:
|
|
284
|
+
(typeof pluginConfig.contextMenu === 'object'
|
|
285
|
+
? pluginConfig.contextMenu.thirdParty
|
|
286
|
+
: null) ?? true,
|
|
314
287
|
EXPERIMENTAL_REQUEST_BUILDER: pluginConfig.experimentalRequestBuilder,
|
|
315
288
|
STAINLESS_PROJECT: pluginConfig.stainlessProject,
|
|
289
|
+
LLMS_TXT_DESCRIPTION: pluginConfig.llmsTxt.description,
|
|
290
|
+
LLMS_TXT_DETAIL_THRESHOLD: pluginConfig.llmsTxt.detailThreshold,
|
|
316
291
|
} satisfies Omit<typeof StlStarlightVirtualModule, 'MIDDLEWARE'>),
|
|
317
292
|
vmMiddlewareExport,
|
|
318
293
|
].join('\n');
|
|
319
294
|
}
|
|
320
295
|
},
|
|
321
296
|
},
|
|
322
|
-
prebundleWorkers({
|
|
323
|
-
include: [
|
|
324
|
-
'**/typescript/runner*',
|
|
325
|
-
'**/typescript/worker*',
|
|
326
|
-
'**/pyright.worker*',
|
|
327
|
-
'**/python/pyodide*',
|
|
328
|
-
],
|
|
329
|
-
configureEsBuild(_, opts) {
|
|
330
|
-
opts.external ??= [];
|
|
331
|
-
opts.external.push('url');
|
|
332
|
-
opts.loader ??= {};
|
|
333
|
-
opts.loader['.wasm'] = 'dataurl';
|
|
334
|
-
return opts;
|
|
335
|
-
},
|
|
336
|
-
}),
|
|
337
297
|
],
|
|
338
298
|
},
|
|
339
299
|
});
|
|
340
300
|
},
|
|
341
|
-
'astro:build:start'({ logger }) {
|
|
342
|
-
collectedErrors = [];
|
|
343
|
-
reportError = (message: string) => {
|
|
344
|
-
logger.error(message);
|
|
345
|
-
collectedErrors!.push(message);
|
|
346
|
-
};
|
|
347
|
-
},
|
|
348
301
|
'astro:build:done': async ({ dir, logger }) => {
|
|
349
302
|
const dist = fileURLToPath(dir);
|
|
350
303
|
const stainlessDir = path.join(dist, '_stainless');
|
|
351
304
|
await mkdir(stainlessDir, { recursive: true });
|
|
352
|
-
if (collectedErrors) {
|
|
353
|
-
for (const error of collectedErrors) {
|
|
354
|
-
logger.error(error);
|
|
355
|
-
}
|
|
356
|
-
collectedErrors = null;
|
|
357
|
-
}
|
|
358
305
|
|
|
359
306
|
const manifest = {
|
|
360
307
|
astroBase,
|
|
361
308
|
};
|
|
362
309
|
await writeFile(path.join(stainlessDir, 'stl-manifest.json'), JSON.stringify(manifest, null, 2));
|
|
363
310
|
|
|
364
|
-
const
|
|
311
|
+
const loadedSpecs = await specsPromiseResolved();
|
|
365
312
|
|
|
366
313
|
await buildAlgoliaIndex({
|
|
367
|
-
|
|
314
|
+
loadedSpecs,
|
|
368
315
|
logger,
|
|
369
316
|
});
|
|
370
317
|
|
|
@@ -375,7 +322,7 @@ async function stlStarlightAstroIntegration(
|
|
|
375
322
|
// about the missing method and provide links to SDKs where it is available.
|
|
376
323
|
|
|
377
324
|
// TODO: (multi-spec) support multiple specs
|
|
378
|
-
const spec =
|
|
325
|
+
const spec = loadedSpecs[0]!.sdkJson;
|
|
379
326
|
|
|
380
327
|
const missingRoutes = generateMissingRouteList({
|
|
381
328
|
spec,
|
|
@@ -395,7 +342,7 @@ export function stainlessStarlight(someUserConfig: SomeStainlessStarlightUserCon
|
|
|
395
342
|
return {
|
|
396
343
|
name: 'stl-starlight',
|
|
397
344
|
hooks: {
|
|
398
|
-
'config:setup':
|
|
345
|
+
'config:setup': ({
|
|
399
346
|
addIntegration,
|
|
400
347
|
updateConfig,
|
|
401
348
|
addRouteMiddleware,
|
|
@@ -430,18 +377,17 @@ export function stainlessStarlight(someUserConfig: SomeStainlessStarlightUserCon
|
|
|
430
377
|
addIntegration(react());
|
|
431
378
|
}
|
|
432
379
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
// })
|
|
380
|
+
if ('apiKey' in config) {
|
|
381
|
+
if (!config.apiKey) {
|
|
382
|
+
logger.info(`Stainless credentials not loaded`);
|
|
383
|
+
} else if (config.apiKey.source === 'explicit-config') {
|
|
384
|
+
logger.info(`Stainless credentials loaded from user config`);
|
|
385
|
+
} else if (config.apiKey.source === 'environment-variable') {
|
|
386
|
+
logger.info('Stainless credentials loaded from `STAINLESS_API_KEY` environment variable');
|
|
387
|
+
} else if (config.apiKey.source === 'cli') {
|
|
388
|
+
logger.info('Stainless credentials loaded from `stl` CLI');
|
|
389
|
+
}
|
|
390
|
+
}
|
|
445
391
|
|
|
446
392
|
if (starlightConfig.sidebar) {
|
|
447
393
|
// for pagination (https://starlight.astro.build/reference/configuration/#pagination) to work correctly
|
|
@@ -455,14 +401,14 @@ export function stainlessStarlight(someUserConfig: SomeStainlessStarlightUserCon
|
|
|
455
401
|
}
|
|
456
402
|
}
|
|
457
403
|
|
|
458
|
-
addIntegration(
|
|
404
|
+
addIntegration(stlStarlightAstroIntegration(config));
|
|
459
405
|
|
|
460
406
|
const expressiveCodeConfig =
|
|
461
407
|
typeof starlightConfig.expressiveCode === 'object' ? starlightConfig.expressiveCode : {};
|
|
462
408
|
|
|
463
409
|
const themes = expressiveCodeConfig.themes
|
|
464
|
-
?
|
|
465
|
-
: (['github-light', 'github-dark']
|
|
410
|
+
? expressiveCodeConfig.themes
|
|
411
|
+
: (['github-light', 'github-dark'] satisfies (typeof expressiveCodeConfig)['themes']);
|
|
466
412
|
|
|
467
413
|
updateConfig({
|
|
468
414
|
sidebar: starlightConfig.sidebar,
|
|
@@ -486,5 +432,3 @@ export function stainlessStarlight(someUserConfig: SomeStainlessStarlightUserCon
|
|
|
486
432
|
// Additional exports we want for Stainless <-> docs integration.
|
|
487
433
|
export { parseStainlessPath } from '@stainless-api/docs-ui/routing';
|
|
488
434
|
export { renderMarkdown } from '@stainless-api/docs-ui/markdown';
|
|
489
|
-
|
|
490
|
-
export { resolveSpec } from './specs/inputResolver';
|