@stainless-api/docs 0.1.0-beta.105 → 0.1.0-beta.107

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,17 @@
1
1
  # @stainless-api/docs
2
2
 
3
+ ## 0.1.0-beta.107
4
+
5
+ ### Minor Changes
6
+
7
+ - 971a12f: Adds an experimental flag to disable indexing
8
+
9
+ ## 0.1.0-beta.106
10
+
11
+ ### Patch Changes
12
+
13
+ - a8ed299: Adds the ability for AI chat to move into a sidebar “panel” position.
14
+
3
15
  ## 0.1.0-beta.105
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stainless-api/docs",
3
- "version": "0.1.0-beta.105",
3
+ "version": "0.1.0-beta.107",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -0,0 +1,28 @@
1
+ import { AstroIntegration, type AstroIntegrationLogger } from 'astro';
2
+ import { getSharedLogger } from './getSharedLogger';
3
+
4
+ export default function conditionalIntegration({
5
+ condition,
6
+ integration,
7
+ reason,
8
+ }: {
9
+ condition: boolean;
10
+ integration: AstroIntegration;
11
+ reason?: string | undefined;
12
+ }): AstroIntegration {
13
+ if (condition) {
14
+ return integration;
15
+ }
16
+ return {
17
+ name: integration.name,
18
+ hooks: Object.fromEntries(
19
+ Object.keys(integration.hooks).map((hookName) => [
20
+ hookName,
21
+ ({ logger: localLogger }: { logger: AstroIntegrationLogger }) => {
22
+ const logger = getSharedLogger({ fallback: localLogger });
23
+ logger.info(`Skipping ${integration.name} integration. Reason: ${reason ?? 'not provided'}`);
24
+ },
25
+ ]),
26
+ ),
27
+ };
28
+ }
package/stl-docs/index.ts CHANGED
@@ -25,6 +25,7 @@ import { stainlessDocsVectorProseIndexing } from './proseDocSync';
25
25
  import { stainlessDocsAlgoliaProseIndexing } from './proseSearchIndexing';
26
26
  import { stainlessStarlight } from '../plugin';
27
27
  import { getFontRoles, flattenFonts } from './fonts';
28
+ import conditionalIntegration from '../shared/conditionalIntegration';
28
29
 
29
30
  export * from '../plugin';
30
31
 
@@ -189,14 +190,14 @@ function stainlessDocsIntegration(
189
190
  } satisfies typeof StlDocsVirtualModule),
190
191
 
191
192
  'virtual:stl-docs/components/AiChat.tsx': `
192
- ${
193
- config.aiChat
194
- ? `export { default } from ${JSON.stringify(config.aiChat.chatComponentPath)};`
195
- : // export null when no AI chat component is provided
196
- `export default null;`
197
- }
198
- export const STAINLESS_PROJECT = ${config.apiReference ? JSON.stringify(config.apiReference.stainlessProject) : 'undefined'};
199
- `,
193
+ ${
194
+ config.aiChat
195
+ ? `export { default } from ${JSON.stringify(config.aiChat.chatComponentPath)};`
196
+ : // export null when no AI chat component is provided
197
+ `export default null;`
198
+ }
199
+ export const STAINLESS_PROJECT = ${config.apiReference ? JSON.stringify(config.apiReference.stainlessProject) : 'undefined'};
200
+ `,
200
201
  }),
201
202
  );
202
203
 
@@ -284,11 +285,20 @@ export function stainlessDocs(config: StainlessDocsUserConfig): StarlightPlugin[
284
285
  react(),
285
286
  stainlessDocsStarlightIntegration(normalizedConfig),
286
287
  stainlessDocsIntegration(normalizedConfig, apiReferenceBasePath),
287
- stainlessDocsMarkdownRenderer({
288
- enabled: normalizedConfig.enableProseMarkdownRendering,
289
- apiReferenceBasePath,
288
+ conditionalIntegration({
289
+ condition: !config.experimental?.disableProseMarkdownRendering,
290
+ integration: stainlessDocsMarkdownRenderer({ apiReferenceBasePath }),
291
+ reason: 'disabled by experimental config "disableProseMarkdownRendering"',
292
+ }),
293
+ conditionalIntegration({
294
+ condition: !config.experimental?.disableStainlessProseIndexing,
295
+ integration: stainlessDocsAlgoliaProseIndexing({ apiReferenceBasePath }),
296
+ reason: 'disabled by experimental config "disableStainlessProseIndexing"',
297
+ }),
298
+ conditionalIntegration({
299
+ condition: !config.experimental?.disableStainlessProseIndexing,
300
+ integration: stainlessDocsVectorProseIndexing(normalizedConfig, apiReferenceBasePath),
301
+ reason: 'disabled by experimental config "disableStainlessProseIndexing"',
290
302
  }),
291
- stainlessDocsAlgoliaProseIndexing({ apiReferenceBasePath }),
292
- stainlessDocsVectorProseIndexing(normalizedConfig, apiReferenceBasePath),
293
303
  ];
294
304
  }
@@ -77,6 +77,7 @@ export type StainlessDocsUserConfig = {
77
77
  * @default false
78
78
  */
79
79
  disableProseMarkdownRendering?: boolean;
80
+ disableStainlessProseIndexing?: boolean;
80
81
  aiChat?: { chatComponentPath: string };
81
82
  /**
82
83
  * Whether to link group titles to overview pages. Note: overview pages must already be present in the sidebar for this to work.
@@ -172,6 +173,8 @@ function normalizeConfig(userConfig: StainlessDocsUserConfig) {
172
173
  enableClientRouter: userConfig.experimental?.enableClientRouter ?? false,
173
174
  apiReference: userConfig.apiReference ?? null,
174
175
  sidebar: userConfig.sidebar,
176
+ enableStainlessProseIndexing:
177
+ userConfig.experimental?.disableStainlessProseIndexing === true ? false : true,
175
178
  enableProseMarkdownRendering:
176
179
  userConfig.experimental?.disableProseMarkdownRendering === true ? false : true,
177
180
  contextMenu: userConfig.contextMenu ?? true,
@@ -201,7 +201,7 @@ async function deleteDocuments(
201
201
  try {
202
202
  const response = await docsApiRequest(
203
203
  'DELETE',
204
- `/api/docs-sites/${docsSiteId}/documents/${encodeURIComponent(docId)}?project=${encodeURIComponent(project)}`,
204
+ `/api/docs-sites/${docsSiteId}/documents?documentId=${encodeURIComponent(docId)}&project=${encodeURIComponent(project)}`,
205
205
  apiKey,
206
206
  );
207
207
  if (response.ok) {
@@ -7,29 +7,21 @@ import { bold } from '../../shared/terminalUtils';
7
7
  import { getProsePages } from '../../shared/getProsePages';
8
8
 
9
9
  export function stainlessDocsMarkdownRenderer({
10
- enabled,
11
10
  apiReferenceBasePath,
12
11
  }: {
13
- enabled: boolean;
14
12
  apiReferenceBasePath: string | null;
15
13
  }): AstroIntegration {
16
14
  return {
17
15
  name: 'stl-docs-md',
18
16
  hooks: {
19
17
  'astro:config:setup': ({ addMiddleware }) => {
20
- if (enabled) {
21
- addMiddleware({
22
- entrypoint: resolveSrcFile('/stl-docs/proseMarkdown/proseMarkdownMiddleware.ts'),
23
- order: 'post',
24
- });
25
- }
18
+ addMiddleware({
19
+ entrypoint: resolveSrcFile('/stl-docs/proseMarkdown/proseMarkdownMiddleware.ts'),
20
+ order: 'post',
21
+ });
26
22
  },
27
23
  'astro:build:done': async ({ logger: localLogger, dir }) => {
28
24
  const logger = getSharedLogger({ fallback: localLogger });
29
- if (!enabled) {
30
- logger.info('Stainless Docs prose Markdown rendering is disabled, skipping...');
31
- return;
32
- }
33
25
  const outputBasePath = dir.pathname;
34
26
  const pagesToRender = await getProsePages({ apiReferenceBasePath, outputBasePath });
35
27
 
package/styles/page.css CHANGED
@@ -39,13 +39,16 @@
39
39
  display: grid;
40
40
 
41
41
  /* TODO: verify that env-safe-area-inset is behaving as we expect */
42
- --stl-viewport-width: calc(100vw - env(safe-area-inset-left, 0) - env(safe-area-inset-right, 0));
42
+ --stl-viewport-width: calc(
43
+ 100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) -
44
+ var(--stl-chat-panel-width, 0px)
45
+ );
43
46
  --stl-page-gutter-left: calc(
44
- env(safe-area-inset-left, 0) +
47
+ env(safe-area-inset-left, 0px) +
45
48
  max(var(--stl-page-min-padding), (var(--stl-viewport-width) - var(--stl-page-max-width)) / 2)
46
49
  );
47
50
  --stl-page-gutter-right: calc(
48
- env(safe-area-inset-right, 0) +
51
+ env(safe-area-inset-right, 0px) +
49
52
  max(var(--stl-page-min-padding), (var(--stl-viewport-width) - var(--stl-page-max-width)) / 2)
50
53
  );
51
54
 
@@ -183,7 +186,7 @@ header > .header {
183
186
  max-width: min(var(--stl-two-column-content-max-width), 100%);
184
187
  padding-inline-start: clamp(
185
188
  var(--stl-content-padding),
186
- var(--stl-page-gutter-right) - env(safe-area-inset-right, 0),
189
+ var(--stl-page-gutter-right) - env(safe-area-inset-right, 0px),
187
190
  var(--stl-content-padding) * 2
188
191
  );
189
192
  padding-inline-end: 0;