@stainless-api/docs 0.1.0-beta.65 → 0.1.0-beta.67

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,21 @@
1
1
  # @stainless-api/docs
2
2
 
3
+ ## 0.1.0-beta.67
4
+
5
+ ### Patch Changes
6
+
7
+ - a59d5f7: Pass current page context through as “intent”
8
+ - Updated dependencies [e9567b0]
9
+ - @stainless-api/ui-primitives@0.1.0-beta.40
10
+ - @stainless-api/docs-ui@0.1.0-beta.53
11
+ - @stainless-api/docs-search@0.1.0-beta.5
12
+
13
+ ## 0.1.0-beta.66
14
+
15
+ ### Patch Changes
16
+
17
+ - af54129: fix: index missing prose docs for search
18
+
3
19
  ## 0.1.0-beta.65
4
20
 
5
21
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stainless-api/docs",
3
- "version": "0.1.0-beta.65",
3
+ "version": "0.1.0-beta.67",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -40,7 +40,7 @@
40
40
  "clsx": "^2.1.1",
41
41
  "dotenv": "17.2.3",
42
42
  "get-port": "^7.1.0",
43
- "lucide-react": "^0.561.0",
43
+ "lucide-react": "^0.562.0",
44
44
  "marked": "^17.0.1",
45
45
  "node-html-parser": "^7.0.1",
46
46
  "rehype-parse": "^9.0.1",
@@ -48,19 +48,19 @@
48
48
  "remark-gfm": "^4.0.1",
49
49
  "remark-github-alerts": "^0.1.1",
50
50
  "remark-stringify": "^11.0.0",
51
- "shiki": "^3.19.0",
51
+ "shiki": "^3.20.0",
52
52
  "unified": "^11.0.5",
53
53
  "vite-plugin-prebundle-workers": "^0.2.0",
54
54
  "web-worker": "^1.5.0",
55
55
  "yaml": "^2.8.2",
56
- "@stainless-api/docs-ui": "0.1.0-beta.52",
57
- "@stainless-api/docs-search": "0.1.0-beta.4",
58
- "@stainless-api/ui-primitives": "0.1.0-beta.39"
56
+ "@stainless-api/docs-search": "0.1.0-beta.5",
57
+ "@stainless-api/docs-ui": "0.1.0-beta.53",
58
+ "@stainless-api/ui-primitives": "0.1.0-beta.40"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@astrojs/check": "^0.9.6",
62
62
  "@markdoc/markdoc": "^0.5.4",
63
- "@types/node": "24.10.3",
63
+ "@types/node": "24.10.4",
64
64
  "@types/react": "19.2.7",
65
65
  "@types/react-dom": "^19.2.3",
66
66
  "react": "^19.2.3",
@@ -68,7 +68,7 @@
68
68
  "tsx": "^4.21.0",
69
69
  "typescript": "5.9.3",
70
70
  "vite": "^6.4.1",
71
- "zod": "^4.1.13",
71
+ "zod": "^4.3.5",
72
72
  "@stainless/eslint-config": "0.1.0-beta.1",
73
73
  "@stainless/sdk-json": "^0.1.0-beta.2"
74
74
  },
@@ -0,0 +1,42 @@
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
+ // Filter out API reference pages
31
+ const pagesToRender = htmlFiles.filter((absPath) => {
32
+ if (!apiReferenceBasePath) {
33
+ return true;
34
+ }
35
+ const relPath = relative(outputBasePath, absPath);
36
+ // Normalize by removing leading/trailing slashes from apiReferenceBasePath
37
+ const normalizedApiPath = apiReferenceBasePath.replace(/^\/+|\/+$/g, '');
38
+ return !relPath.startsWith(normalizedApiPath);
39
+ });
40
+
41
+ return pagesToRender;
42
+ }
@@ -1,8 +1,14 @@
1
1
  import type { DocsLanguage } from '@stainless-api/docs-ui/routing';
2
2
  import AiChat, { STAINLESS_PROJECT } from 'virtual:stl-docs/components/AiChat.tsx';
3
3
 
4
- export default function AiChatIsland({ currentLanguage }: { currentLanguage: DocsLanguage | undefined }) {
4
+ export default function AiChatIsland({
5
+ currentLanguage,
6
+ siteTitle,
7
+ }: {
8
+ currentLanguage: DocsLanguage | undefined;
9
+ siteTitle: string | undefined;
10
+ }) {
5
11
  if (!AiChat) throw new Error('AiChatIsland was rendered but could not load AiChat component');
6
12
  if (!STAINLESS_PROJECT) return null;
7
- return <AiChat projectId={STAINLESS_PROJECT} language={currentLanguage} />;
13
+ return <AiChat projectId={STAINLESS_PROJECT} language={currentLanguage} siteTitle={siteTitle} />;
8
14
  }
@@ -2,6 +2,10 @@
2
2
  import Default from '@astrojs/starlight/components/PageFrame.astro';
3
3
  import AiChat from 'virtual:stl-docs/components/AiChat.tsx'; // conditionally resolves to null if ai chat module is not injected
4
4
  import AiChatIsland from './AiChatIsland.tsx'; // entrypoint for client island can’t be a virtual module
5
+
6
+ import starlightConfig from 'virtual:starlight/user-config';
7
+ const locale = Astro.currentLocale ?? starlightConfig.defaultLocale.lang;
8
+ const siteTitle = locale && starlightConfig.title[locale];
5
9
  ---
6
10
 
7
11
  <Default>
@@ -10,5 +14,5 @@ import AiChatIsland from './AiChatIsland.tsx'; // entrypoint for client island c
10
14
 
11
15
  <slot />
12
16
 
13
- {!!AiChat && <AiChatIsland client:load currentLanguage={Astro.locals.language} />}
17
+ {!!AiChat && <AiChatIsland client:load currentLanguage={Astro.locals.language} siteTitle={siteTitle} />}
14
18
  </Default>
package/stl-docs/index.ts CHANGED
@@ -271,6 +271,6 @@ export function stainlessDocs(config: StainlessDocsUserConfig) {
271
271
  enabled: normalizedConfig.enableProseMarkdownRendering,
272
272
  apiReferenceBasePath,
273
273
  }),
274
- stainlessDocsProseIndexing(),
274
+ stainlessDocsProseIndexing({ apiReferenceBasePath }),
275
275
  ];
276
276
  }
@@ -1,10 +1,10 @@
1
1
  import type { AstroIntegration } from 'astro';
2
- import { readdir, readFile, writeFile } from 'fs/promises';
2
+ import { readFile, writeFile } from 'fs/promises';
3
3
  import { toMarkdown } from './toMarkdown';
4
4
  import { resolveSrcFile } from '../../resolveSrcFile';
5
5
  import { getSharedLogger } from '../../shared/getSharedLogger';
6
- import { join, relative } from 'path';
7
6
  import { bold } from '../../shared/terminalUtils';
7
+ import { getProsePages } from '../../shared/getProsePages';
8
8
 
9
9
  export function stainlessDocsMarkdownRenderer({
10
10
  enabled,
@@ -31,32 +31,7 @@ export function stainlessDocsMarkdownRenderer({
31
31
  return;
32
32
  }
33
33
  const outputBasePath = dir.pathname;
34
-
35
- // Read all HTML files from output directory, and not from assets.
36
- // We cannot use the `assets` map here because it is not guaranteed to
37
- // contain all files, especially if they were generated by other integrations.
38
- // Other astro integrations may hijack the "[...slug]" entrypoint, and any files
39
- // previously in the [...slug] asset map entry would be lost (this is where starlight stores
40
- // its prose HTML files).
41
- const allFiles = await readdir(outputBasePath, {
42
- recursive: true,
43
- withFileTypes: true,
44
- });
45
-
46
- const htmlFiles = allFiles
47
- .filter((file) => file.isFile() && file.name.endsWith('.html'))
48
- .map((file) => join(file.parentPath, file.name));
49
-
50
- // Filter out API reference pages
51
- const pagesToRender = htmlFiles.filter((absPath) => {
52
- if (!apiReferenceBasePath) {
53
- return true;
54
- }
55
- const relPath = relative(outputBasePath, absPath);
56
- // Normalize by removing leading/trailing slashes from apiReferenceBasePath
57
- const normalizedApiPath = apiReferenceBasePath.replace(/^\/+|\/+$/g, '');
58
- return !relPath.startsWith(normalizedApiPath);
59
- });
34
+ const pagesToRender = await getProsePages({ apiReferenceBasePath, outputBasePath });
60
35
 
61
36
  logger.info(bold(`Building ${pagesToRender.length} Markdown pages for prose content`));
62
37
 
@@ -1,5 +1,6 @@
1
1
  import type { AstroIntegration } from 'astro';
2
2
  import { readFile } from 'fs/promises';
3
+ import { getProsePages } from '../shared/getProsePages';
3
4
  import { getSharedLogger } from '../shared/getSharedLogger';
4
5
  import { bold } from '../shared/terminalUtils';
5
6
  import { buildProseIndex } from '@stainless-api/docs-search/providers/algolia';
@@ -306,11 +307,15 @@ export function* indexHTML(content: string, root: string, pattern: string) {
306
307
  const root = 'main';
307
308
  const pattern = 'h1, h2, h3, h4, h5, h6, p, li';
308
309
 
309
- export function stainlessDocsProseIndexing(): AstroIntegration {
310
+ export function stainlessDocsProseIndexing({
311
+ apiReferenceBasePath,
312
+ }: {
313
+ apiReferenceBasePath: string | null;
314
+ }): AstroIntegration {
310
315
  return {
311
316
  name: 'stl-docs-prose-indexing',
312
317
  hooks: {
313
- 'astro:build:done': async ({ assets, logger: localLogger, dir }) => {
318
+ 'astro:build:done': async ({ logger: localLogger, dir }) => {
314
319
  const logger = getSharedLogger({ fallback: localLogger });
315
320
  const outputBasePath = dir.pathname;
316
321
 
@@ -325,13 +330,7 @@ export function stainlessDocsProseIndexing(): AstroIntegration {
325
330
  return;
326
331
  }
327
332
 
328
- const starlightPagePatterns = ['/[...slug]'];
329
- const pagesToRender = Array.from(assets.entries())
330
- .filter(([k]) => starlightPagePatterns.includes(k))
331
- .map(([, v]) => v)
332
- .flat()
333
- .map((v) => v.pathname);
334
-
333
+ const pagesToRender = await getProsePages({ apiReferenceBasePath, outputBasePath });
335
334
  logger.info(bold(`Indexing ${pagesToRender.length} prose pages for search`));
336
335
 
337
336
  const objects = [];
@@ -56,6 +56,7 @@ declare module 'virtual:stl-docs/components/AiChat.tsx' {
56
56
  | import('react').ComponentType<{
57
57
  projectId: string;
58
58
  language: import('@stainless-api/docs-ui/routing').DocsLanguage | undefined;
59
+ siteTitle: string | undefined;
59
60
  }>
60
61
  | null;
61
62
  export default AiChatComponent;