Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Add support for powershell #507

Merged
merged 14 commits into from
Mar 20, 2023
31 changes: 18 additions & 13 deletions demo/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const config = {
copyright: `Copyright © ${new Date().getFullYear()} Palo Alto Networks, Inc. Built with Docusaurus ${DOCUSAURUS_VERSION}.`,
},
prism: {
additionalLanguages: ["ruby", "csharp", "php", "java"],
additionalLanguages: ["ruby", "csharp", "php", "java", "powershell"],
},
languageTabs: [
{
Expand All @@ -148,7 +148,7 @@ const config = {
highlight: "python",
language: "python",
logoClass: "python",
variant: "http.client",
variant: "requests",
},
{
highlight: "go",
Expand All @@ -161,28 +161,33 @@ const config = {
logoClass: "nodejs",
variant: "axios",
},
// {
// highlight: "ruby",
// language: "ruby",
// logoClass: "ruby",
// },
{
highlight: "ruby",
language: "ruby",
logoClass: "ruby",
},
{
highlight: "csharp",
language: "csharp",
logoClass: "csharp",
variant: "httpclient",
},
// {
// highlight: "php",
// language: "php",
// logoClass: "php",
// },
{
highlight: "php",
language: "php",
logoClass: "php",
},
{
highlight: "java",
language: "java",
logoClass: "java",
variant: "unirest",
},
{
highlight: "powershell",
language: "powershell",
logoClass: "powershell",
},
],
algolia: {
apiKey: "441074cace987cbf4640c039ebed303c",
Expand Down Expand Up @@ -233,7 +238,7 @@ const config = {
template: "api.mustache", // Customize API MDX with mustache template
downloadUrl:
"https://raw.githubusercontent.com/PaloAltoNetworks/docusaurus-openapi-docs/main/demo/examples/petstore.yaml",
hideSendButton: true,
hideSendButton: false,
},
cos: {
specPath: "examples/openapi-cos.json",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-openapi-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"@docusaurus/theme-common": ">=2.0.1 <2.3.0",
"@mdx-js/react": "^1.6.21",
"@paloaltonetworks/postman-code-generators": "^1.1.15",
"@paloaltonetworks/postman-code-generators": "1.1.15-patch.2",
"@paloaltonetworks/postman-collection": "^4.1.0",
"@reduxjs/toolkit": "^1.7.1",
"buffer": "^6.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ export const languageSet: Language[] = [
},
variant: "OkHttp",
},
{
highlight: "powershell",
language: "powershell",
logoClass: "powershell",
options: {
followRedirect: true,
trimRequestBody: true,
},
variant: "RestMethod",
},
];

export interface Props {
Expand Down Expand Up @@ -280,7 +290,11 @@ function Curl({ postman, codeSamples }: Props) {
}
attributes={{ className: `code__tab--${lang.logoClass}` }}
>
<CodeBlock language={lang.highlight} className={styles.codeBlock}>
<CodeBlock
language={lang.highlight}
className={styles.codeBlock}
title={`${lang.language} / ${lang.variant}`}
>
{codeText}
</CodeBlock>
</CodeTab>
Expand Down
72 changes: 53 additions & 19 deletions packages/docusaurus-theme-openapi-docs/src/theme/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@
--openapi-card-border-radius: var(--ifm-pre-border-radius);
--openapi-input-border: var(--ifm-color-primary);
--openapi-input-background: var(--openapi-card-background-color);
--bash-background-color: transparent;
--bash-border-radius: none;
--code-tab-logo-width: 26px;
--code-tab-logo-height: 26px;
}

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

.docs-wrapper {
Expand Down Expand Up @@ -239,8 +245,8 @@

.code__tab--python::after {
content: "";
width: 28px;
height: 28px;
width: var(--code-tab-logo-width);
height: var(--code-tab-logo-height);
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/python/python-original.svg");
margin-block: auto;
}
Expand All @@ -265,8 +271,8 @@

.code__tab--go::after {
content: "";
width: 28px;
height: 28px;
width: var(--code-tab-logo-width);
height: var(--code-tab-logo-height);
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/go/go-original-wordmark.svg");
margin-block: auto;
}
Expand All @@ -291,8 +297,8 @@

.code__tab--javascript::after {
content: "";
width: 28px;
height: 28px;
width: var(--code-tab-logo-width);
height: var(--code-tab-logo-height);
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/javascript/javascript-original.svg");
margin-block: auto;
}
Expand All @@ -317,9 +323,11 @@

.code__tab--bash::after {
content: "";
width: 28px;
height: 28px;
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/linux/linux-original.svg");
width: var(--code-tab-logo-width);
height: var(--code-tab-logo-height);
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/bash/bash-plain.svg");
background-color: var(--bash-background-color);
border-radius: var(--bash-border-radius);
margin-block: auto;
}

Expand All @@ -343,8 +351,8 @@

.code__tab--ruby::after {
content: "";
width: 28px;
height: 28px;
width: var(--code-tab-logo-width);
height: var(--code-tab-logo-height);
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/ruby/ruby-plain.svg");
margin-block: auto;
}
Expand All @@ -369,8 +377,8 @@

.code__tab--csharp::after {
content: "";
width: 28px;
height: 28px;
width: var(--code-tab-logo-width);
height: var(--code-tab-logo-height);
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/csharp/csharp-original.svg");
margin-block: auto;
}
Expand All @@ -395,8 +403,8 @@

.code__tab--nodejs::after {
content: "";
width: 28px;
height: 28px;
width: var(--code-tab-logo-width);
height: var(--code-tab-logo-height);
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/nodejs/nodejs-original.svg");
margin-block: auto;
}
Expand All @@ -421,8 +429,8 @@

.code__tab--php::after {
content: "";
width: 28px;
height: 28px;
width: var(--code-tab-logo-width);
height: var(--code-tab-logo-height);
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/php/php-original.svg");
margin-block: auto;
}
Expand All @@ -447,8 +455,8 @@

.code__tab--java::after {
content: "";
width: 28px;
height: 28px;
width: var(--code-tab-logo-width);
height: var(--code-tab-logo-height);
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/java/java-original.svg");
margin-block: auto;
}
Expand All @@ -471,6 +479,32 @@
overflow: auto;
}

.code__tab--powershell::after {
content: "";
width: var(--code-tab-logo-width);
height: var(--code-tab-logo-height);
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/windows8/windows8-original.svg");
margin-block: auto;
}

.code__tab--powershell {
color: var(--ifm-color-info);
padding-left: 1.4rem;
padding-right: 1.4rem;
padding-top: 1rem !important;
padding-bottom: 1rem !important;
}

.code__tab--powershell.tabs__item--active {
border-bottom-color: var(--ifm-color-info);
background-color: var(--ifm-color-emphasis-100);
}

.language-powershell {
max-height: 500px;
overflow: auto;
}

/* Prism code styles */
.prism-code.language-java {
white-space: pre !important;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3101,10 +3101,10 @@
path-browserify "1.0.1"
yaml "1.10.2"

"@paloaltonetworks/postman-code-generators@^1.1.15":
version "1.1.15"
resolved "https://registry.yarnpkg.com/@paloaltonetworks/postman-code-generators/-/postman-code-generators-1.1.15.tgz#822eb45b538e47559ef2b6552223923cd8a62571"
integrity sha512-GVVqC+Uhe5Bt6VH/j26ooYZhv3lnrTdx59Fj3/DNeHV3aJAaWFtktu9pqj90nbxR56Sg/3CymaoZl/vyLiLJmg==
"@paloaltonetworks/[email protected]-patch.2":
version "1.1.15-patch.2"
resolved "https://registry.yarnpkg.com/@paloaltonetworks/postman-code-generators/-/postman-code-generators-1.1.15-patch.2.tgz#012051485269a2da6bd9a6b60031ddbc53e5e363"
integrity sha512-tRnAKtV4M8wLxcVnAx6ZCjCqbrR1xiqJNQkf1A71K8UxEP3N/+EspT82N5c0555w02oYFk21ViHuzuhm4gaGLw==
dependencies:
"@paloaltonetworks/postman-collection" "^4.1.0"
async "^3.2.4"
Expand Down