Skip to content

Commit e63ea9b

Browse files
authored
Merge pull request #952 from PaloAltoNetworks/language-options
2 parents 800c1b1 + 19d450f commit e63ea9b

File tree

4 files changed

+537
-86
lines changed

4 files changed

+537
-86
lines changed

demo/docs/customization/languagetabs.mdx

Lines changed: 134 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -8,98 +8,159 @@ description: Configuring language tabs for the API Demo Panel.
88

99
## Overview
1010

11-
The Docusaurus OpenAPI docs plugin comes with support for 8 languages which you can render as code snippets on an API operation page. The languages currently supported are:
11+
The Docusaurus OpenAPI docs plugin comes with support for 18 languages which you can render as code snippets on an API operation page.
12+
13+
14+
### Supported Languages and Variants
15+
16+
The languages currently supported are:
1217

1318
| Language | Prism Highlighter | Variants |
1419
| ------------ | ----------------- | ------------------------------------------------ |
15-
| `curl` | bash | `curl`\* |
16-
| `python` | python | `requests`\*, `http.client` |
17-
| `go` | go | `native`\* |
18-
| `nodejs` | javascript | `axios`\*, `native` |
19-
| `ruby` | ruby | `net::http`\* |
20-
| `csharp` | csharp | `restsharp`\*, `httpclient` |
21-
| `php` | php | `curl`\*, `guzzle`, `pecl_http`, `http_request2` |
22-
| `java` | java | `okhttp`\*, `unirest` |
23-
| `powershell` | powershell | `RestMethod`\* |
20+
| `curl` | bash | `curl` |
21+
| `python` | python | `requests`, `http.client` |
22+
| `go` | go | `native` |
23+
| `nodejs` | javascript | `axios`, `native`, `request`, `unirest` |
24+
| `ruby` | ruby | `net::http` |
25+
| `csharp` | csharp | `httpclient`, `restsharp` |
26+
| `php` | php | `curl`, `guzzle`, `pecl_http`, `http_request2` |
27+
| `java` | java | `okhttp`, `unirest` |
28+
| `powershell` | powershell | `restmethod` |
29+
| `dart` | dart | `dio`, `http` |
30+
| `javascript` | javascript | `fetch`, `jquery`, `xhr` |
31+
| `kotlin` | kotlin | `okhttp` |
32+
| `c` | c_cpp | `libcurl` |
33+
| `objective-c`| objectivec | `nsurlsession` |
34+
| `ocaml` | ocaml | `cohttp` |
35+
| `r` | r | `httr`, `rcurl` |
36+
| `rust` | rust | `reqwest` |
37+
| `swift` | swift | `urlsession` |
2438

25-
\* Default variant
39+
### Defining languages in languageTabs
2640

2741
The enabled languages are defined for your site in a `languageTabs` array in the `themeConfig` object in your config file. If you do not define this configuration item all of the languages above are enabled. The config schema for each language is as follows:
2842

2943
| Name | Type | Default | Description |
3044
| ----------------- | --------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------- |
31-
| `highlight` | `string` | `null` | The syntax highlighting ruleset to use. |
3245
| `language` | `string` | `null` | The programming language to use when generating the example. |
33-
| `logoClass` | `string` | `null` | The CSS class to be added to render the appropriate logo. |
34-
| `variant` | `string` | `null` | The language variant to use when generating the example, see below for a tip on where you can find the variants. |
35-
| `options` | `object` | `null` | _Optional:_ Set of options for language customization. See below for common options, exact options depend on language. |
36-
| `followRedirect` | `string` | `null` | _Optional:_ Follow redirects when handling requests. |
37-
| `trimRequestBody` | `string` | `null` | _Optional:_ Trim request body fields. |
38-
| `indentCount` | `integer` | _language dependent_ | _Optional:_ Alter the number of indentations used when generating the examples. |
39-
| `indentType` | `string` | _language dependent_ | _Optional:_ Alter the type of indentation used, `Space` or `Tab` are acceptable options for this. |
46+
| `highlight` | `string` | _language dependent_ | _Optional:_ The prism syntax highlighting language to use. |
47+
| `logoClass` | `string` | _language dependent_ | _Optional:_ The CSS class suffix to be added to render the appropriate logo. |
48+
| `variant` | `string` | _language dependent_ | _Optional:_ The default language variant to use when generating the code snippet. |
49+
| `variants` | `array` | _language dependent_ | _Optional:_ An array of strings representing the variants available for the language. |
50+
| `options` | `object` | _language dependent_ | _Optional:_ Set of options for language customization. See below for common options, exact options depend on language. |
51+
|     `followRedirect` | `boolean` | _language dependent_ | _Optional:_ Follow redirects when handling requests. |
52+
|     `trimRequestBody` | `boolean` | _language dependent_ | _Optional:_ Trim request body fields. |
53+
|     `indentCount` | `integer` | _language dependent_ | _Optional:_ Alter the number of indentations used when generating the examples. |
54+
|     `indentType` | `string` | _language dependent_ | _Optional:_ Alter the type of indentation used, `Space` or `Tab` are acceptable options for this. |
4055

4156
:::tip
42-
The order you define the languages under `languageTabs` is the order in which they will appear once rendered.
57+
The order you define the languages under `languageTabs` is the order in which they will appear once rendered. You may also choose a subset of languages and variants to include.
4358
:::
4459

4560
:::danger
4661
Individual languages may only be defined once, meaning you cannot define a language multiple times with different variants. For example, you cannot define both `nodejs\axios` and `nodejs\unirest` or `python/requests` and `python/http.client`.
4762
:::
4863

49-
## Demo Languages
64+
### Languages in Demo
5065

51-
The demo site disables the `ruby` and `php` languages using the following `languageTabs` config object.
66+
The demo site defines all supported languages using the following `languageTabs` config object.
67+
68+
:::note
69+
Only the `language` property is required. The `highlight` and `logoClass` properties are provided only for reference.
70+
:::
5271

5372
```js
54-
languageTabs: [
55-
{
56-
highlight: "bash",
57-
language: "curl",
58-
logoClass: "bash",
59-
},
60-
{
61-
highlight: "python",
62-
language: "python",
63-
logoClass: "python",
64-
variant: "requests",
65-
},
66-
{
67-
highlight: "go",
68-
language: "go",
69-
logoClass: "go",
70-
},
71-
{
72-
highlight: "javascript",
73-
language: "nodejs",
74-
logoClass: "nodejs",
75-
variant: "axios",
76-
},
77-
{
78-
highlight: "ruby",
79-
language: "ruby",
80-
logoClass: "ruby",
81-
},
82-
{
83-
highlight: "csharp",
84-
language: "csharp",
85-
logoClass: "csharp",
86-
variant: "httpclient",
87-
},
88-
{
89-
highlight: "php",
90-
language: "php",
91-
logoClass: "php",
92-
},
93-
{
94-
highlight: "java",
95-
language: "java",
96-
logoClass: "java",
97-
variant: "unirest",
98-
},
99-
{
100-
highlight: "powershell",
101-
language: "powershell",
102-
logoClass: "powershell",
103-
},
104-
],
73+
languageTabs: [
74+
{
75+
highlight: "python",
76+
language: "python",
77+
logoClass: "python",
78+
},
79+
{
80+
highlight: "bash",
81+
language: "curl",
82+
logoClass: "bash",
83+
},
84+
{
85+
highlight: "csharp",
86+
language: "csharp",
87+
logoClass: "csharp",
88+
},
89+
{
90+
highlight: "go",
91+
language: "go",
92+
logoClass: "go",
93+
},
94+
{
95+
highlight: "javascript",
96+
language: "nodejs",
97+
logoClass: "nodejs",
98+
},
99+
{
100+
highlight: "ruby",
101+
language: "ruby",
102+
logoClass: "ruby",
103+
},
104+
{
105+
highlight: "php",
106+
language: "php",
107+
logoClass: "php",
108+
},
109+
{
110+
highlight: "java",
111+
language: "java",
112+
logoClass: "java",
113+
variant: "unirest",
114+
},
115+
{
116+
highlight: "powershell",
117+
language: "powershell",
118+
logoClass: "powershell",
119+
},
120+
{
121+
highlight: "dart",
122+
language: "dart",
123+
logoClass: "dart",
124+
},
125+
{
126+
highlight: "javascript",
127+
language: "javascript",
128+
logoClass: "javascript",
129+
},
130+
{
131+
highlight: "c",
132+
language: "c",
133+
logoClass: "c",
134+
},
135+
{
136+
highlight: "objective-c",
137+
language: "objective-c",
138+
logoClass: "objective-c",
139+
},
140+
{
141+
highlight: "ocaml",
142+
language: "ocaml",
143+
logoClass: "ocaml",
144+
},
145+
{
146+
highlight: "r",
147+
language: "r",
148+
logoClass: "r",
149+
},
150+
{
151+
highlight: "swift",
152+
language: "swift",
153+
logoClass: "swift",
154+
},
155+
{
156+
highlight: "kotlin",
157+
language: "kotlin",
158+
logoClass: "kotlin",
159+
},
160+
{
161+
highlight: "rust",
162+
language: "rust",
163+
logoClass: "rust",
164+
},
165+
],
105166
```

0 commit comments

Comments
 (0)