@stainless-api/docs 0.1.0-beta.9 → 0.1.0-beta.90
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 +748 -0
- package/eslint-suppressions.json +32 -0
- package/locals.d.ts +17 -0
- package/package.json +49 -40
- 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/buildAlgoliaIndex.ts +38 -11
- 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 +31 -0
- package/plugin/components/RequestBuilder/props.ts +9 -0
- package/plugin/components/RequestBuilder/spec-helpers.ts +50 -0
- package/plugin/components/RequestBuilder/styles.css +67 -0
- package/plugin/components/SDKSelect.astro +20 -104
- package/plugin/components/SnippetCode.tsx +111 -66
- package/plugin/components/StainlessIslands.tsx +126 -0
- package/plugin/components/search/SearchAlgolia.astro +45 -28
- 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 +15 -8
- package/plugin/globalJs/copy.ts +94 -17
- package/plugin/globalJs/create-playground.shim.ts +3 -0
- package/plugin/globalJs/method-descriptions.ts +33 -0
- package/plugin/globalJs/navigation.ts +10 -29
- package/plugin/globalJs/playground-data.shim.ts +1 -0
- package/plugin/globalJs/playground-data.ts +14 -0
- package/plugin/helpers/generateDocsRoutes.ts +27 -0
- package/plugin/helpers/getDocsLanguages.ts +9 -0
- package/plugin/index.ts +292 -116
- package/plugin/languages.ts +7 -2
- package/plugin/loadPluginConfig.ts +155 -79
- package/plugin/middlewareBuilder/stainlessMiddleware.d.ts +1 -1
- package/plugin/react/Routing.tsx +204 -132
- package/plugin/referencePlaceholderUtils.ts +18 -15
- package/plugin/replaceSidebarPlaceholderMiddleware.ts +38 -34
- package/plugin/routes/Docs.astro +65 -117
- package/plugin/routes/DocsStatic.astro +7 -4
- package/plugin/routes/Overview.astro +20 -24
- package/plugin/routes/markdown.ts +12 -11
- package/plugin/{cms → sidebar-utils}/sidebar-builder.ts +30 -54
- package/plugin/specs/fetchSpecSSR.ts +21 -0
- package/plugin/specs/generateSpec.ts +50 -0
- package/plugin/specs/index.ts +238 -0
- package/plugin/{cms → specs}/worker.ts +82 -5
- package/plugin/vendor/preview.worker.docs.js +20928 -17830
- package/plugin/vendor/templates/go.md +1 -1
- package/plugin/vendor/templates/python.md +1 -1
- package/resolveSrcFile.ts +10 -0
- package/scripts/vendor_deps.ts +5 -5
- package/shared/getProsePages.ts +42 -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/Head.astro +20 -0
- package/stl-docs/components/Header.astro +6 -8
- package/stl-docs/components/PageFrame.astro +18 -0
- package/stl-docs/components/PageTitle.astro +82 -0
- package/stl-docs/components/TableOfContents.astro +34 -0
- package/stl-docs/components/ThemeProvider.astro +36 -0
- package/stl-docs/components/ThemeSelect.astro +84 -139
- package/stl-docs/components/content-panel/ContentPanel.astro +16 -46
- package/stl-docs/components/headers/SplashMobileMenuToggle.astro +17 -1
- package/stl-docs/components/headers/StackedHeader.astro +29 -24
- 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/Accordion.astro +7 -5
- package/stl-docs/components/mintlify-compat/AccordionGroup.astro +7 -3
- package/stl-docs/components/mintlify-compat/Columns.astro +40 -42
- package/stl-docs/components/mintlify-compat/Frame.astro +16 -18
- package/stl-docs/components/mintlify-compat/callouts/Callout.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Check.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Danger.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Info.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Note.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Tip.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Warning.astro +1 -1
- package/stl-docs/components/mintlify-compat/card.css +33 -35
- package/stl-docs/components/mintlify-compat/index.ts +2 -4
- package/stl-docs/components/nav-tabs/NavDropdown.astro +31 -70
- package/stl-docs/components/nav-tabs/NavTabs.astro +78 -80
- package/stl-docs/components/nav-tabs/SecondaryNavTabs.astro +15 -8
- 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 +175 -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 +9 -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 +153 -50
- package/stl-docs/loadStlDocsConfig.ts +51 -7
- package/stl-docs/proseMarkdown/proseMarkdownIntegration.ts +61 -0
- package/stl-docs/proseMarkdown/proseMarkdownMiddleware.ts +41 -0
- package/stl-docs/proseMarkdown/toMarkdown.ts +158 -0
- package/stl-docs/proseSearchIndexing.ts +606 -0
- package/stl-docs/tabsMiddleware.ts +13 -4
- package/styles/code.css +128 -136
- package/styles/links.css +11 -48
- package/styles/method-descriptions.css +36 -0
- package/styles/overrides.css +49 -57
- package/styles/page.css +100 -59
- package/styles/sdk_select.css +9 -7
- package/styles/search.css +57 -69
- package/styles/sidebar.css +26 -156
- package/styles/{variables.css → sl-variables.css} +3 -2
- package/styles/stldocs-variables.css +6 -0
- package/styles/toc.css +41 -34
- package/theme.css +11 -11
- package/tsconfig.json +2 -5
- package/virtual-module.d.ts +47 -7
- package/components/variables.css +0 -135
- 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/mintlify-compat/Step.astro +0 -58
- package/stl-docs/components/mintlify-compat/Steps.astro +0 -17
- 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,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,11 +22,14 @@ window.addEventListener('popstate', (ev: PopStateEvent) => {
|
|
|
24
22
|
});
|
|
25
23
|
|
|
26
24
|
document.addEventListener(getPageLoadEvent(), () => {
|
|
25
|
+
const rootElement = document.getElementById('stldocs-snippet-select');
|
|
26
|
+
if (!rootElement) return;
|
|
27
|
+
|
|
27
28
|
initDropdown({
|
|
28
|
-
|
|
29
|
+
root: rootElement,
|
|
29
30
|
onSelect: (value) => {
|
|
30
|
-
const originalLanguage =
|
|
31
|
-
navigate(updateSelectedLanguage(
|
|
31
|
+
const originalLanguage = rootElement?.dataset.currentValue;
|
|
32
|
+
navigate(updateSelectedLanguage(RESOLVED_API_REFERENCE_PATH, originalLanguage, value));
|
|
32
33
|
},
|
|
33
34
|
});
|
|
34
35
|
|
|
@@ -36,26 +37,6 @@ document.addEventListener(getPageLoadEvent(), () => {
|
|
|
36
37
|
if (path) setTimeout(() => scrollToPath(path.slice(1)), 10);
|
|
37
38
|
});
|
|
38
39
|
|
|
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
40
|
document.addEventListener('click', (event) => {
|
|
60
41
|
const toggle = (event.target as HTMLElement).closest(
|
|
61
42
|
'[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,27 @@
|
|
|
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
|
+
|
|
5
|
+
export function generateDocsRoutes(spec: SDKJSON.Spec, excludeLanguages: DocsLanguage[] = EXCLUDE_LANGUAGES) {
|
|
6
|
+
const paths = generateRouteList({
|
|
7
|
+
spec,
|
|
8
|
+
excludeLanguages,
|
|
9
|
+
});
|
|
10
|
+
const readmes = Object.entries(spec.readme)
|
|
11
|
+
.filter(([language]) => language !== 'http')
|
|
12
|
+
.filter(([language]) => !excludeLanguages.includes(language as DocsLanguage))
|
|
13
|
+
.map(([language]) => ({
|
|
14
|
+
slug: language,
|
|
15
|
+
stainlessPath: null,
|
|
16
|
+
language: language as DocsLanguage,
|
|
17
|
+
title: 'Readme',
|
|
18
|
+
kind: 'readme' as const,
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
return [...paths, ...readmes].map(({ slug, stainlessPath, language, title, kind }) => {
|
|
22
|
+
return {
|
|
23
|
+
params: { slug },
|
|
24
|
+
props: { stainlessPath, language, title, kind },
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DocsLanguage } from '@stainless-api/docs-ui/routing';
|
|
2
|
+
import type * as SDKJSON from '@stainless/sdk-json';
|
|
3
|
+
|
|
4
|
+
export function getDocsLanguages(spec: SDKJSON.Spec, excludeLanguages: DocsLanguage[]) {
|
|
5
|
+
// TODO: should not force unwrap this
|
|
6
|
+
const languages: DocsLanguage[] = spec.docs!.languages ?? ['http'];
|
|
7
|
+
|
|
8
|
+
return languages.filter((language) => !excludeLanguages.includes(language));
|
|
9
|
+
}
|