@stainless-api/docs 0.1.0-beta.119 → 0.1.0-beta.120
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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type * as SDKJSON from '@stainless/sdk-json';
|
|
2
2
|
import { generateRoute, walkTree, type DocsLanguage } from '@stainless-api/docs-ui/routing';
|
|
3
3
|
import type { StarlightRouteData } from '@astrojs/starlight/route-data';
|
|
4
|
+
import { isResourceEntirelyUnsupported } from '@stainless-api/docs-ui/languages/terraform';
|
|
4
5
|
|
|
5
6
|
function makeMethodOrResourceKey(entry: SDKJSON.Method | SDKJSON.Resource): string {
|
|
6
7
|
if (entry.kind === 'http_method') {
|
|
@@ -249,13 +250,43 @@ export class SidebarConfigItemsBuilder {
|
|
|
249
250
|
};
|
|
250
251
|
}
|
|
251
252
|
|
|
253
|
+
private generateTerraformItems(resources: SDKJSON.Resource[]) {
|
|
254
|
+
const entries: ReferenceSidebarConfigItem[] = [];
|
|
255
|
+
|
|
256
|
+
for (const resource of resources) {
|
|
257
|
+
if (isResourceEntirelyUnsupported(resource, this.spec.decls['terraform'])) {
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
entries.push({
|
|
261
|
+
kind: 'resource_overview_page',
|
|
262
|
+
label: resource.title,
|
|
263
|
+
key: makeMethodOrResourceKey(resource),
|
|
264
|
+
badge: undefined,
|
|
265
|
+
metadata: {
|
|
266
|
+
subResourceCount: countKeys(resource.subresources),
|
|
267
|
+
methodCount: countKeys(resource.methods),
|
|
268
|
+
modelCount: countKeys(resource.models),
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
return entries;
|
|
273
|
+
}
|
|
274
|
+
|
|
252
275
|
public generateItems(): ReferenceSidebarConfigItem[] {
|
|
253
276
|
const resourceMap = this.spec.resources;
|
|
254
277
|
const { resources, sharedModelsResource } = pullOutSharedModelsResource(Object.values(resourceMap ?? {}));
|
|
255
278
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
279
|
+
let entries: ReferenceSidebarConfigItem[];
|
|
280
|
+
|
|
281
|
+
if (this.language === 'terraform') {
|
|
282
|
+
// Handle Terraform specifically
|
|
283
|
+
// In TF, we only render the top level resource, not the subresources.
|
|
284
|
+
entries = this.generateTerraformItems(resources);
|
|
285
|
+
} else {
|
|
286
|
+
entries = resources.filter(isResourceNonEmpty).map((r) => {
|
|
287
|
+
return this.generateResourceGroup(r, false);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
259
290
|
|
|
260
291
|
const includeSharedModels = this.options?.includeSharedModels ?? false;
|
|
261
292
|
if (includeSharedModels && sharedModelsResource) {
|
|
@@ -381,10 +412,10 @@ export function toStarlightSidebar({
|
|
|
381
412
|
throw new Error(`Unknown entry kind ${JSON.stringify(entry)}`);
|
|
382
413
|
}
|
|
383
414
|
} else if (entry.kind === 'group') {
|
|
384
|
-
// Skip pushing the group if if the resource it represents is not available in the current language.
|
|
385
|
-
// This occurs when SDK generation for the current language is skipped in the Stainless config for that resource.
|
|
386
415
|
if (entry.resourceGroupKey) {
|
|
387
416
|
const resourceOrMethod = getResourceOrMethod(spec, entry.resourceGroupKey);
|
|
417
|
+
// Skip pushing the group if if the resource it represents is not available in the current language.
|
|
418
|
+
// This occurs when SDK generation for the current language is skipped in the Stainless config for that resource.
|
|
388
419
|
if (resourceOrMethod?.data?.kind === 'resource' && !resourceOrMethod?.data?.[currentLanguage]) {
|
|
389
420
|
continue;
|
|
390
421
|
}
|
|
@@ -73,7 +73,8 @@ function linkGroupTitleToOverviewPages(sidebar: StlSidebarEntry[]): StlSidebarEn
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
// Since Terraform only renders the top level resource, we don't need to link group titles to overview pages.
|
|
77
|
+
if (LINK_GROUP_TITLES_TO_OVERVIEW_PAGES === true && Astro.locals.language !== 'terraform') {
|
|
77
78
|
stlSidebar = linkGroupTitleToOverviewPages(stlSidebar);
|
|
78
79
|
}
|
|
79
80
|
---
|