@stainless-api/docs 0.1.0-beta.11 → 0.1.0-beta.110
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 +919 -0
- package/eslint-suppressions.json +27 -0
- package/locals.d.ts +17 -0
- package/package.json +50 -41
- 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 +37 -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 +110 -68
- package/plugin/components/StainlessIslands.tsx +126 -0
- package/plugin/components/search/SearchAlgolia.astro +46 -29
- package/plugin/components/search/SearchIsland.tsx +47 -29
- package/plugin/generateAPIReferenceLink.ts +2 -2
- package/plugin/globalJs/ai-dropdown-options.ts +243 -0
- package/plugin/globalJs/code-snippets.ts +40 -11
- package/plugin/globalJs/copy.ts +95 -17
- package/plugin/globalJs/create-playground.shim.ts +3 -0
- package/plugin/globalJs/method-descriptions.ts +33 -0
- package/plugin/globalJs/navigation.ts +12 -32
- package/plugin/globalJs/playground-data.shim.ts +1 -0
- package/plugin/globalJs/playground-data.ts +14 -0
- package/plugin/helpers/generateDocsRoutes.ts +59 -0
- package/plugin/helpers/multiSpec.ts +8 -0
- package/plugin/index.ts +304 -138
- 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 +212 -141
- package/plugin/referencePlaceholderUtils.ts +18 -15
- package/plugin/replaceSidebarPlaceholderMiddleware.ts +38 -34
- package/plugin/routes/Docs.astro +70 -111
- package/plugin/routes/DocsStatic.astro +6 -5
- package/plugin/routes/Overview.astro +45 -21
- package/plugin/routes/markdown.ts +13 -12
- package/plugin/{cms → sidebar-utils}/sidebar-builder.ts +49 -60
- 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 +132 -0
- package/plugin/specs/inputResolver.ts +146 -0
- package/plugin/{cms → specs}/worker.ts +82 -5
- package/plugin/vendor/preview.worker.docs.js +27303 -18260
- 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/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/content-panel/ContentPanel.astro +4 -64
- 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 +79 -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 +171 -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 +13 -4
- 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 +25 -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/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
package/plugin/globalJs/copy.ts
CHANGED
|
@@ -1,30 +1,44 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
RESOLVED_API_REFERENCE_PATH,
|
|
3
|
+
EXPERIMENTAL_COLLAPSIBLE_SNIPPETS,
|
|
4
|
+
} from 'virtual:stl-starlight-virtual-module';
|
|
5
|
+
import { getPageLoadEvent } from '../helpers/getPageLoadEvent';
|
|
6
|
+
import { updateSelectedLanguage } from '../languages';
|
|
7
|
+
import { navigate } from 'astro/virtual-modules/transitions-router.js';
|
|
2
8
|
const copyIcon = `<rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>`;
|
|
3
9
|
const circleAlertIcon = `<circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/>`;
|
|
4
10
|
const checkIcon = `<path d="M20 6 9 17l-5-5"/>`;
|
|
5
11
|
|
|
12
|
+
function getContent(button: HTMLElement, full: boolean) {
|
|
13
|
+
const isContentCollapsed = !!document.querySelector('.stldocs-snippet-code.stl-snippet-code-is-collapsed');
|
|
14
|
+
|
|
15
|
+
const content = button.closest('[data-stldocs-copy-parent]')!.querySelector('[data-stldocs-copy-content]')!;
|
|
16
|
+
|
|
17
|
+
const contentCopy = content.cloneNode(true) as HTMLElement;
|
|
18
|
+
|
|
19
|
+
contentCopy.querySelectorAll('.ellipsis').forEach((el) => el.remove());
|
|
20
|
+
if (EXPERIMENTAL_COLLAPSIBLE_SNIPPETS && isContentCollapsed && !full) {
|
|
21
|
+
contentCopy.querySelectorAll('.hidden').forEach((el) => el.remove());
|
|
22
|
+
contentCopy.querySelectorAll('.leading-ws').forEach((el) => el.remove());
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return contentCopy.textContent!;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const preloadPlayground = async (event: Event) => {
|
|
29
|
+
const playButton = (event.target as HTMLElement).closest('[data-stldocs-snippet-play]') as HTMLElement;
|
|
30
|
+
if (playButton) {
|
|
31
|
+
loadPlayground(playButton);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
addEventListener('mouseover', preloadPlayground);
|
|
6
35
|
addEventListener('click', async (event) => {
|
|
7
36
|
const copyButton = (event.target as HTMLElement).closest('[data-stldocs-snippet-copy]') as HTMLElement;
|
|
8
37
|
if (copyButton) {
|
|
9
38
|
const iconElement = copyButton.querySelector('.stldocs-icon') as SVGElement;
|
|
10
39
|
clearTimeout(copyButton.dataset.__stldocsCopyTimeout);
|
|
11
40
|
try {
|
|
12
|
-
|
|
13
|
-
'.stldocs-snippet-code.stl-snippet-code-is-collapsed',
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
const content = copyButton
|
|
17
|
-
.closest('[data-stldocs-copy-parent]')!
|
|
18
|
-
.querySelector('[data-stldocs-copy-content]')!;
|
|
19
|
-
|
|
20
|
-
const contentCopy = content.cloneNode(true) as HTMLElement;
|
|
21
|
-
|
|
22
|
-
contentCopy.querySelectorAll('.ellipsis').forEach((el) => el.remove());
|
|
23
|
-
if (EXPERIMENTAL_COLLAPSIBLE_SNIPPETS && isContentCollapsed) {
|
|
24
|
-
contentCopy.querySelectorAll('.hidden').forEach((el) => el.remove());
|
|
25
|
-
contentCopy.querySelectorAll('.leading-ws').forEach((el) => el.remove());
|
|
26
|
-
}
|
|
27
|
-
await navigator.clipboard.writeText(contentCopy.textContent!);
|
|
41
|
+
await navigator.clipboard.writeText(getContent(copyButton, false));
|
|
28
42
|
iconElement.innerHTML = checkIcon;
|
|
29
43
|
} catch {
|
|
30
44
|
iconElement.innerHTML = circleAlertIcon;
|
|
@@ -34,4 +48,68 @@ addEventListener('click', async (event) => {
|
|
|
34
48
|
iconElement.innerHTML = copyIcon;
|
|
35
49
|
}, 1000) + '';
|
|
36
50
|
}
|
|
51
|
+
|
|
52
|
+
const playButton = (event.target as HTMLElement).closest('[data-stldocs-snippet-play]') as HTMLElement;
|
|
53
|
+
if (playButton) {
|
|
54
|
+
showPlayground(playButton);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
async function showPlayground(playButton: HTMLElement) {
|
|
59
|
+
if (playButton.getAttribute('aria-disabled') === 'true') return;
|
|
60
|
+
const iconElement = playButton.querySelector('.stldocs-icon') as SVGElement;
|
|
61
|
+
try {
|
|
62
|
+
// use aria-disabled, not disabled, to avoid losing focus
|
|
63
|
+
playButton.setAttribute('aria-disabled', 'true');
|
|
64
|
+
playButton.setAttribute('aria-label', 'Loading playground...');
|
|
65
|
+
playButton.classList.add('stl-ui-button--loading');
|
|
66
|
+
const showPlayground = loadPlayground(playButton);
|
|
67
|
+
await showPlayground();
|
|
68
|
+
} catch (e) {
|
|
69
|
+
console.error(e);
|
|
70
|
+
iconElement.innerHTML = circleAlertIcon;
|
|
71
|
+
}
|
|
72
|
+
playButton.removeAttribute('aria-disabled');
|
|
73
|
+
playButton.removeAttribute('aria-label');
|
|
74
|
+
playButton.classList.remove('stl-ui-button--loading');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function loadPlayground(playButton: HTMLElement) {
|
|
78
|
+
(playButton as any).__playgroundLoadPromise ??= (async () => {
|
|
79
|
+
const container = playButton.closest('.stldocs-snippet') as HTMLElement;
|
|
80
|
+
const language = (container.querySelector('.stl-sdk-select') as HTMLElement).dataset.currentValue;
|
|
81
|
+
const code = getContent(playButton, true);
|
|
82
|
+
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
|
83
|
+
if (import.meta.env.DEV) {
|
|
84
|
+
const id = '/@id/astro:scripts/before-hydration.js';
|
|
85
|
+
await import(/* @vite-ignore */ id).catch(console.warn);
|
|
86
|
+
}
|
|
87
|
+
const { createPlayground } = await import('virtual:stl-playground/create');
|
|
88
|
+
const { default: playgroundData } = await import('virtual:stl-playground/data');
|
|
89
|
+
return createPlayground({
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
+
lang: language as any,
|
|
92
|
+
doc: (language === 'python' ? 'from rich import print\n' : '') + code.trimEnd(),
|
|
93
|
+
container,
|
|
94
|
+
onLanguageSelect: (value) => {
|
|
95
|
+
const originalLanguage = container.querySelector<HTMLElement>('[data-stldocs-snippet-select]')
|
|
96
|
+
?.dataset.currentValue;
|
|
97
|
+
const path: string = updateSelectedLanguage(RESOLVED_API_REFERENCE_PATH, originalLanguage, value);
|
|
98
|
+
navigate(path.replace(/(\?.+)?($|#)/, (_, str, end) => (str ? str + '&play' : '?play') + end));
|
|
99
|
+
},
|
|
100
|
+
...playgroundData,
|
|
101
|
+
});
|
|
102
|
+
})();
|
|
103
|
+
return async () => {
|
|
104
|
+
const promise = (playButton as any).__playgroundLoadPromise;
|
|
105
|
+
(playButton as any).__playgroundLoadPromise = null;
|
|
106
|
+
await ((await promise) as () => Promise<void>)();
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
document.addEventListener(getPageLoadEvent(), () => {
|
|
110
|
+
if (new URL(location.href).searchParams.has('play')) {
|
|
111
|
+
document.querySelectorAll('[data-stldocs-snippet-play]').forEach((e) => {
|
|
112
|
+
showPlayground(e as HTMLElement);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
37
115
|
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
2
|
+
const COLLAPSED_HEIGHT = 170;
|
|
3
|
+
|
|
4
|
+
const container = document.querySelector<HTMLElement>('[data-stldocs-property-group="method-description"]');
|
|
5
|
+
|
|
6
|
+
if (!container) return;
|
|
7
|
+
|
|
8
|
+
const toggle = document?.querySelector<HTMLButtonElement>('[data-method-description-toggle]');
|
|
9
|
+
if (!toggle) return;
|
|
10
|
+
|
|
11
|
+
// If content isn't tall enough, don't show the button
|
|
12
|
+
if (container.scrollHeight <= COLLAPSED_HEIGHT + 1) {
|
|
13
|
+
toggle.hidden = true;
|
|
14
|
+
container.dataset.collapsed = 'false';
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Only show button if content is taller than collapsed max height
|
|
19
|
+
if (container.scrollHeight > COLLAPSED_HEIGHT + 1) {
|
|
20
|
+
toggle.hidden = false;
|
|
21
|
+
} else {
|
|
22
|
+
// Not tall enough to need collapsing — show full content and hide button
|
|
23
|
+
container.dataset.collapsed = 'false';
|
|
24
|
+
toggle.hidden = true;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
toggle.addEventListener('click', function () {
|
|
29
|
+
const isCollapsed = container.dataset.collapsed !== 'false';
|
|
30
|
+
container.dataset.collapsed = isCollapsed ? 'false' : 'true';
|
|
31
|
+
toggle.textContent = isCollapsed ? 'Show less' : 'Show more';
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import { parseRoute, scrollToPath } from '@stainless-api/docs-ui/
|
|
2
|
-
import {
|
|
1
|
+
import { parseRoute, scrollToPath } from '@stainless-api/docs-ui/routing';
|
|
2
|
+
import { RESOLVED_API_REFERENCE_PATH } from 'virtual:stl-starlight-virtual-module';
|
|
3
3
|
import { updateSelectedLanguage } from '../languages';
|
|
4
4
|
import { navigate } from 'astro:transitions/client';
|
|
5
5
|
import { getPageLoadEvent } from '../helpers/getPageLoadEvent.ts';
|
|
6
6
|
|
|
7
|
-
import { initDropdown } from '@stainless-api/docs
|
|
8
|
-
import { initDropdownButton } from '@stainless-api/ui-primitives/scripts';
|
|
9
|
-
import { copyCurrentPageAsMarkdown, onSelectAIOption } from './ai-dropdown.ts';
|
|
7
|
+
import { initDropdown } from '@stainless-api/docs/components/scripts';
|
|
10
8
|
|
|
11
9
|
history.scrollRestoration = 'auto';
|
|
12
10
|
|
|
13
11
|
function getStainlessPathForLocation() {
|
|
14
12
|
return document.location.hash
|
|
15
13
|
? decodeURI(document.location.hash)
|
|
16
|
-
: parseRoute(
|
|
14
|
+
: parseRoute(RESOLVED_API_REFERENCE_PATH, document.location.href)?.stainlessPath;
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
window.addEventListener('popstate', (ev: PopStateEvent) => {
|
|
@@ -24,38 +22,20 @@ window.addEventListener('popstate', (ev: PopStateEvent) => {
|
|
|
24
22
|
});
|
|
25
23
|
|
|
26
24
|
document.addEventListener(getPageLoadEvent(), () => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
document.querySelectorAll<HTMLElement>('[data-stldocs-snippet-select]').forEach((rootElement) => {
|
|
26
|
+
initDropdown({
|
|
27
|
+
root: rootElement,
|
|
28
|
+
onSelect: (value) => {
|
|
29
|
+
const originalLanguage = rootElement.dataset.currentValue;
|
|
30
|
+
navigate(updateSelectedLanguage(RESOLVED_API_REFERENCE_PATH, originalLanguage, value));
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
const path = getStainlessPathForLocation();
|
|
36
36
|
if (path) setTimeout(() => scrollToPath(path.slice(1)), 10);
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
document.addEventListener(getPageLoadEvent(), () => {
|
|
40
|
-
initDropdownButton({
|
|
41
|
-
dropdownId: 'ai-dropdown-button',
|
|
42
|
-
onSelect: onSelectAIOption,
|
|
43
|
-
onPrimaryAction: (el) => {
|
|
44
|
-
copyCurrentPageAsMarkdown();
|
|
45
|
-
const innerText = el.querySelector('[data-part="primary-action-text"]');
|
|
46
|
-
if (!innerText) return;
|
|
47
|
-
|
|
48
|
-
const originalInnerHtml = innerText.innerHTML;
|
|
49
|
-
innerText.innerHTML = 'Copied!';
|
|
50
|
-
el.classList.add('disabled');
|
|
51
|
-
setTimeout(() => {
|
|
52
|
-
innerText.innerHTML = originalInnerHtml;
|
|
53
|
-
el.classList.remove('disabled');
|
|
54
|
-
}, 1000);
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
39
|
document.addEventListener('click', (event) => {
|
|
60
40
|
const toggle = (event.target as HTMLElement).closest(
|
|
61
41
|
'[data-stldocs-property-toggle-expanded] > .stldocs-expand-toggle-content',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import wheelUrl from 'virtual:stl-playground/python/wheel.whl?url';
|
|
2
|
+
import pyTypes from 'virtual:stl-playground/python.json';
|
|
3
|
+
import tsTypes from 'virtual:stl-playground/typescript.json';
|
|
4
|
+
import authData from 'virtual:stl-playground/auth.json';
|
|
5
|
+
import { HIGHLIGHT_THEMES } from 'virtual:stl-starlight-virtual-module';
|
|
6
|
+
import { Config } from 'virtual:stl-playground/create';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
wheelUrl,
|
|
10
|
+
pyTypes,
|
|
11
|
+
tsTypes,
|
|
12
|
+
authData,
|
|
13
|
+
HIGHLIGHT_THEMES,
|
|
14
|
+
} satisfies Config;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type * as SDKJSON from '@stainless/sdk-json';
|
|
2
|
+
import { DocsLanguage, generateRouteList } from '@stainless-api/docs-ui/routing';
|
|
3
|
+
import { EXCLUDE_LANGUAGES } from 'virtual:stl-starlight-virtual-module';
|
|
4
|
+
import { api } from 'virtual:stainless-apis-manifest';
|
|
5
|
+
import { getSDKJSONInSSR } from '../specs/fetchSpecSSR';
|
|
6
|
+
|
|
7
|
+
export function generateDocsRoutes(spec: SDKJSON.Spec, excludeLanguages: DocsLanguage[] = EXCLUDE_LANGUAGES) {
|
|
8
|
+
const paths = generateRouteList({
|
|
9
|
+
spec,
|
|
10
|
+
excludeLanguages,
|
|
11
|
+
});
|
|
12
|
+
const readmes = Object.entries(spec.readme)
|
|
13
|
+
.filter(([language]) => language !== 'http')
|
|
14
|
+
.filter(([language]) => !excludeLanguages.includes(language as DocsLanguage))
|
|
15
|
+
.map(([language]) => ({
|
|
16
|
+
slug: language,
|
|
17
|
+
stainlessPath: null,
|
|
18
|
+
language: language as DocsLanguage,
|
|
19
|
+
title: 'Readme',
|
|
20
|
+
kind: 'readme' as const,
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
return [...paths, ...readmes].map(({ slug, stainlessPath, language, title, kind }) => {
|
|
24
|
+
return {
|
|
25
|
+
params: { slug },
|
|
26
|
+
props: { stainlessPath, language, title, kind },
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function generateAllDocsRoutes() {
|
|
32
|
+
const uniquePaths = new Set<string>();
|
|
33
|
+
|
|
34
|
+
const allRoutes = (
|
|
35
|
+
await Promise.all(
|
|
36
|
+
api.languages.map(async (entry) => {
|
|
37
|
+
const spec = await getSDKJSONInSSR(entry.language);
|
|
38
|
+
|
|
39
|
+
// this is super annoying, but preview worker _always_ generates HTTP routes
|
|
40
|
+
// so, we exclude them unless the we're explicitly told to include them
|
|
41
|
+
const excludeLanguages = [...EXCLUDE_LANGUAGES];
|
|
42
|
+
if (entry.language !== 'http') {
|
|
43
|
+
excludeLanguages.push('http');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const routes = generateDocsRoutes(spec, excludeLanguages);
|
|
47
|
+
return routes.filter((route) => {
|
|
48
|
+
if (uniquePaths.has(route.params.slug)) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
uniquePaths.add(route.params.slug);
|
|
52
|
+
return true;
|
|
53
|
+
});
|
|
54
|
+
}),
|
|
55
|
+
)
|
|
56
|
+
).flat();
|
|
57
|
+
|
|
58
|
+
return allRoutes;
|
|
59
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { api } from 'virtual:stainless-apis-manifest';
|
|
2
|
+
import { EXCLUDE_LANGUAGES } from 'virtual:stl-starlight-virtual-module';
|
|
3
|
+
|
|
4
|
+
export function getDocsLanguages() {
|
|
5
|
+
return api.languages
|
|
6
|
+
.map((language) => language.language)
|
|
7
|
+
.filter((language) => !EXCLUDE_LANGUAGES.includes(language));
|
|
8
|
+
}
|