@stainless-api/docs 0.1.0-beta.12 → 0.1.0-beta.120
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 +998 -0
- package/eslint-suppressions.json +95 -0
- package/{eslint.config.js → eslint.config.ts} +0 -2
- package/locals.d.ts +17 -0
- package/package.json +57 -43
- package/playground-virtual-modules.d.ts +96 -0
- package/plugin/assets/languages/cli.svg +14 -0
- package/plugin/assets/languages/csharp.svg +1 -0
- package/plugin/assets/languages/php.svg +4 -0
- package/plugin/buildAlgoliaIndex.ts +40 -39
- package/plugin/components/MethodDescription.tsx +54 -0
- package/plugin/components/RequestBuilder/ParamEditor.tsx +55 -0
- package/plugin/components/RequestBuilder/SnippetStainlessIsland.tsx +107 -0
- package/plugin/components/RequestBuilder/index.tsx +40 -0
- package/plugin/components/RequestBuilder/props.ts +9 -0
- package/plugin/components/RequestBuilder/spec-helpers.ts +47 -0
- package/plugin/components/RequestBuilder/styles.css +67 -0
- package/plugin/components/SDKSelect.astro +18 -111
- package/plugin/components/SnippetCode.tsx +112 -70
- package/plugin/components/StainlessIslands.tsx +126 -0
- package/plugin/components/search/SearchAlgolia.astro +46 -29
- package/plugin/components/search/SearchIsland.tsx +52 -29
- package/plugin/generateAPIReferenceLink.ts +2 -2
- package/plugin/globalJs/ai-dropdown-options.ts +248 -0
- package/plugin/globalJs/code-snippets.ts +45 -16
- package/plugin/globalJs/copy.ts +115 -27
- package/plugin/globalJs/create-playground.shim.ts +3 -0
- package/plugin/globalJs/method-descriptions.ts +33 -0
- package/plugin/globalJs/navigation.ts +15 -33
- package/plugin/globalJs/playground-data.shim.ts +1 -0
- package/plugin/globalJs/playground-data.ts +14 -0
- package/plugin/globalJs/summary-selection-tweak.ts +29 -0
- package/plugin/helpers/generateDocsRoutes.ts +59 -0
- package/plugin/helpers/multiSpec.ts +8 -0
- package/plugin/index.ts +306 -142
- package/plugin/languages.ts +8 -2
- package/plugin/loadPluginConfig.ts +251 -107
- package/plugin/middlewareBuilder/stainlessMiddleware.d.ts +3 -1
- package/plugin/react/Routing.tsx +214 -143
- package/plugin/referencePlaceholderUtils.ts +18 -15
- package/plugin/replaceSidebarPlaceholderMiddleware.ts +39 -35
- package/plugin/routes/Docs.astro +71 -111
- package/plugin/routes/DocsStatic.astro +6 -5
- package/plugin/routes/Overview.astro +46 -22
- package/plugin/routes/markdown.ts +13 -12
- package/plugin/{cms → sidebar-utils}/sidebar-builder.ts +83 -63
- package/plugin/specs/FileCache.ts +99 -0
- package/plugin/specs/fetchSpecSSR.ts +27 -0
- package/plugin/specs/generateSpec.ts +112 -0
- package/plugin/specs/index.ts +137 -0
- package/plugin/specs/inputResolver.ts +148 -0
- package/plugin/{cms → specs}/worker.ts +82 -5
- package/plugin/vendor/preview.worker.docs.js +27234 -17991
- package/plugin/vendor/templates/cli.md +1 -0
- package/plugin/vendor/templates/go.md +4 -2
- package/plugin/vendor/templates/java.md +5 -1
- package/plugin/vendor/templates/kotlin.md +5 -1
- package/plugin/vendor/templates/node.md +4 -2
- package/plugin/vendor/templates/python.md +4 -2
- package/plugin/vendor/templates/ruby.md +4 -2
- package/plugin/vendor/templates/terraform.md +1 -1
- package/plugin/vendor/templates/typescript.md +3 -1
- package/resolveSrcFile.ts +10 -0
- package/scripts/vendor_deps.ts +5 -5
- package/shared/conditionalIntegration.ts +28 -0
- package/shared/getProsePages.ts +41 -0
- package/shared/getSharedLogger.ts +15 -0
- package/shared/terminalUtils.ts +3 -0
- package/shared/virtualModule.ts +54 -1
- package/src/content.config.ts +9 -0
- package/stl-docs/components/AIDropdown.tsx +63 -0
- package/stl-docs/components/AiChatIsland.tsx +14 -0
- package/stl-docs/components/{content-panel/ContentBreadcrumbs.tsx → ContentBreadcrumbs.tsx} +2 -2
- package/stl-docs/components/ContentPanel.astro +9 -0
- package/stl-docs/components/Footer.astro +89 -0
- package/stl-docs/components/Head.astro +20 -0
- package/stl-docs/components/Header.astro +3 -10
- package/stl-docs/components/PageFrame.astro +34 -0
- package/stl-docs/components/PageSidebar.astro +11 -0
- package/stl-docs/components/PageTitle.astro +82 -0
- package/stl-docs/components/StainlessLogo.svg +4 -0
- package/stl-docs/components/TableOfContents.astro +34 -0
- package/stl-docs/components/ThemeProvider.astro +36 -0
- package/stl-docs/components/ThemeSelect.astro +84 -146
- package/stl-docs/components/TwoColumnContent.astro +2 -0
- package/stl-docs/components/headers/DefaultHeader.astro +4 -6
- package/stl-docs/components/headers/StackedHeader.astro +8 -51
- package/stl-docs/components/icons/chat-gpt.tsx +2 -2
- package/stl-docs/components/icons/cursor.tsx +10 -0
- package/stl-docs/components/icons/gemini.tsx +19 -0
- package/stl-docs/components/icons/markdown.tsx +1 -1
- package/stl-docs/components/index.ts +1 -0
- package/stl-docs/components/mintlify-compat/Frame.astro +4 -4
- package/stl-docs/components/mintlify-compat/card.css +4 -4
- package/stl-docs/components/mintlify-compat/index.ts +2 -4
- package/stl-docs/components/nav-tabs/NavDropdown.astro +31 -75
- package/stl-docs/components/nav-tabs/NavTabs.astro +79 -81
- package/stl-docs/components/nav-tabs/SecondaryNavTabs.astro +15 -7
- package/stl-docs/components/nav-tabs/buildNavLinks.ts +3 -2
- package/stl-docs/components/pagination/HomeLink.astro +10 -0
- package/stl-docs/components/pagination/Pagination.astro +177 -0
- package/stl-docs/components/pagination/PaginationLinkEmphasized.astro +22 -0
- package/stl-docs/components/pagination/PaginationLinkQuiet.astro +13 -0
- package/stl-docs/components/pagination/util.ts +71 -0
- package/stl-docs/components/scripts.ts +1 -0
- package/stl-docs/components/sidebars/BaseSidebar.astro +80 -2
- package/stl-docs/components/sidebars/SidebarWithComponents.tsx +10 -0
- package/stl-docs/components/sidebars/convertAstroSidebarToStl.tsx +62 -0
- package/stl-docs/disableCalloutSyntax.ts +36 -0
- package/stl-docs/fonts.ts +186 -0
- package/stl-docs/index.ts +169 -51
- package/stl-docs/loadStlDocsConfig.ts +64 -8
- package/stl-docs/proseDocSync.ts +314 -0
- package/stl-docs/proseMarkdown/proseMarkdownIntegration.ts +53 -0
- package/stl-docs/proseMarkdown/proseMarkdownMiddleware.ts +41 -0
- package/stl-docs/proseMarkdown/toMarkdown.ts +158 -0
- package/stl-docs/proseSearchIndexing.ts +222 -0
- package/stl-docs/tabsMiddleware.ts +14 -5
- package/styles/code.css +53 -49
- package/styles/links.css +2 -37
- package/styles/method-descriptions.css +36 -0
- package/styles/overrides.css +28 -46
- package/styles/page.css +230 -52
- package/styles/sdk_select.css +9 -6
- package/styles/search.css +11 -21
- package/styles/sidebar.css +28 -211
- package/styles/{variables.css → sl-variables.css} +4 -8
- package/styles/stldocs-variables.css +6 -0
- package/styles/toc.css +19 -8
- package/theme.css +11 -9
- package/tsconfig.json +1 -4
- package/virtual-module.d.ts +65 -8
- package/components/variables.css +0 -112
- package/plugin/cms/client.ts +0 -62
- package/plugin/cms/server.ts +0 -268
- package/plugin/globalJs/ai-dropdown.ts +0 -57
- package/stl-docs/components/APIReferenceAIDropdown.tsx +0 -58
- package/stl-docs/components/content-panel/ContentPanel.astro +0 -69
- package/stl-docs/components/content-panel/ProseAIDropdown.tsx +0 -55
- package/stl-docs/components/headers/SplashMobileMenuToggle.astro +0 -49
- package/stl-docs/components/mintlify-compat/Step.astro +0 -56
- package/stl-docs/components/mintlify-compat/Steps.astro +0 -15
- package/styles/fonts.css +0 -68
- /package/{plugin/assets → assets}/fonts/geist/OFL.txt +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-italic-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-italic-latin.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-latin.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-italic-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-italic-latin.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-latin.woff2 +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
SDK_Readme
|
|
@@ -7,6 +7,8 @@ from applications written in Go.
|
|
|
7
7
|
|
|
8
8
|
SDK_GeneratedByStainless
|
|
9
9
|
|
|
10
|
+
SDK_MCPReadmeSection
|
|
11
|
+
|
|
10
12
|
## Installation
|
|
11
13
|
|
|
12
14
|
SDK_ReleasePleaseMarkdownBlockStart
|
|
@@ -31,7 +33,7 @@ SDK_ReleasePleaseMarkdownBlockEnd
|
|
|
31
33
|
|
|
32
34
|
## Requirements
|
|
33
35
|
|
|
34
|
-
This library requires Go 1.
|
|
36
|
+
This library requires Go 1.22+.
|
|
35
37
|
|
|
36
38
|
## Usage
|
|
37
39
|
|
|
@@ -307,7 +309,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
307
309
|
|
|
308
310
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
309
311
|
|
|
310
|
-
We are keen for your feedback; please open an [issue](
|
|
312
|
+
We are keen for your feedback; please open an [issue](SDK_RepoURL/issues) with questions, bugs, or suggestions.
|
|
311
313
|
|
|
312
314
|
## Contributing
|
|
313
315
|
|
|
@@ -11,6 +11,8 @@ SDK_SectionSimilarToOtherSDK
|
|
|
11
11
|
|
|
12
12
|
SDK_GeneratedByStainless
|
|
13
13
|
|
|
14
|
+
SDK_MCPReadmeSection
|
|
15
|
+
|
|
14
16
|
SDK_SectionDocumentationReference
|
|
15
17
|
|
|
16
18
|
SDK_SectionInstallation
|
|
@@ -57,6 +59,8 @@ SDK_SectionTimeouts
|
|
|
57
59
|
|
|
58
60
|
SDK_SectionProxies
|
|
59
61
|
|
|
62
|
+
SDK_SectionConnectionPooling
|
|
63
|
+
|
|
60
64
|
SDK_SectionHTTPS
|
|
61
65
|
|
|
62
66
|
SDK_SectionEnvironments
|
|
@@ -84,4 +88,4 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
84
88
|
|
|
85
89
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
86
90
|
|
|
87
|
-
We are keen for your feedback; please open an [issue](
|
|
91
|
+
We are keen for your feedback; please open an [issue](SDK_RepoURL/issues) with questions, bugs, or suggestions.
|
|
@@ -11,6 +11,8 @@ SDK_SectionSimilarToOtherSDK
|
|
|
11
11
|
|
|
12
12
|
SDK_GeneratedByStainless
|
|
13
13
|
|
|
14
|
+
SDK_MCPReadmeSection
|
|
15
|
+
|
|
14
16
|
SDK_SectionDocumentationReference
|
|
15
17
|
|
|
16
18
|
SDK_SectionInstallation
|
|
@@ -57,6 +59,8 @@ SDK_SectionTimeouts
|
|
|
57
59
|
|
|
58
60
|
SDK_SectionProxies
|
|
59
61
|
|
|
62
|
+
SDK_SectionConnectionPooling
|
|
63
|
+
|
|
60
64
|
SDK_SectionHTTPS
|
|
61
65
|
|
|
62
66
|
SDK_SectionEnvironments
|
|
@@ -84,4 +88,4 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
84
88
|
|
|
85
89
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
86
90
|
|
|
87
|
-
We are keen for your feedback; please open an [issue](
|
|
91
|
+
We are keen for your feedback; please open an [issue](SDK_RepoURL/issues) with questions, bugs, or suggestions.
|
|
@@ -10,6 +10,8 @@ SDK_DocumentationReference
|
|
|
10
10
|
|
|
11
11
|
SDK_GeneratedByStainless
|
|
12
12
|
|
|
13
|
+
SDK_MCPReadmeSection
|
|
14
|
+
|
|
13
15
|
## Installation
|
|
14
16
|
|
|
15
17
|
SDK_NPMInstallInstructions
|
|
@@ -169,7 +171,7 @@ import SDK_PackageName from 'SDK_NPMPackage';
|
|
|
169
171
|
```
|
|
170
172
|
|
|
171
173
|
To do the inverse, add `import "SDK_NPMPackage/shims/node"` (which does import polyfills).
|
|
172
|
-
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](
|
|
174
|
+
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](SDK_RepoCodeURL/src/_shims#readme)).
|
|
173
175
|
|
|
174
176
|
### Logging and middleware
|
|
175
177
|
|
|
@@ -214,7 +216,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
214
216
|
|
|
215
217
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
216
218
|
|
|
217
|
-
We are keen for your feedback; please open an [issue](
|
|
219
|
+
We are keen for your feedback; please open an [issue](SDK_RepoURL/issues) with questions, bugs, or suggestions.
|
|
218
220
|
|
|
219
221
|
## Requirements
|
|
220
222
|
|
|
@@ -9,6 +9,8 @@ SDK_ScreencastURL
|
|
|
9
9
|
|
|
10
10
|
SDK_GeneratedByStainless
|
|
11
11
|
|
|
12
|
+
SDK_MCPReadmeSection
|
|
13
|
+
|
|
12
14
|
## Documentation
|
|
13
15
|
|
|
14
16
|
SDK_DocumentationCallout SDK_APIReferenceCallout
|
|
@@ -227,7 +229,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
227
229
|
|
|
228
230
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
229
231
|
|
|
230
|
-
We are keen for your feedback; please open an [issue](
|
|
232
|
+
We are keen for your feedback; please open an [issue](SDK_RepoURL/issues) with questions, bugs, or suggestions.
|
|
231
233
|
|
|
232
234
|
### Determining the installed version
|
|
233
235
|
|
|
@@ -242,7 +244,7 @@ print(SDK_PythonPackageImportName.__version__)
|
|
|
242
244
|
|
|
243
245
|
## Requirements
|
|
244
246
|
|
|
245
|
-
Python 3.
|
|
247
|
+
Python 3.9 or higher.
|
|
246
248
|
|
|
247
249
|
## Contributing
|
|
248
250
|
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# SDK_PackageTitle API library
|
|
2
2
|
|
|
3
|
-
SDK_ReadmeOpening It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](
|
|
3
|
+
SDK_ReadmeOpening It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](SDK_RepoURL#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.
|
|
4
4
|
|
|
5
5
|
SDK_ScreencastURL
|
|
6
6
|
|
|
7
7
|
SDK_GeneratedByStainless
|
|
8
8
|
|
|
9
|
+
SDK_MCPReadmeSection
|
|
10
|
+
|
|
9
11
|
## Documentation
|
|
10
12
|
|
|
11
13
|
Documentation for releases of this gem can be found [on RubyDoc](SDK_RubyDocInfoURL).
|
|
@@ -142,4 +144,4 @@ Ruby SDK_RubyMinVersion or higher.
|
|
|
142
144
|
|
|
143
145
|
## Contributing
|
|
144
146
|
|
|
145
|
-
See [the contributing documentation](
|
|
147
|
+
See [the contributing documentation](SDK_RepoAssetURL/CONTRIBUTING.md).
|
|
@@ -53,7 +53,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
53
53
|
|
|
54
54
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
55
55
|
|
|
56
|
-
We are keen for your feedback; please open an [issue](
|
|
56
|
+
We are keen for your feedback; please open an [issue](SDK_RepoURL/issues) with questions, bugs, or suggestions.
|
|
57
57
|
|
|
58
58
|
## Contributing
|
|
59
59
|
|
|
@@ -10,6 +10,8 @@ SDK_DocumentationReference
|
|
|
10
10
|
|
|
11
11
|
SDK_GeneratedByStainless
|
|
12
12
|
|
|
13
|
+
SDK_MCPReadmeSection
|
|
14
|
+
|
|
13
15
|
## Installation
|
|
14
16
|
|
|
15
17
|
SDK_NPMInstallInstructions
|
|
@@ -298,7 +300,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
298
300
|
|
|
299
301
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
300
302
|
|
|
301
|
-
We are keen for your feedback; please open an [issue](
|
|
303
|
+
We are keen for your feedback; please open an [issue](SDK_RepoURL/issues) with questions, bugs, or suggestions.
|
|
302
304
|
|
|
303
305
|
## Requirements
|
|
304
306
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
const dirName = import.meta.dirname;
|
|
3
|
+
/**
|
|
4
|
+
* Resolve a source file path relative to the stl-starlight package.
|
|
5
|
+
* @param projectPath - The relative path to the source file.
|
|
6
|
+
* @returns The absolute path to the source file.
|
|
7
|
+
*/
|
|
8
|
+
export function resolveSrcFile(...projectPath: string[]) {
|
|
9
|
+
return join(dirName, ...projectPath);
|
|
10
|
+
}
|
package/scripts/vendor_deps.ts
CHANGED
|
@@ -3,7 +3,7 @@ import fs from 'fs';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
|
-
import { Languages } from '@stainless-api/docs-ui/
|
|
6
|
+
import { Languages } from '@stainless-api/docs-ui/routing';
|
|
7
7
|
|
|
8
8
|
const DEPS_DIR = './plugin/vendor';
|
|
9
9
|
|
|
@@ -11,12 +11,12 @@ config();
|
|
|
11
11
|
|
|
12
12
|
const envSchema = z.object({
|
|
13
13
|
// absolute path to the Stainless monorepo root
|
|
14
|
-
|
|
14
|
+
STAINLESS_ROOT: z.string(),
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
const env = envSchema.parse(process.env);
|
|
18
18
|
|
|
19
|
-
console.log(`Using Stainless monorepo at ${env.
|
|
19
|
+
console.log(`Using Stainless monorepo at ${env.STAINLESS_ROOT}`);
|
|
20
20
|
|
|
21
21
|
if (fs.existsSync(DEPS_DIR)) {
|
|
22
22
|
fs.rmSync(DEPS_DIR, { recursive: true });
|
|
@@ -25,11 +25,11 @@ if (fs.existsSync(DEPS_DIR)) {
|
|
|
25
25
|
fs.mkdirSync(DEPS_DIR, { recursive: true });
|
|
26
26
|
|
|
27
27
|
const previewWorkerPath = path.join(
|
|
28
|
-
env.
|
|
28
|
+
env.STAINLESS_ROOT,
|
|
29
29
|
'/packages/preview-worker/dist/stainless/preview.worker.docs.js',
|
|
30
30
|
);
|
|
31
31
|
|
|
32
|
-
const readmeTemplatePath = path.join(env.
|
|
32
|
+
const readmeTemplatePath = path.join(env.STAINLESS_ROOT, '/legacy-dir-root/templates');
|
|
33
33
|
|
|
34
34
|
fs.copyFileSync(previewWorkerPath, path.join(DEPS_DIR, 'preview.worker.docs.js'));
|
|
35
35
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AstroIntegration, type AstroIntegrationLogger } from 'astro';
|
|
2
|
+
import { getSharedLogger } from './getSharedLogger';
|
|
3
|
+
|
|
4
|
+
export default function conditionalIntegration({
|
|
5
|
+
condition,
|
|
6
|
+
integration,
|
|
7
|
+
reason,
|
|
8
|
+
}: {
|
|
9
|
+
condition: boolean;
|
|
10
|
+
integration: AstroIntegration;
|
|
11
|
+
reason?: string | undefined;
|
|
12
|
+
}): AstroIntegration {
|
|
13
|
+
if (condition) {
|
|
14
|
+
return integration;
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
name: integration.name,
|
|
18
|
+
hooks: Object.fromEntries(
|
|
19
|
+
Object.keys(integration.hooks).map((hookName) => [
|
|
20
|
+
hookName,
|
|
21
|
+
({ logger: localLogger }: { logger: AstroIntegrationLogger }) => {
|
|
22
|
+
const logger = getSharedLogger({ fallback: localLogger });
|
|
23
|
+
logger.info(`Skipping ${integration.name} integration. Reason: ${reason ?? 'not provided'}`);
|
|
24
|
+
},
|
|
25
|
+
]),
|
|
26
|
+
),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { readdir } from 'fs/promises';
|
|
2
|
+
import { join, relative } from 'path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get all prose pages after a build, by reading all HTML files from the
|
|
6
|
+
* given output directory, and not from assets.
|
|
7
|
+
*
|
|
8
|
+
* We cannot use the `assets` map here because it is not guaranteed to
|
|
9
|
+
* contain all files, especially if they were generated by other integrations.
|
|
10
|
+
* Other astro integrations may hijack the "[...slug]" entrypoint, and any files
|
|
11
|
+
* previously in the [...slug] asset map entry would be lost (this is where starlight stores
|
|
12
|
+
* its prose HTML files).
|
|
13
|
+
*/
|
|
14
|
+
export async function getProsePages({
|
|
15
|
+
apiReferenceBasePath,
|
|
16
|
+
outputBasePath,
|
|
17
|
+
}: {
|
|
18
|
+
apiReferenceBasePath: string | null;
|
|
19
|
+
outputBasePath: string;
|
|
20
|
+
}): Promise<string[]> {
|
|
21
|
+
const allFiles = await readdir(outputBasePath, {
|
|
22
|
+
recursive: true,
|
|
23
|
+
withFileTypes: true,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const htmlFiles = allFiles
|
|
27
|
+
.filter((file) => file.isFile() && file.name.endsWith('.html'))
|
|
28
|
+
.map((file) => join(file.parentPath, file.name));
|
|
29
|
+
|
|
30
|
+
if (!apiReferenceBasePath) return htmlFiles;
|
|
31
|
+
// Normalize by removing leading/trailing slashes from apiReferenceBasePath
|
|
32
|
+
const normalizedApiPath = apiReferenceBasePath.replace(/^\/+/g, '').replace(/\/+$/g, '');
|
|
33
|
+
const pagesToRender = htmlFiles.filter((absPath) => {
|
|
34
|
+
const relPath = relative(outputBasePath, absPath);
|
|
35
|
+
// Filter out API reference pages
|
|
36
|
+
if (relPath === normalizedApiPath || relPath.startsWith(`${normalizedApiPath}/`)) return false;
|
|
37
|
+
return true;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return pagesToRender;
|
|
41
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AstroIntegrationLogger } from 'astro';
|
|
2
|
+
|
|
3
|
+
let sharedLogger: AstroIntegrationLogger | null = null;
|
|
4
|
+
|
|
5
|
+
// This is probably temporary, but it's a quick way to share a logger between our many integrations
|
|
6
|
+
// we want to share a logger so they have the same "stainless" label
|
|
7
|
+
|
|
8
|
+
export function setSharedLogger(logger: AstroIntegrationLogger) {
|
|
9
|
+
sharedLogger = logger;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// a fallback is probably not required, but it's a good safeguard in case we somehow call a logger before the shared logger is set
|
|
13
|
+
export function getSharedLogger({ fallback }: { fallback: AstroIntegrationLogger }) {
|
|
14
|
+
return sharedLogger ?? fallback;
|
|
15
|
+
}
|
package/shared/virtualModule.ts
CHANGED
|
@@ -1,7 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ViteUserConfig } from 'astro';
|
|
2
|
+
|
|
3
|
+
export type VitePlugin = NonNullable<ViteUserConfig['plugins']>[number];
|
|
4
|
+
|
|
5
|
+
export function buildVirtualModuleString<T extends Record<string, unknown>>(vars: T) {
|
|
2
6
|
return Object.entries(vars)
|
|
3
7
|
.map(([key, value]) => {
|
|
4
8
|
return `export const ${key} = ${JSON.stringify(value)};`;
|
|
5
9
|
})
|
|
6
10
|
.join('\n');
|
|
7
11
|
}
|
|
12
|
+
|
|
13
|
+
export function makeVirtualModPlugin(bareId: string, content: string): VitePlugin {
|
|
14
|
+
return {
|
|
15
|
+
name: `stl-virtual-module-loader-${bareId}`,
|
|
16
|
+
resolveId(id) {
|
|
17
|
+
// The '\0' prefix tells Vite “this is a virtual module” and prevents it from being resolved again.
|
|
18
|
+
if (id === bareId) {
|
|
19
|
+
return `\0${bareId}`;
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
load(id) {
|
|
23
|
+
if (id === `\0${bareId}`) {
|
|
24
|
+
return content;
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function makeAsyncVirtualModPlugin<T extends Record<string, unknown>>(
|
|
31
|
+
bareId: string,
|
|
32
|
+
contentLoader: () => Promise<T | string>,
|
|
33
|
+
): VitePlugin {
|
|
34
|
+
return {
|
|
35
|
+
name: `stl-virtual-module-loader-${bareId}`,
|
|
36
|
+
resolveId(id) {
|
|
37
|
+
// The '\0' prefix tells Vite “this is a virtual module” and prevents it from being resolved again.
|
|
38
|
+
if (id === bareId) {
|
|
39
|
+
return `\0${bareId}`;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
async load(id) {
|
|
43
|
+
if (id === `\0${bareId}`) {
|
|
44
|
+
const content = await contentLoader();
|
|
45
|
+
if (typeof content === 'string') {
|
|
46
|
+
return content;
|
|
47
|
+
}
|
|
48
|
+
return buildVirtualModuleString(content);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function virtualModule(id: string) {
|
|
55
|
+
return {
|
|
56
|
+
fromString: (content: string) => makeVirtualModPlugin(id, content),
|
|
57
|
+
fromObject: <T extends Record<string, unknown>>(content: T) =>
|
|
58
|
+
makeVirtualModPlugin(id, buildVirtualModuleString(content)),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Stub here so that `astro sync` generates the correct types for the `docs` content collection
|
|
2
|
+
|
|
3
|
+
import { defineCollection } from 'astro:content';
|
|
4
|
+
import { docsLoader } from '@astrojs/starlight/loaders';
|
|
5
|
+
import { docsSchema } from '@astrojs/starlight/schema';
|
|
6
|
+
|
|
7
|
+
export const collections = {
|
|
8
|
+
docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
|
|
9
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { DropdownButton } from '@stainless-api/ui-primitives';
|
|
2
|
+
import { CopyIcon } from 'lucide-react';
|
|
3
|
+
import { ChatGPTIcon } from './icons/chat-gpt';
|
|
4
|
+
import { ClaudeIcon } from './icons/claude';
|
|
5
|
+
import { GeminiIcon } from './icons/gemini';
|
|
6
|
+
import { MarkdownIcon } from './icons/markdown';
|
|
7
|
+
import { CursorIcon } from './icons/cursor';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
import { getAIDropdownOptions, type DropdownIcon } from '../../plugin/globalJs/ai-dropdown-options';
|
|
11
|
+
|
|
12
|
+
const iconMap: { [key in DropdownIcon]: React.ReactNode } = {
|
|
13
|
+
markdown: <MarkdownIcon />,
|
|
14
|
+
copy: <CopyIcon size={16} />,
|
|
15
|
+
claude: <ClaudeIcon />,
|
|
16
|
+
chatgpt: <ChatGPTIcon />,
|
|
17
|
+
gemini: <GeminiIcon />,
|
|
18
|
+
cursor: <CursorIcon />,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const { primaryAction, groups } = getAIDropdownOptions();
|
|
22
|
+
|
|
23
|
+
function ItemLabel({ label }: { label: string[] }) {
|
|
24
|
+
if (label.length > 1) {
|
|
25
|
+
return (
|
|
26
|
+
<DropdownButton.MenuItemText subtle>
|
|
27
|
+
{label[0]}
|
|
28
|
+
<strong>{label[1]}</strong>
|
|
29
|
+
</DropdownButton.MenuItemText>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<DropdownButton.MenuItemText>
|
|
35
|
+
<strong>{label[0]}</strong>
|
|
36
|
+
</DropdownButton.MenuItemText>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function AIDropdown() {
|
|
41
|
+
return (
|
|
42
|
+
<DropdownButton data-dropdown-id="ai-dropdown-button">
|
|
43
|
+
<DropdownButton.PrimaryAction>
|
|
44
|
+
{iconMap[primaryAction.icon]}
|
|
45
|
+
<DropdownButton.PrimaryActionText>{primaryAction.label}</DropdownButton.PrimaryActionText>
|
|
46
|
+
</DropdownButton.PrimaryAction>
|
|
47
|
+
<DropdownButton.Trigger />
|
|
48
|
+
<DropdownButton.Menu>
|
|
49
|
+
{groups.map((group) => (
|
|
50
|
+
<React.Fragment key={group.reactKey}>
|
|
51
|
+
{group.options.map((option) => (
|
|
52
|
+
<DropdownButton.MenuItem value={option.id} isExternalLink={option.external} key={option.id}>
|
|
53
|
+
<DropdownButton.Icon>{iconMap[option.icon]}</DropdownButton.Icon>
|
|
54
|
+
<ItemLabel label={option.label} />
|
|
55
|
+
</DropdownButton.MenuItem>
|
|
56
|
+
))}
|
|
57
|
+
{group.isLast ? null : <hr />}
|
|
58
|
+
</React.Fragment>
|
|
59
|
+
))}
|
|
60
|
+
</DropdownButton.Menu>
|
|
61
|
+
</DropdownButton>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DocsLanguage } from '@stainless-api/docs-ui/routing';
|
|
2
|
+
import AiChat, { STAINLESS_PROJECT } from 'virtual:stl-docs/components/AiChat.tsx';
|
|
3
|
+
|
|
4
|
+
export default function AiChatIsland({
|
|
5
|
+
currentLanguage,
|
|
6
|
+
siteTitle,
|
|
7
|
+
}: {
|
|
8
|
+
currentLanguage: DocsLanguage | undefined;
|
|
9
|
+
siteTitle: string | undefined;
|
|
10
|
+
}) {
|
|
11
|
+
if (!AiChat) throw new Error('AiChatIsland was rendered but could not load AiChat component');
|
|
12
|
+
if (!STAINLESS_PROJECT) return null;
|
|
13
|
+
return <AiChat projectId={STAINLESS_PROJECT} language={currentLanguage} siteTitle={siteTitle} />;
|
|
14
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChevronRight } from 'lucide-react';
|
|
2
|
-
import { Join } from '@stainless-api/docs-ui/
|
|
3
|
-
import style from '@stainless-api/docs-ui/
|
|
2
|
+
import { Join } from '@stainless-api/docs-ui/components';
|
|
3
|
+
import style from '@stainless-api/docs-ui/style';
|
|
4
4
|
import type { StarlightRouteData } from '@astrojs/starlight/route-data';
|
|
5
5
|
|
|
6
6
|
type Breadcrumb = { title: string; href: string };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
import EditLink from 'virtual:starlight/components/EditLink';
|
|
3
|
+
import LastUpdated from 'virtual:starlight/components/LastUpdated';
|
|
4
|
+
import Pagination from 'virtual:starlight/components/Pagination';
|
|
5
|
+
import { RENDER_CREDITS } from 'virtual:stl-docs-virtual-module';
|
|
6
|
+
import StainlessLogo from './StainlessLogo.svg';
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<footer class="stl-footer">
|
|
10
|
+
<div class="stl-footer-row meta">
|
|
11
|
+
<EditLink />
|
|
12
|
+
<LastUpdated />
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<Pagination />
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
RENDER_CREDITS && (
|
|
19
|
+
<div class="stl-footer-row">
|
|
20
|
+
<a
|
|
21
|
+
class="stl-footer-credits"
|
|
22
|
+
href="https://www.stainless.com/products/docs"
|
|
23
|
+
target="_blank"
|
|
24
|
+
rel="noopener noreferrer"
|
|
25
|
+
>
|
|
26
|
+
Powered by <StainlessLogo />
|
|
27
|
+
</a>
|
|
28
|
+
</div>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
</footer>
|
|
32
|
+
|
|
33
|
+
<style is:global>
|
|
34
|
+
.stl-footer {
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
gap: 1.5rem;
|
|
38
|
+
margin-block-start: 4rem;
|
|
39
|
+
padding-block-start: 1rem;
|
|
40
|
+
padding-block-end: 4rem;
|
|
41
|
+
|
|
42
|
+
.stl-footer-row {
|
|
43
|
+
display: flex;
|
|
44
|
+
gap: 1rem;
|
|
45
|
+
justify-content: space-between;
|
|
46
|
+
|
|
47
|
+
&:empty,
|
|
48
|
+
&:not(:has(> *)) {
|
|
49
|
+
display: none;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.pagination-links {
|
|
54
|
+
margin-inline: calc(-0.25 * var(--stl-ui-pagination-border-radius-outer));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.stl-footer-credits {
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: row;
|
|
61
|
+
align-items: center;
|
|
62
|
+
text-decoration: none;
|
|
63
|
+
margin-inline-start: auto;
|
|
64
|
+
margin-block-start: 1rem;
|
|
65
|
+
font-size: var(--stl-typography-scale-sm);
|
|
66
|
+
|
|
67
|
+
/* duck text opacity by more than image opacity */
|
|
68
|
+
opacity: 0.75;
|
|
69
|
+
color: rgb(from var(--stl-color-foreground-reduced) r g b / calc(alpha * 0.9));
|
|
70
|
+
transition:
|
|
71
|
+
opacity 0.15s ease,
|
|
72
|
+
color 0.15s ease;
|
|
73
|
+
/* both text & image to full opacity */
|
|
74
|
+
&:hover {
|
|
75
|
+
opacity: 1;
|
|
76
|
+
color: var(--stl-color-foreground-reduced);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
svg {
|
|
80
|
+
height: 1.4em;
|
|
81
|
+
width: auto;
|
|
82
|
+
display: inline-block;
|
|
83
|
+
margin-inline-start: 0.5ch;
|
|
84
|
+
image {
|
|
85
|
+
transform: translateX(0.15ch);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { Font } from 'astro:assets';
|
|
3
|
+
import { FONTS } from 'virtual:stl-docs-virtual-module';
|
|
4
|
+
import Default from '@astrojs/starlight/components/Head.astro';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
|
|
7
|
+
const mdPath = path.posix.join(Astro.url.pathname, 'index.md');
|
|
8
|
+
const fonts = [FONTS.primary, FONTS.heading, FONTS.mono, ...(FONTS.additional ?? [])].filter(Boolean);
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<Default />
|
|
12
|
+
|
|
13
|
+
{fonts.map((font) => <Font cssVariable={font.cssVariable} preload={font.preload} />)}
|
|
14
|
+
|
|
15
|
+
<link rel="alternate" type="text/markdown" href={mdPath} />
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
import { wireAIDropdown } from '../../plugin/globalJs/ai-dropdown-options.ts';
|
|
19
|
+
wireAIDropdown();
|
|
20
|
+
</script>
|
|
@@ -23,14 +23,6 @@ const shouldRenderSearch = !!(
|
|
|
23
23
|
|
|
24
24
|
<style is:global>
|
|
25
25
|
@layer starlight.core {
|
|
26
|
-
header {
|
|
27
|
-
border-color: var(--sl-color-hairline);
|
|
28
|
-
|
|
29
|
-
&.header {
|
|
30
|
-
border-bottom-color: var(--sl-color-hairline);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
26
|
.header {
|
|
35
27
|
display: flex;
|
|
36
28
|
gap: var(--sl-nav-gap);
|
|
@@ -44,9 +36,10 @@ const shouldRenderSearch = !!(
|
|
|
44
36
|
overflow: clip;
|
|
45
37
|
/* Avoid clipping focus ring around link inside title wrapper. */
|
|
46
38
|
padding: 0.25rem;
|
|
47
|
-
padding-left: 0;
|
|
48
39
|
margin: -0.25rem;
|
|
49
40
|
min-width: 0;
|
|
41
|
+
/* Max height should match button height */
|
|
42
|
+
max-height: 32px;
|
|
50
43
|
}
|
|
51
44
|
|
|
52
45
|
.default-tabs-container {
|
|
@@ -84,7 +77,7 @@ const shouldRenderSearch = !!(
|
|
|
84
77
|
|
|
85
78
|
@media (min-width: 50rem) {
|
|
86
79
|
.default-tabs-container {
|
|
87
|
-
min-width:
|
|
80
|
+
min-width: 540px;
|
|
88
81
|
}
|
|
89
82
|
}
|
|
90
83
|
}
|