Skip to content

Commit 1256d1a

Browse files
authored
[Enhancement] Add support for powershell (#507)
* Switch to BASH icon * Ugprade to postman-code-generators 1.5.0-patch.1 * Add powershell and enable all langs * Add powershell * Add powershell styles and add background to bash icon * Switch to python requests variant * Add title to code blocks * Unhide send button for Petstore * Adjust size of code block logos * Downgrade to legacy postman-code-generators * Disable csharp * Disable powershell * Enable powershell * Switch to postman-code-generators 1.1.15-patch.2
1 parent 2a28e06 commit 1256d1a

File tree

5 files changed

+91
-38
lines changed

5 files changed

+91
-38
lines changed

demo/docusaurus.config.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const config = {
136136
copyright: `Copyright © ${new Date().getFullYear()} Palo Alto Networks, Inc. Built with Docusaurus ${DOCUSAURUS_VERSION}.`,
137137
},
138138
prism: {
139-
additionalLanguages: ["ruby", "csharp", "php", "java"],
139+
additionalLanguages: ["ruby", "csharp", "php", "java", "powershell"],
140140
},
141141
languageTabs: [
142142
{
@@ -148,7 +148,7 @@ const config = {
148148
highlight: "python",
149149
language: "python",
150150
logoClass: "python",
151-
variant: "http.client",
151+
variant: "requests",
152152
},
153153
{
154154
highlight: "go",
@@ -161,28 +161,33 @@ const config = {
161161
logoClass: "nodejs",
162162
variant: "axios",
163163
},
164-
// {
165-
// highlight: "ruby",
166-
// language: "ruby",
167-
// logoClass: "ruby",
168-
// },
164+
{
165+
highlight: "ruby",
166+
language: "ruby",
167+
logoClass: "ruby",
168+
},
169169
{
170170
highlight: "csharp",
171171
language: "csharp",
172172
logoClass: "csharp",
173173
variant: "httpclient",
174174
},
175-
// {
176-
// highlight: "php",
177-
// language: "php",
178-
// logoClass: "php",
179-
// },
175+
{
176+
highlight: "php",
177+
language: "php",
178+
logoClass: "php",
179+
},
180180
{
181181
highlight: "java",
182182
language: "java",
183183
logoClass: "java",
184184
variant: "unirest",
185185
},
186+
{
187+
highlight: "powershell",
188+
language: "powershell",
189+
logoClass: "powershell",
190+
},
186191
],
187192
algolia: {
188193
apiKey: "441074cace987cbf4640c039ebed303c",
@@ -233,7 +238,7 @@ const config = {
233238
template: "api.mustache", // Customize API MDX with mustache template
234239
downloadUrl:
235240
"https://raw.githubusercontent.com/PaloAltoNetworks/docusaurus-openapi-docs/main/demo/examples/petstore.yaml",
236-
hideSendButton: true,
241+
hideSendButton: false,
237242
},
238243
cos: {
239244
specPath: "examples/openapi-cos.json",

packages/docusaurus-theme-openapi-docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"dependencies": {
4646
"@docusaurus/theme-common": ">=2.0.1 <2.3.0",
4747
"@mdx-js/react": "^1.6.21",
48-
"@paloaltonetworks/postman-code-generators": "^1.1.15",
48+
"@paloaltonetworks/postman-code-generators": "1.1.15-patch.2",
4949
"@paloaltonetworks/postman-collection": "^4.1.0",
5050
"@reduxjs/toolkit": "^1.7.1",
5151
"buffer": "^6.0.3",

packages/docusaurus-theme-openapi-docs/src/theme/ApiDemoPanel/Curl/index.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ export const languageSet: Language[] = [
111111
},
112112
variant: "OkHttp",
113113
},
114+
{
115+
highlight: "powershell",
116+
language: "powershell",
117+
logoClass: "powershell",
118+
options: {
119+
followRedirect: true,
120+
trimRequestBody: true,
121+
},
122+
variant: "RestMethod",
123+
},
114124
];
115125

116126
export interface Props {
@@ -280,7 +290,11 @@ function Curl({ postman, codeSamples }: Props) {
280290
}
281291
attributes={{ className: `code__tab--${lang.logoClass}` }}
282292
>
283-
<CodeBlock language={lang.highlight} className={styles.codeBlock}>
293+
<CodeBlock
294+
language={lang.highlight}
295+
className={styles.codeBlock}
296+
title={`${lang.language} / ${lang.variant}`}
297+
>
284298
{codeText}
285299
</CodeBlock>
286300
</CodeTab>

packages/docusaurus-theme-openapi-docs/src/theme/styles.css

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@
1717
--openapi-card-border-radius: var(--ifm-pre-border-radius);
1818
--openapi-input-border: var(--ifm-color-primary);
1919
--openapi-input-background: var(--openapi-card-background-color);
20+
--bash-background-color: transparent;
21+
--bash-border-radius: none;
22+
--code-tab-logo-width: 26px;
23+
--code-tab-logo-height: 26px;
2024
}
2125

2226
[data-theme="dark"] {
2327
--openapi-card-background-color: var(--ifm-color-gray-900) !important;
28+
--bash-background-color: lightgrey;
29+
--bash-border-radius: 20px;
2430
}
2531

2632
.docs-wrapper {
@@ -239,8 +245,8 @@
239245

240246
.code__tab--python::after {
241247
content: "";
242-
width: 28px;
243-
height: 28px;
248+
width: var(--code-tab-logo-width);
249+
height: var(--code-tab-logo-height);
244250
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/python/python-original.svg");
245251
margin-block: auto;
246252
}
@@ -265,8 +271,8 @@
265271

266272
.code__tab--go::after {
267273
content: "";
268-
width: 28px;
269-
height: 28px;
274+
width: var(--code-tab-logo-width);
275+
height: var(--code-tab-logo-height);
270276
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/go/go-original-wordmark.svg");
271277
margin-block: auto;
272278
}
@@ -291,8 +297,8 @@
291297

292298
.code__tab--javascript::after {
293299
content: "";
294-
width: 28px;
295-
height: 28px;
300+
width: var(--code-tab-logo-width);
301+
height: var(--code-tab-logo-height);
296302
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/javascript/javascript-original.svg");
297303
margin-block: auto;
298304
}
@@ -317,9 +323,11 @@
317323

318324
.code__tab--bash::after {
319325
content: "";
320-
width: 28px;
321-
height: 28px;
322-
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/linux/linux-original.svg");
326+
width: var(--code-tab-logo-width);
327+
height: var(--code-tab-logo-height);
328+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/bash/bash-plain.svg");
329+
background-color: var(--bash-background-color);
330+
border-radius: var(--bash-border-radius);
323331
margin-block: auto;
324332
}
325333

@@ -343,8 +351,8 @@
343351

344352
.code__tab--ruby::after {
345353
content: "";
346-
width: 28px;
347-
height: 28px;
354+
width: var(--code-tab-logo-width);
355+
height: var(--code-tab-logo-height);
348356
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/ruby/ruby-plain.svg");
349357
margin-block: auto;
350358
}
@@ -369,8 +377,8 @@
369377

370378
.code__tab--csharp::after {
371379
content: "";
372-
width: 28px;
373-
height: 28px;
380+
width: var(--code-tab-logo-width);
381+
height: var(--code-tab-logo-height);
374382
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/csharp/csharp-original.svg");
375383
margin-block: auto;
376384
}
@@ -395,8 +403,8 @@
395403

396404
.code__tab--nodejs::after {
397405
content: "";
398-
width: 28px;
399-
height: 28px;
406+
width: var(--code-tab-logo-width);
407+
height: var(--code-tab-logo-height);
400408
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/nodejs/nodejs-original.svg");
401409
margin-block: auto;
402410
}
@@ -421,8 +429,8 @@
421429

422430
.code__tab--php::after {
423431
content: "";
424-
width: 28px;
425-
height: 28px;
432+
width: var(--code-tab-logo-width);
433+
height: var(--code-tab-logo-height);
426434
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/php/php-original.svg");
427435
margin-block: auto;
428436
}
@@ -447,8 +455,8 @@
447455

448456
.code__tab--java::after {
449457
content: "";
450-
width: 28px;
451-
height: 28px;
458+
width: var(--code-tab-logo-width);
459+
height: var(--code-tab-logo-height);
452460
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/java/java-original.svg");
453461
margin-block: auto;
454462
}
@@ -471,6 +479,32 @@
471479
overflow: auto;
472480
}
473481

482+
.code__tab--powershell::after {
483+
content: "";
484+
width: var(--code-tab-logo-width);
485+
height: var(--code-tab-logo-height);
486+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/windows8/windows8-original.svg");
487+
margin-block: auto;
488+
}
489+
490+
.code__tab--powershell {
491+
color: var(--ifm-color-info);
492+
padding-left: 1.4rem;
493+
padding-right: 1.4rem;
494+
padding-top: 1rem !important;
495+
padding-bottom: 1rem !important;
496+
}
497+
498+
.code__tab--powershell.tabs__item--active {
499+
border-bottom-color: var(--ifm-color-info);
500+
background-color: var(--ifm-color-emphasis-100);
501+
}
502+
503+
.language-powershell {
504+
max-height: 500px;
505+
overflow: auto;
506+
}
507+
474508
/* Prism code styles */
475509
.prism-code.language-java {
476510
white-space: pre !important;

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3101,10 +3101,10 @@
31013101
path-browserify "1.0.1"
31023102
yaml "1.10.2"
31033103

3104-
"@paloaltonetworks/postman-code-generators@^1.1.15":
3105-
version "1.1.15"
3106-
resolved "https://registry.yarnpkg.com/@paloaltonetworks/postman-code-generators/-/postman-code-generators-1.1.15.tgz#822eb45b538e47559ef2b6552223923cd8a62571"
3107-
integrity sha512-GVVqC+Uhe5Bt6VH/j26ooYZhv3lnrTdx59Fj3/DNeHV3aJAaWFtktu9pqj90nbxR56Sg/3CymaoZl/vyLiLJmg==
3104+
"@paloaltonetworks/postman-code-generators@1.1.15-patch.2":
3105+
version "1.1.15-patch.2"
3106+
resolved "https://registry.yarnpkg.com/@paloaltonetworks/postman-code-generators/-/postman-code-generators-1.1.15-patch.2.tgz#012051485269a2da6bd9a6b60031ddbc53e5e363"
3107+
integrity sha512-tRnAKtV4M8wLxcVnAx6ZCjCqbrR1xiqJNQkf1A71K8UxEP3N/+EspT82N5c0555w02oYFk21ViHuzuhm4gaGLw==
31083108
dependencies:
31093109
"@paloaltonetworks/postman-collection" "^4.1.0"
31103110
async "^3.2.4"

0 commit comments

Comments
 (0)