@stainless-api/docs-ui 0.1.0-beta.82 → 0.1.0-beta.84

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.
@@ -1,6 +1,6 @@
1
1
  import "../use-strict-context-L0c8JKg4.js";
2
2
  import { code, fence, heading, item, list, paragraph, parse, strong, text } from "./md.js";
3
- import { getDecl, getSnippet, stripMarkup } from "./utils.js";
3
+ import { getCustomSnippetTitle, getDecl, getSnippets, stripMarkup } from "./utils.js";
4
4
  import { declaration as declaration$1, methodSignature, t as printer_exports } from "./printer.js";
5
5
  import Markdoc from "@markdoc/markdoc";
6
6
 
@@ -27,7 +27,7 @@ function renderMethod(env, method) {
27
27
  const signature = methodSignature(env.language, decl);
28
28
  const [httpMethod, endpoint] = method.endpoint.split(" ");
29
29
  const output = [
30
- heading(2, method.title),
30
+ heading(2, method.summary ?? method.title),
31
31
  ...env.language === "http" ? [] : [paragraph(code(stripMarkup(signature)))],
32
32
  paragraph(strong(text(httpMethod)), text(" "), code(endpoint))
33
33
  ];
@@ -47,8 +47,14 @@ function renderMethod(env, method) {
47
47
  }
48
48
  if ("paramsChildren" in decl && Array.isArray(decl.paramsChildren) && decl.paramsChildren.length > 0) output.push(heading(3, "Parameters"), renderChildren(env, decl.paramsChildren));
49
49
  if ("responseChildren" in decl && decl.responseChildren && decl.responseChildren.length > 0) output.push(heading(3, "Returns"), renderChildren(env, decl.responseChildren));
50
- const snippet = getSnippet(env, method.stainlessPath);
51
- if (snippet) output.push(heading(3, "Example"), fence(env.language, snippet));
50
+ const snippetEntries = getSnippets(env, method.stainlessPath);
51
+ for (const [key, { snippet, response }] of Object.entries(snippetEntries)) {
52
+ if (!snippet) continue;
53
+ let title = getCustomSnippetTitle(key);
54
+ if (title.toLowerCase() === "default") title = "Example";
55
+ output.push(heading(3, title), fence(env.language, snippet));
56
+ if (response) output.push(heading(4, "Response"), fence("json", response));
57
+ }
52
58
  return output;
53
59
  }
54
60
  function renderModel(env, model) {
@@ -15,7 +15,14 @@ type EnvironmentType = {
15
15
  };
16
16
  };
17
17
  declare function getDecl(env: EnvironmentType, path: string): LanguageDeclNodes[SpecLanguage] | undefined;
18
- declare function getSnippet(env: EnvironmentType, path: string, snippetId?: 'default' | `custom:${string}`): string | undefined;
18
+ declare const customSnippetPrefix = "custom:";
19
+ declare const getCustomSnippetTitle: (snippetId: string) => string;
20
+ declare function getSnippets(env: EnvironmentType, path: string): {
21
+ [k: string]: {
22
+ snippet: string;
23
+ response: string | undefined;
24
+ };
25
+ };
19
26
  declare function stripMarkup(content: string): string;
20
27
  //#endregion
21
- export { EnvironmentType, getDecl, getSnippet, stripMarkup };
28
+ export { EnvironmentType, customSnippetPrefix, getCustomSnippetTitle, getDecl, getSnippets, stripMarkup };
@@ -10,14 +10,16 @@ function getDecl(env, path) {
10
10
  }
11
11
  return decl;
12
12
  }
13
- function getSnippet(env, path, snippetId = "default") {
13
+ const customSnippetPrefix = "custom:";
14
+ const getCustomSnippetTitle = (snippetId) => snippetId.startsWith(customSnippetPrefix) ? snippetId.slice(7) : snippetId;
15
+ function getSnippets(env, path) {
14
16
  const lang = env.language === "http" ? "http.curl" : `${env.language}.default`;
15
- let snippet = env.spec?.snippets?.[lang]?.[path]?.[snippetId]?.content;
16
- if (snippet && env.transforms?.transformRequestSnippet) snippet = env.transforms.transformRequestSnippet({
17
- snippet,
18
- language: env.language
19
- });
20
- return snippet;
17
+ const snippets = env.spec?.snippets?.[lang]?.[path];
18
+ const responses = env.spec?.snippetResponses?.http?.[path];
19
+ return Object.fromEntries(Object.entries(snippets ?? {}).map(([key, snippet]) => [key, {
20
+ snippet: snippet.content,
21
+ response: responses?.[key]?.[0]?.content
22
+ }]));
21
23
  }
22
24
  function stripMarkup(content) {
23
25
  let output = "";
@@ -28,4 +30,4 @@ function stripMarkup(content) {
28
30
  }
29
31
 
30
32
  //#endregion
31
- export { getDecl, getSnippet, stripMarkup };
33
+ export { customSnippetPrefix, getCustomSnippetTitle, getDecl, getSnippets, stripMarkup };
package/dist/routing.d.ts CHANGED
@@ -8,7 +8,7 @@ declare const Languages: readonly ["http", "node", "python", "go", "typescript",
8
8
  declare const SupportedLanguageSyntaxes: string[];
9
9
  type DocsLanguage = (typeof Languages)[number];
10
10
  declare const LanguageNames: Record<DocsLanguage, string>;
11
- declare function getLanguageSnippet(language: DocsLanguage): "http.curl" | "cli.default" | "csharp.default" | "go.default" | "java.default" | "kotlin.default" | "node.default" | "php.default" | "python.default" | "ruby.default" | "terraform.default" | "typescript.default";
11
+ declare function getLanguageSnippet(language: DocsLanguage): "http.curl" | "node.default" | "python.default" | "go.default" | "typescript.default" | "terraform.default" | "ruby.default" | "java.default" | "kotlin.default" | "csharp.default" | "php.default" | "cli.default";
12
12
  declare function isSupportedLanguage(language: string): language is DocsLanguage;
13
13
  type ParsedStainlessPath = ReturnType<typeof parseStainlessPath>;
14
14
  declare function parseStainlessPath(stainlessPath: string): {
@@ -194,6 +194,13 @@
194
194
  margin-left: calc(-1 * var(--stldocs-expander-margin-shift));
195
195
  padding-right: var(--stldocs-expander-right-margin);
196
196
  }
197
+ /* move margin to .stldocs-property parent where possible to fix safari subgrid bug */
198
+ .stldocs-property:has(> .stldocs-expander) {
199
+ margin-left: calc(-1 * var(--stldocs-expander-margin-shift));
200
+ & > .stldocs-expander {
201
+ margin-left: 0;
202
+ }
203
+ }
197
204
  }
198
205
  }
199
206
  }
package/dist/styles.css CHANGED
@@ -1586,6 +1586,13 @@ a.stl-ui-button {
1586
1586
  margin-left: calc(-1 * var(--stldocs-expander-margin-shift));
1587
1587
  padding-right: var(--stldocs-expander-right-margin);
1588
1588
  }
1589
+ /* move margin to .stldocs-property parent where possible to fix safari subgrid bug */
1590
+ .stldocs-property:has(> .stldocs-expander) {
1591
+ margin-left: calc(-1 * var(--stldocs-expander-margin-shift));
1592
+ & > .stldocs-expander {
1593
+ margin-left: 0;
1594
+ }
1595
+ }
1589
1596
  }
1590
1597
  }
1591
1598
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stainless-api/docs-ui",
3
3
  "private": false,
4
- "version": "0.1.0-beta.82",
4
+ "version": "0.1.0-beta.84",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },