@stainless-api/docs 0.1.0-beta.5 → 0.1.0-beta.51

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.
Files changed (115) hide show
  1. package/CHANGELOG.md +390 -0
  2. package/eslint-suppressions.json +47 -0
  3. package/locals.d.ts +14 -0
  4. package/package.json +43 -39
  5. package/plugin/buildAlgoliaIndex.ts +31 -6
  6. package/plugin/cms/server.ts +98 -56
  7. package/plugin/cms/sidebar-builder.ts +7 -26
  8. package/plugin/cms/worker.ts +3 -3
  9. package/plugin/components/MethodDescription.tsx +54 -0
  10. package/plugin/components/SDKSelect.astro +7 -87
  11. package/plugin/components/SnippetCode.tsx +11 -7
  12. package/plugin/components/search/SearchAlgolia.astro +5 -33
  13. package/plugin/components/search/SearchIsland.tsx +37 -23
  14. package/plugin/generateAPIReferenceLink.ts +2 -2
  15. package/plugin/globalJs/ai-dropdown-options.ts +235 -0
  16. package/plugin/globalJs/method-descriptions.ts +33 -0
  17. package/plugin/globalJs/navigation.ts +7 -27
  18. package/plugin/helpers/getPageLoadEvent.ts +1 -1
  19. package/plugin/index.ts +54 -34
  20. package/plugin/languages.ts +2 -2
  21. package/plugin/loadPluginConfig.ts +112 -32
  22. package/plugin/middlewareBuilder/stainlessMiddleware.d.ts +1 -1
  23. package/plugin/react/Routing.tsx +176 -80
  24. package/plugin/referencePlaceholderUtils.ts +1 -1
  25. package/plugin/replaceSidebarPlaceholderMiddleware.ts +5 -1
  26. package/plugin/routes/Docs.astro +60 -85
  27. package/plugin/routes/Overview.astro +10 -16
  28. package/plugin/routes/markdown.ts +7 -7
  29. package/plugin/vendor/preview.worker.docs.js +17973 -16561
  30. package/plugin/vendor/templates/go.md +1 -1
  31. package/plugin/vendor/templates/python.md +1 -1
  32. package/resolveSrcFile.ts +10 -0
  33. package/scripts/vendor_deps.ts +1 -1
  34. package/shared/getSharedLogger.ts +15 -0
  35. package/shared/terminalUtils.ts +3 -0
  36. package/src/content.config.ts +9 -0
  37. package/stl-docs/components/AIDropdown.tsx +63 -0
  38. package/stl-docs/components/{content-panel/ContentBreadcrumbs.tsx → ContentBreadcrumbs.tsx} +2 -2
  39. package/stl-docs/components/Head.astro +16 -0
  40. package/stl-docs/components/Header.astro +6 -8
  41. package/stl-docs/components/PageTitle.astro +82 -0
  42. package/stl-docs/components/TableOfContents.astro +34 -0
  43. package/stl-docs/components/ThemeSelect.astro +118 -141
  44. package/stl-docs/components/content-panel/ContentPanel.astro +16 -46
  45. package/stl-docs/components/headers/DefaultHeader.astro +1 -1
  46. package/stl-docs/components/headers/HeaderLinks.astro +1 -1
  47. package/stl-docs/components/headers/SplashMobileMenuToggle.astro +17 -1
  48. package/stl-docs/components/headers/StackedHeader.astro +29 -24
  49. package/stl-docs/components/icons/chat-gpt.tsx +17 -0
  50. package/stl-docs/components/icons/claude.tsx +10 -0
  51. package/stl-docs/components/icons/cursor.tsx +10 -0
  52. package/stl-docs/components/icons/gemini.tsx +19 -0
  53. package/stl-docs/components/icons/markdown.tsx +10 -0
  54. package/stl-docs/components/index.ts +1 -0
  55. package/stl-docs/components/mintlify-compat/Accordion.astro +7 -38
  56. package/stl-docs/components/mintlify-compat/AccordionGroup.astro +9 -23
  57. package/stl-docs/components/mintlify-compat/Columns.astro +40 -42
  58. package/stl-docs/components/mintlify-compat/Frame.astro +16 -18
  59. package/stl-docs/components/mintlify-compat/Step.astro +30 -32
  60. package/stl-docs/components/mintlify-compat/Steps.astro +8 -10
  61. package/stl-docs/components/mintlify-compat/callouts/Callout.astro +10 -3
  62. package/stl-docs/components/mintlify-compat/callouts/Check.astro +7 -3
  63. package/stl-docs/components/mintlify-compat/callouts/Danger.astro +7 -3
  64. package/stl-docs/components/mintlify-compat/callouts/Info.astro +7 -3
  65. package/stl-docs/components/mintlify-compat/callouts/Note.astro +7 -3
  66. package/stl-docs/components/mintlify-compat/callouts/Tip.astro +7 -3
  67. package/stl-docs/components/mintlify-compat/callouts/Warning.astro +7 -3
  68. package/stl-docs/components/mintlify-compat/card.css +33 -35
  69. package/stl-docs/components/nav-tabs/NavDropdown.astro +31 -75
  70. package/stl-docs/components/nav-tabs/NavTabs.astro +78 -80
  71. package/stl-docs/components/nav-tabs/SecondaryNavTabs.astro +15 -8
  72. package/stl-docs/components/nav-tabs/buildNavLinks.ts +4 -3
  73. package/stl-docs/components/pagination/HomeLink.astro +10 -0
  74. package/stl-docs/components/pagination/Pagination.astro +174 -0
  75. package/stl-docs/components/pagination/PaginationLinkEmphasized.astro +22 -0
  76. package/stl-docs/components/pagination/PaginationLinkQuiet.astro +13 -0
  77. package/stl-docs/components/pagination/util.ts +71 -0
  78. package/stl-docs/components/scripts.ts +1 -0
  79. package/stl-docs/components/{Sidebar.astro → sidebars/BaseSidebar.astro} +2 -3
  80. package/stl-docs/components/sidebars/SDKSelectSidebar.astro +8 -0
  81. package/stl-docs/disableCalloutSyntax.ts +36 -0
  82. package/stl-docs/index.ts +98 -26
  83. package/stl-docs/loadStlDocsConfig.ts +37 -5
  84. package/stl-docs/proseMarkdown/proseMarkdownIntegration.ts +64 -0
  85. package/stl-docs/proseMarkdown/proseMarkdownMiddleware.ts +34 -0
  86. package/stl-docs/proseMarkdown/toMarkdown.ts +158 -0
  87. package/stl-docs/tabsMiddleware.ts +12 -4
  88. package/styles/code.css +104 -141
  89. package/styles/fonts.css +32 -17
  90. package/styles/links.css +11 -48
  91. package/styles/method-descriptions.css +36 -0
  92. package/styles/overrides.css +49 -57
  93. package/styles/page.css +90 -59
  94. package/styles/sdk_select.css +9 -7
  95. package/styles/search.css +58 -69
  96. package/styles/sidebar.css +211 -131
  97. package/styles/{variables.css → sl-variables.css} +3 -2
  98. package/styles/stldocs-variables.css +6 -0
  99. package/styles/toc.css +41 -34
  100. package/theme.css +12 -2
  101. package/tsconfig.json +2 -5
  102. package/virtual-module.d.ts +8 -4
  103. package/components/variables.css +0 -139
  104. package/plugin/globalJs/ai-dropdown.ts +0 -57
  105. package/stl-docs/components/APIReferenceAIDropdown.tsx +0 -86
  106. package/stl-docs/components/content-panel/ProseAIDropdown.tsx +0 -64
  107. /package/{plugin/assets → assets}/fonts/geist/OFL.txt +0 -0
  108. /package/{plugin/assets → assets}/fonts/geist/geist-italic-latin-ext.woff2 +0 -0
  109. /package/{plugin/assets → assets}/fonts/geist/geist-italic-latin.woff2 +0 -0
  110. /package/{plugin/assets → assets}/fonts/geist/geist-latin-ext.woff2 +0 -0
  111. /package/{plugin/assets → assets}/fonts/geist/geist-latin.woff2 +0 -0
  112. /package/{plugin/assets → assets}/fonts/geist/geist-mono-italic-latin-ext.woff2 +0 -0
  113. /package/{plugin/assets → assets}/fonts/geist/geist-mono-italic-latin.woff2 +0 -0
  114. /package/{plugin/assets → assets}/fonts/geist/geist-mono-latin-ext.woff2 +0 -0
  115. /package/{plugin/assets → assets}/fonts/geist/geist-mono-latin.woff2 +0 -0
@@ -1,24 +1,15 @@
1
1
  ---
2
- import StarlightPage from "@astrojs/starlight/components/StarlightPage.astro";
3
- import { cmsClient } from "../cms/client";
4
-
5
- import "@stainless-api/docs-ui/src/styles/resets.css";
6
- import "@stainless-api/docs-ui/src/styles/primitives.css";
7
- import "@stainless-api/docs-ui/src/styles/main.css";
8
- import "@stainless-api/docs-ui/src/styles/snippets.css";
9
- // TODO: fix variables.css import
10
- // import "./variables.css";
11
-
2
+ import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
3
+ import { cmsClient } from '../cms/client';
12
4
  import {
13
5
  getReadmeContent,
14
6
  generateDocsRoutes,
15
7
  buildPageNavigation,
16
8
  RenderSpec,
17
9
  astroMarkdownRender,
18
- } from "../react/Routing";
19
- import { getResourceFromSpec } from "@stainless-api/docs-ui/src/utils";
20
- import { BASE_PATH, CONTENT_PANEL_LAYOUT,MIDDLEWARE } from "virtual:stl-starlight-virtual-module";
21
-
10
+ } from '../react/Routing';
11
+ import { getResourceFromSpec } from '@stainless-api/docs-ui/utils';
12
+ import { BASE_PATH, CONTENT_PANEL_LAYOUT, MIDDLEWARE } from 'virtual:stl-starlight-virtual-module';
22
13
 
23
14
  const spec = await cmsClient.getSpec();
24
15
  const routes = generateDocsRoutes(spec);
@@ -26,23 +17,23 @@ const routes = generateDocsRoutes(spec);
26
17
  const route = routes.find((r) => r.params.slug === Astro.params.slug);
27
18
 
28
19
  if (!route) {
29
- throw new Error("No such route");
20
+ throw new Error(`Could not find a route for slug '${Astro.params.slug}'`);
30
21
  }
31
22
 
23
+ // PageTitle override will skip rendering the default Starlight title
24
+ Astro.locals._stlStarlightPage = {
25
+ skipRenderingStarlightTitle: route.props.kind === 'readme' ? false : true,
26
+ };
27
+
32
28
  const readmeContent = await getReadmeContent(spec, route.props.language);
33
- const readme =
34
- route.props.kind === "readme"
35
- ? await astroMarkdownRender(readmeContent ?? "")
36
- : null;
29
+ const readme = route.props.kind === 'readme' ? await astroMarkdownRender(readmeContent ?? '') : null;
37
30
 
38
- const resource = route.props.stainlessPath
39
- ? getResourceFromSpec(route.props.stainlessPath, spec)
40
- : null;
31
+ const resource = route.props.stainlessPath ? getResourceFromSpec(route.props.stainlessPath, spec) : null;
41
32
 
42
33
  const pageNav =
43
- route.props.kind === "resource" && resource
34
+ route.props.kind === 'resource' && resource
44
35
  ? buildPageNavigation(resource)
45
- : route.props.kind === "readme" && readme?.metadata
36
+ : route.props.kind === 'readme' && readme?.metadata
46
37
  ? readme?.metadata.headings
47
38
  : [];
48
39
 
@@ -50,38 +41,27 @@ const props = route.props;
50
41
 
51
42
  if (readme) {
52
43
  const repo = spec.metadata?.[props.language]?.code_url;
53
- readme.code = readme.code.replace(
54
- /<a href="(?!(?:https?:\/\/|\/\/))([^"]+)"/g,
55
- `<a href="${repo}/$1"`);
56
- props.title = readme.metadata.headings[0].text ?? "Overview";
44
+ readme.code = readme.code.replace(/<a href="(?!(?:https?:\/\/|\/\/))([^"]+)"/g, `<a href="${repo}/$1"`);
45
+ props.title = readme.metadata.headings[0]!.text ?? 'Overview';
57
46
  }
58
-
59
47
  ---
60
48
 
61
-
62
49
  <StarlightPage
63
50
  headings={pageNav}
64
51
  frontmatter={{
65
52
  title: props?.title,
66
53
  head: [
67
54
  {
68
- tag: "link",
55
+ tag: 'link',
69
56
  attrs: {
70
- rel: "alternate",
71
- type: "text/markdown",
72
- href: `${BASE_PATH}/${Astro.params.slug}.md`
73
- }
74
- }
57
+ rel: 'alternate',
58
+ type: 'text/markdown',
59
+ href: `${BASE_PATH}/${Astro.params.slug}.md`,
60
+ },
61
+ },
75
62
  ],
76
63
  pagefind: false,
77
- tableOfContents: ["resource", "readme"].includes(props.kind)
78
- ? { maxHeadingLevel: 6 }
79
- : false,
80
- // @ts-ignore
81
- stainlessStarlight: {
82
- basePath: BASE_PATH,
83
- ...props,
84
- },
64
+ tableOfContents: ['resource', 'readme'].includes(props.kind) ? { maxHeadingLevel: 6 } : false,
85
65
  }}
86
66
  >
87
67
  {
@@ -97,7 +77,9 @@ if (readme) {
97
77
  transformRequestSnippet={MIDDLEWARE.transformRequestSnippet}
98
78
  />
99
79
 
100
- <style is:inline>
80
+ <style
81
+ is:inline
82
+ set:text={`
101
83
  #stldocs-snippet-title {
102
84
  display: flex;
103
85
  gap: 5px;
@@ -105,61 +87,53 @@ if (readme) {
105
87
 
106
88
  .stldocs-snippet-code:not(.stldocs-snippet-response .stldocs-snippet-code) {
107
89
  padding: 0 !important;
108
-
90
+
109
91
  .astro-code {
110
92
  padding: 1rem;
111
93
  }
112
94
  }
113
95
 
114
-
115
96
  [data-has-sidebar]:not([data-has-toc]) .sl-container {
116
97
  max-width: 1428px;
117
98
  }
118
-
119
- .content-panel:nth-of-type(1) {
120
- display: none;
121
- }
122
- .content-panel:nth-of-type(2) .stl-page-nav-container {
123
- display: none;
124
- }
125
-
126
- .content-panel:nth-of-type(2) .stldocs-root .stl-page-nav-container {
127
- display: flex;
128
- }
129
- </style>
99
+ `}
100
+ />
130
101
  </div>
131
102
  ) : (
132
103
  <>
133
104
  <Fragment set:html={readme?.code} />
134
- <style is:inline>
135
- .sl-markdown-content h1:first-of-type {
136
- display: none;
137
- }
105
+ <style
106
+ is:inline
107
+ set:text={`
108
+ .sl-markdown-content h1:first-of-type {
109
+ display: none;
110
+ }
138
111
 
139
- .sl-markdown-content img {
140
- display: inline-block;
141
- vertical-align: text-bottom;
142
- }
112
+ .sl-markdown-content img {
113
+ display: inline-block;
114
+ vertical-align: text-bottom;
115
+ }
143
116
 
144
- .sl-markdown-content .octicon {
145
- margin-right: 0.2rem;
146
- overflow: visible !important;
147
- -webkit-mask: var(--oct-icon) no-repeat;
148
- mask: var(--oct-icon) no-repeat;
149
- -webkit-mask-size: 100% 100%;
150
- mask-size: 100% 100%;
151
- background-color: currentColor;
152
- color: inherit;
153
- display: inline-block;
154
- vertical-align: text-bottom;
155
- width: 1em;
156
- height: 1em;
157
- }
117
+ .sl-markdown-content .octicon {
118
+ margin-right: 0.2rem;
119
+ overflow: visible !important;
120
+ -webkit-mask: var(--oct-icon) no-repeat;
121
+ mask: var(--oct-icon) no-repeat;
122
+ -webkit-mask-size: 100% 100%;
123
+ mask-size: 100% 100%;
124
+ background-color: currentColor;
125
+ color: inherit;
126
+ display: inline-block;
127
+ vertical-align: text-bottom;
128
+ width: 1em;
129
+ height: 1em;
130
+ }
158
131
 
159
- .sl-markdown-content code {
160
- white-space: pre-wrap;
161
- }
162
- </style>
132
+ .sl-markdown-content code {
133
+ white-space: pre-wrap;
134
+ }
135
+ `}
136
+ />
163
137
  </>
164
138
  )
165
139
  }
@@ -169,3 +143,4 @@ if (readme) {
169
143
  <script src="../globalJs/copy.ts"></script>
170
144
  <script src="../globalJs/tooltip.ts"></script>
171
145
  <script src="../globalJs/code-snippets.ts"></script>
146
+ <script src="../globalJs/method-descriptions.ts"></script>
@@ -1,24 +1,22 @@
1
1
  ---
2
2
  import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
3
- import { BASE_PATH, EXCLUDE_LANGUAGES } from 'virtual:stl-starlight-virtual-module';
3
+ import { EXCLUDE_LANGUAGES } from 'virtual:stl-starlight-virtual-module';
4
4
  import { cmsClient } from '../cms/client';
5
- import type { DocsLanguage } from '@stainless-api/docs-ui/src/routing';
6
-
7
- import '@stainless-api/docs-ui/src/styles/resets.css';
8
- import '@stainless-api/docs-ui/src/styles/primitives.css';
9
- import '@stainless-api/docs-ui/src/styles/main.css';
10
- import '@stainless-api/docs-ui/src/styles/snippets.css';
11
- // TODO: fix variables.css import
12
- // import '../components/variables.css';
5
+ import type { DocsLanguage } from '@stainless-api/docs-ui/routing';
13
6
  import { RenderLibraries, RenderSpecOverview, type SpecMetadata } from '../react/Routing';
14
7
 
15
8
  const spec = await cmsClient.getSpec();
16
9
 
17
10
  const languages: DocsLanguage[] = spec.docs!.languages ?? ['http'];
18
- const metadata = languages
11
+ const metadata: SpecMetadata = languages
19
12
  .filter((language) => !['http', 'terraform'].includes(language) && spec.metadata[language])
20
13
  .filter((language) => !EXCLUDE_LANGUAGES.includes(language))
21
- .map((language) => [language, spec.metadata[language]]) as SpecMetadata;
14
+ .map<SpecMetadata[number]>((language) => [language, spec.metadata[language]!]);
15
+
16
+ // PageTitle override will skip rendering the default Starlight title
17
+ Astro.locals._stlStarlightPage = {
18
+ hasMarkdownRoute: false,
19
+ };
22
20
  ---
23
21
 
24
22
  <StarlightPage
@@ -26,15 +24,11 @@ const metadata = languages
26
24
  title: 'API Reference',
27
25
  pagefind: false,
28
26
  tableOfContents: false,
29
- stainlessStarlight: {
30
- basePath: BASE_PATH,
31
- language: 'http',
32
- },
33
27
  }}
34
28
  >
35
29
  <h3>Libraries</h3>
36
30
 
37
- <div class="stldocs-root language-blocks stl-ui-not-prose">
31
+ <div class="stldocs-root language-blocks stl-ui-not-prose not-content">
38
32
  <RenderLibraries metadata={metadata} />
39
33
  </div>
40
34
 
@@ -1,12 +1,12 @@
1
1
  import type { APIRoute, GetStaticPaths } from 'astro';
2
2
  import { cmsClient } from '../cms/client';
3
3
  import { generateDocsRoutes, getReadmeContent } from '../react/Routing';
4
- import { getResourceFromSpec } from '@stainless-api/docs-ui/src/utils';
4
+ import { getResourceFromSpec } from '@stainless-api/docs-ui/utils';
5
5
 
6
- import { renderMarkdown } from '@stainless-api/docs-ui/src/markdown';
6
+ import { renderMarkdown } from '@stainless-api/docs-ui/markdown';
7
7
 
8
- import { parseStainlessPath, type DocsLanguage } from '@stainless-api/docs-ui/src/routing';
9
- import type { EnvironmentType } from '@stainless-api/docs-ui/src/markdown/utils';
8
+ import { parseStainlessPath, type DocsLanguage } from '@stainless-api/docs-ui/routing';
9
+ import type { EnvironmentType } from '@stainless-api/docs-ui/markdown/utils';
10
10
  import { PROPERTY_SETTINGS, MIDDLEWARE } from 'virtual:stl-starlight-virtual-module';
11
11
 
12
12
  type RouteProps = {
@@ -26,7 +26,7 @@ export const GET: APIRoute<RouteProps> = async ({ props }) => {
26
26
  if (props.kind === 'readme') {
27
27
  const readmeContent = await getReadmeContent(spec, props.language);
28
28
  return new Response(readmeContent, {
29
- headers: { 'Content-Type': 'text/markdown' },
29
+ headers: { 'Content-Type': 'text/plain' },
30
30
  });
31
31
  }
32
32
 
@@ -47,11 +47,11 @@ export const GET: APIRoute<RouteProps> = async ({ props }) => {
47
47
  },
48
48
  };
49
49
 
50
- const target = props.kind === 'http_method' && parsed?.method ? resource.methods[parsed.method] : resource;
50
+ const target = props.kind === 'http_method' && parsed?.method ? resource.methods[parsed.method]! : resource;
51
51
  const output = renderMarkdown(env, target);
52
52
 
53
53
  return new Response(output, {
54
- headers: { 'Content-Type': 'text/markdown' },
54
+ headers: { 'Content-Type': 'text/plain' },
55
55
  });
56
56
  };
57
57