@stainless-api/docs 0.1.0-beta.68 → 0.1.0-beta.69

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @stainless-api/docs
2
2
 
3
+ ## 0.1.0-beta.69
4
+
5
+ ### Patch Changes
6
+
7
+ - 67aa6b5: improves UI for algolia search on desktop and mobile
8
+ - bf9bdd4: Remove old/broken mintlify-compat Steps implementation in favor of the new component
9
+ - 68f4528: Adds support for opengraph images
10
+ - Updated dependencies [67aa6b5]
11
+ - @stainless-api/docs-search@0.1.0-beta.6
12
+ - @stainless-api/docs-ui@0.1.0-beta.54
13
+
3
14
  ## 0.1.0-beta.68
4
15
 
5
16
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stainless-api/docs",
3
- "version": "0.1.0-beta.68",
3
+ "version": "0.1.0-beta.69",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -17,7 +17,11 @@
17
17
  "./font-imports": "./styles/fonts.css",
18
18
  "./components": "./stl-docs/components/index.ts",
19
19
  "./components/scripts": "./stl-docs/components/scripts.ts",
20
- "./components/Head": "./stl-docs/components/Head.astro"
20
+ "./docs-config": "./stl-docs/loadStlDocsConfig.ts",
21
+ "./cms-client": "./plugin/cms/client.ts",
22
+ "./generate-docs-routes": "./plugin/helpers/generateDocsRoutes.ts",
23
+ "./components/Head": "./stl-docs/components/Head.astro",
24
+ "./components/ContentBreadcrumbs": "./stl-docs/components/ContentBreadcrumbs.tsx"
21
25
  },
22
26
  "keywords": [],
23
27
  "author": "",
@@ -36,6 +40,7 @@
36
40
  "@astrojs/markdown-remark": "^6.3.10",
37
41
  "@astrojs/react": "^4.4.2",
38
42
  "@stainless-api/sdk": "0.1.0-alpha.19",
43
+ "astro-expressive-code": "^0.41.3",
39
44
  "cheerio": "^1.1.2",
40
45
  "clsx": "^2.1.1",
41
46
  "dotenv": "17.2.3",
@@ -53,8 +58,8 @@
53
58
  "vite-plugin-prebundle-workers": "^0.2.0",
54
59
  "web-worker": "^1.5.0",
55
60
  "yaml": "^2.8.2",
56
- "@stainless-api/docs-search": "0.1.0-beta.5",
57
- "@stainless-api/docs-ui": "0.1.0-beta.53",
61
+ "@stainless-api/docs-search": "0.1.0-beta.6",
62
+ "@stainless-api/docs-ui": "0.1.0-beta.54",
58
63
  "@stainless-api/ui-primitives": "0.1.0-beta.40"
59
64
  },
60
65
  "devDependencies": {
@@ -1,7 +1,7 @@
1
1
  ---
2
- import { Icon } from '@astrojs/starlight/components';
3
2
  import { DocsSearch } from './SearchIsland';
4
3
  import { Button } from '@stainless-api/ui-primitives';
4
+ import { SearchIcon, XIcon } from 'lucide-react';
5
5
  ---
6
6
 
7
7
  <site-search>
@@ -13,7 +13,8 @@ import { Button } from '@stainless-api/ui-primitives';
13
13
  variant="outline"
14
14
  className="stl-algolia-search"
15
15
  >
16
- <Icon name="magnifier" />
16
+ <SearchIcon className="icon-search" size={14} />
17
+ <XIcon className="icon-close" size={14} />
17
18
  <span class="sl-hidden md:sl-block" aria-hidden="true">{Astro.locals.t('search.label')}</span>
18
19
  <kbd class="sl-hidden md:sl-flex" style="display: none;">
19
20
  <kbd>{Astro.locals.t('search.ctrlKey')}</kbd><kbd>K</kbd>
@@ -65,4 +66,32 @@ import { Button } from '@stainless-api/ui-primitives';
65
66
  width: unset;
66
67
  flex-grow: 1;
67
68
  }
69
+ .stl-algolia-search {
70
+ padding: 0;
71
+ }
72
+ @media (min-width: 50rem) {
73
+ .stl-algolia-search {
74
+ padding: 8px 10px;
75
+ }
76
+ }
77
+
78
+ .stl-algolia-search {
79
+ .icon-search {
80
+ display: inline;
81
+ }
82
+
83
+ .icon-close {
84
+ display: none;
85
+ }
86
+ }
87
+
88
+ site-search:has(#stldocs-search[data-stldocs-modal-open='true']) .stl-algolia-search {
89
+ .icon-search {
90
+ display: none;
91
+ }
92
+
93
+ .icon-close {
94
+ display: inline;
95
+ }
96
+ }
68
97
  </style>
@@ -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',
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
+ }
@@ -14,7 +14,6 @@ import type * as SDKJSON from '@stainless/sdk-json';
14
14
  import { LanguageNames, SupportedLanguageSyntaxes, type DocsLanguage } from '@stainless-api/docs-ui/routing';
15
15
 
16
16
  import {
17
- generateRouteList,
18
17
  generateRoute,
19
18
  parseStainlessPath,
20
19
  walkTree,
@@ -67,30 +66,6 @@ import { AIDropdown } from '../../stl-docs/components/AIDropdown';
67
66
  import { ChevronsUpDownIcon } from 'lucide-react';
68
67
  import { MethodDescription } from '../components/MethodDescription';
69
68
 
70
- export function generateDocsRoutes(spec: SDKJSON.Spec) {
71
- const paths = generateRouteList({
72
- spec,
73
- excludeLanguages: EXCLUDE_LANGUAGES as DocsLanguage[],
74
- });
75
- const readmes = Object.entries(spec.readme)
76
- .filter(([language]) => language !== 'http')
77
- .filter(([language]) => !EXCLUDE_LANGUAGES.includes(language as DocsLanguage))
78
- .map(([language]) => ({
79
- slug: language,
80
- stainlessPath: null,
81
- language: language as DocsLanguage,
82
- title: 'Readme',
83
- kind: 'readme',
84
- }));
85
-
86
- return [...paths, ...readmes].map(({ slug, stainlessPath, language, title, kind }) => {
87
- return {
88
- params: { slug },
89
- props: { stainlessPath, language, title, kind },
90
- };
91
- });
92
- }
93
-
94
69
  function isResourceNonEmpty(resource: SDKJSON.Resource) {
95
70
  return (
96
71
  Object.keys(resource.methods ?? {}).length > 0 ||
@@ -1,15 +1,10 @@
1
1
  ---
2
2
  import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
3
3
  import { cmsClient } from '../cms/client';
4
- import {
5
- getReadmeContent,
6
- generateDocsRoutes,
7
- buildPageNavigation,
8
- RenderSpec,
9
- astroMarkdownRender,
10
- } from '../react/Routing';
4
+ import { getReadmeContent, buildPageNavigation, RenderSpec, astroMarkdownRender } from '../react/Routing';
11
5
  import { getResourceFromSpec } from '@stainless-api/docs-ui/utils';
12
6
  import { BASE_PATH, CONTENT_PANEL_LAYOUT, MIDDLEWARE } from 'virtual:stl-starlight-virtual-module';
7
+ import { generateDocsRoutes } from '../helpers/generateDocsRoutes';
13
8
 
14
9
  const spec = await cmsClient.getSpec();
15
10
  const routes = generateDocsRoutes(spec);
@@ -2,7 +2,7 @@
2
2
  import type { GetStaticPaths } from 'astro';
3
3
  import Docs from './Docs.astro';
4
4
  import { cmsClient } from '../cms/client';
5
- import { generateDocsRoutes } from '../react/Routing';
5
+ import { generateDocsRoutes } from '../helpers/generateDocsRoutes';
6
6
 
7
7
  export const getStaticPaths = (async () => {
8
8
  const spec = await cmsClient.getSpec();
@@ -1,6 +1,6 @@
1
1
  import type { APIRoute, GetStaticPaths } from 'astro';
2
2
  import { cmsClient } from '../cms/client';
3
- import { generateDocsRoutes, getReadmeContent } from '../react/Routing';
3
+ import { getReadmeContent } from '../react/Routing';
4
4
  import { getResourceFromSpec } from '@stainless-api/docs-ui/utils';
5
5
 
6
6
  import { renderMarkdown } from '@stainless-api/docs-ui/markdown';
@@ -8,6 +8,7 @@ import { renderMarkdown } from '@stainless-api/docs-ui/markdown';
8
8
  import { parseStainlessPath, type DocsLanguage } from '@stainless-api/docs-ui/routing';
9
9
  import type { EnvironmentType } from '@stainless-api/docs-ui/markdown/utils';
10
10
  import { PROPERTY_SETTINGS, MIDDLEWARE } from 'virtual:stl-starlight-virtual-module';
11
+ import { generateDocsRoutes } from '../helpers/generateDocsRoutes';
11
12
 
12
13
  type RouteProps = {
13
14
  stainlessPath: string;
@@ -3,13 +3,11 @@ import Tab from './Tab.astro';
3
3
  import Tabs from './Tabs.astro';
4
4
  import Frame from './Frame.astro';
5
5
  import Columns from './Columns.astro';
6
- import Steps from './Steps.astro';
7
- import Step from './Step.astro';
8
6
  import Accordion from './Accordion.astro';
9
7
  import AccordionGroup from './AccordionGroup.astro';
10
8
 
11
9
  export * from './callouts';
12
10
  export * from './Card';
13
11
 
14
- export { Tab, Tabs, Frame, Columns, Steps, Step, AccordionGroup, Accordion };
15
- export { Button } from '@stainless-api/ui-primitives';
12
+ export { Tab, Tabs, Frame, Columns, AccordionGroup, Accordion };
13
+ export { Button, Steps, Step } from '@stainless-api/ui-primitives';
package/stl-docs/index.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import starlight from '@astrojs/starlight';
2
2
  import react from '@astrojs/react';
3
3
  import type { StarlightPlugin } from '@astrojs/starlight/types';
4
- import { stainlessStarlight } from '../plugin';
5
4
  import { disableCalloutSyntaxStarlightPlugin } from './disableCalloutSyntax';
6
5
 
7
6
  import type { AstroIntegration } from 'astro';
@@ -23,6 +22,7 @@ import { resolveSrcFile } from '../resolveSrcFile';
23
22
  import { stainlessDocsMarkdownRenderer } from './proseMarkdown/proseMarkdownIntegration';
24
23
  import { setSharedLogger } from '../shared/getSharedLogger';
25
24
  import { stainlessDocsAlgoliaProseIndexing, stainlessDocsVectorProseIndexing } from './proseSearchIndexing';
25
+ import { stainlessStarlight } from '../plugin';
26
26
 
27
27
  export * from '../plugin';
28
28
 
@@ -244,7 +244,7 @@ function sharedLoggerIntegration(): AstroIntegration {
244
244
  };
245
245
  }
246
246
 
247
- export function stainlessDocs(config: StainlessDocsUserConfig) {
247
+ export function stainlessDocs(config: StainlessDocsUserConfig): StarlightPlugin[] {
248
248
  const normalizedConfigResult = parseStlDocsConfig(config);
249
249
  if (normalizedConfigResult.result === 'error') {
250
250
  // TODO: would be good to use the astro logger somehow
@@ -40,7 +40,7 @@ type ExperimentalStarlightCompatibilityConfig = Pick<
40
40
  'components' | 'routeMiddleware' | 'plugins'
41
41
  >;
42
42
 
43
- type Tabs = {
43
+ export type Tabs = {
44
44
  label: string;
45
45
  link: string;
46
46
  sidebar?: SidebarEntry[];
package/styles/search.css CHANGED
@@ -57,8 +57,6 @@ site-search {
57
57
  site-search {
58
58
  > button {
59
59
  border-radius: var(--sl-button-border-radius);
60
- padding-inline-start: var(--sl-button-padding-x);
61
- padding-inline-end: var(--sl-button-padding-x);
62
60
  width: 100%;
63
61
  max-width: 30rem;
64
62
  justify-content: start;
@@ -6,10 +6,11 @@ declare module 'virtual:stl-starlight-virtual-module' {
6
6
  import type { CreateShikiHighlighterOptions } from '@astrojs/markdown-remark';
7
7
  import type { PropertySettingsType } from '@stainless-api/docs-ui/contexts';
8
8
  import type { StlStarlightMiddleware } from '@stainless-api/docs/plugin/MiddlewareTypes';
9
+ import type { DocsLanguage } from '@stainless-api/docs-ui/routing';
9
10
 
10
11
  export const BASE_PATH: string;
11
12
  export const CMS_PORT: number;
12
- export const EXCLUDE_LANGUAGES: string[];
13
+ export const EXCLUDE_LANGUAGES: DocsLanguage[];
13
14
  export const DEFAULT_LANGUAGE: string;
14
15
  export const BREADCRUMB_CONFIG: {
15
16
  includeCurrentPage?: boolean;
@@ -1,56 +0,0 @@
1
- ---
2
- export interface Props {
3
- title?: string;
4
- }
5
-
6
- const { title } = Astro.props;
7
- ---
8
-
9
- <li class="stl-ui-mintlify-compat-step" data-stl-ui-element>
10
- <div class="stl-ui-mintlify-compat-step-step-number"></div>
11
- <div>
12
- <p class="stl-ui-mintlify-compat-step-title">{title}</p>
13
- <div class="stl-ui-mintlify-compat-step-content"><slot /></div>
14
- </div>
15
- </li>
16
-
17
- <style>
18
- .stl-ui-mintlify-compat-step {
19
- display: flex;
20
-
21
- &:not(:first-child) {
22
- margin-top: 1rem;
23
- }
24
- }
25
-
26
- .stl-ui-mintlify-compat-step-step-number {
27
- margin-right: 1rem;
28
- display: flex;
29
- align-items: top;
30
- justify-content: center;
31
- margin-top: 4px;
32
-
33
- &::before {
34
- counter-increment: ui-steps;
35
- content: counter(ui-steps);
36
- border-radius: 50%;
37
- height: 1.5rem;
38
- width: 1.5rem;
39
- font-size: 0.8rem;
40
- color: var(--stl-color-foreground);
41
- font-weight: 600;
42
- background-color: var(--stl-color-faint-background);
43
- display: flex;
44
- align-items: center;
45
- justify-content: center;
46
- }
47
- }
48
-
49
- .stl-ui-mintlify-compat-step-title {
50
- font-weight: 600;
51
- color: var(--stl-color-foreground);
52
- }
53
- .stl-ui-mintlify-compat-step-content {
54
- margin-top: 0.5rem;
55
- }
56
- </style>
@@ -1,15 +0,0 @@
1
- <ol class="stl-ui-mintlify-compat-steps"><slot /></ol>
2
-
3
- <style>
4
- .stl-ui-mintlify-compat-steps {
5
- counter-reset: ui-steps;
6
- list-style: none;
7
- margin: 0;
8
- padding: 0;
9
- margin-top: 1rem;
10
-
11
- * {
12
- margin: 0;
13
- }
14
- }
15
- </style>