@stainless-api/docs 0.1.0-beta.106 → 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
package/package.json
CHANGED
|
@@ -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
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
288
|
-
|
|
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,
|
package/stl-docs/proseDocSync.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|