Skip to content

Minikube documentation update #67

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

Open
wants to merge 13 commits into
base: source
Choose a base branch
from
88 changes: 88 additions & 0 deletions site/_core/CodeTabsWithCopy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import React from 'react';
import Tabs from 'react-responsive-tabs';

export default class CodeTabsWithCopy extends React.Component {
constructor(props) {
super(props);
this.state = {
items: this._getTabs(),
selectedTabKey: 0,
copied: false
};

// bind event handlers here
this.onTabChange = this.onTabChange.bind(this);
this.copyCode = this.copyCode.bind(this);
}

_getTabs() {
return this.props.schema.map((s, i) => ({
key: i,
tabClassName: 'tab',
panelClassName: 'panel',
title: s.name,
getContent: () => s.content
}));
}

onTabChange(index) {
this.setState({ selectedTabKey: index, copied: false });
}

copyCode() {
const { selectedTabKey, items } = this.state;
const codeNode = items[selectedTabKey].getContent();

let textToCopy = '';

try {
if (
codeNode &&
codeNode.props &&
codeNode.props.children &&
codeNode.props.children.props &&
typeof codeNode.props.children.props.children === 'string'
) {
textToCopy = codeNode.props.children.props.children;
} else if (
codeNode &&
codeNode.props &&
typeof codeNode.props.children === 'string'
) {
textToCopy = codeNode.props.children;
}
} catch (e) {
textToCopy = '';
}

if (textToCopy) {
navigator.clipboard.writeText(textToCopy);
this.setState({ copied: true });
setTimeout(() => this.setState({ copied: false }), 2000);
}
}

render() {
const { items, selectedTabKey, copied } = this.state;

return (
<div style={{ position: 'relative' }}>
<Tabs
transform={false}
items={items}
showInkBar={true}
selectedTabKey={selectedTabKey}
onChange={this.onTabChange}
/>
<button
onClick={this.copyCode}
className="copy-btn"
style={{ top: '62px' }}
aria-label="Copy code"
>
{copied ? 'Copied!' : 'Copy'}
</button>
</div>
);
}
}
21 changes: 21 additions & 0 deletions site/_core/Marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,27 @@ Parser.prototype.tok = function () {
}
}
}
if (this.token.lang === 'hkube-tabs-with-copy') {
var lines = this.token.text.split('\n');
var firstLine = lines.shift().match(/^\s*#\s*({.*})$/);
if (firstLine) {
var metaData;
try {
metaData = JSON.parse(firstLine[1]);
} catch (e) {
console.error('Invalid Metadata JSON:', firstLine[1]);
}
if (metaData) {
return <script data-inline dangerouslySetInnerHTML={{
__html: `
import CodeTabsWithCopy from '../_core/CodeTabsWithCopy';
import Prism from '../_core/Prism';
import schema from '../_core/schemas/${metaData.schema}';
renderHere(<CodeTabsWithCopy schema={schema} />);
`}} />
}
}
}
return <Prism language={this.token.lang} line={this.token.line}>{this.token.text}</Prism>;
}
case 'table': {
Expand Down
33 changes: 18 additions & 15 deletions site/_core/schemas/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,34 @@ const items = [
{
name: 'Linux',
content: <Prism language="bash">
{`
minikube start --driver docker --addons ingress --addons registry \\
--addons registry-aliases --addons storage-provisioner
# verify that all pods are running
kubectl get pods -A
`}
{String.raw`minikube start --driver=docker \
--addons ingress \
--addons registry \
--addons registry-aliases \
--addons storage-provisioner \
--kubernetes-version=v1.23.5`}
</Prism>
},
{
name: 'Windows',
content: <Prism language="shell">
{`
minikube start --driver hyperv --cpus 4 --memory 6GB --addons ingress --addons registry --addons registry-aliases --addons storage-provisioner
kubectl get pods -A
`}
{String.raw`minikube start --driver=hyperv --cpus=4 --memory=6GB ^
--addons=ingress ^
--addons=registry ^
--addons=registry-aliases ^
--addons=storage-provisioner ^
--kubernetes-version=v1.23.5`}
</Prism>
},
{
name: 'MacOS',
content: <Prism language="shell">
{`
minikube start --cpus 4 --memory 6GB \\
--addons ingress --addons registry --addons registry-aliases --addons storage-provisioner
kubectl get pods -A
`}
{String.raw`minikube start --cpus=4 --memory=6GB \
--addons=ingress \
--addons=registry \
--addons=registry-aliases \
--addons=storage-provisioner \
--kubernetes-version=v1.23.5`}
</Prism>
},
];
Expand Down
2 changes: 1 addition & 1 deletion site/_css/copy-button.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
cursor: pointer;
font-size: 12px;
position: absolute;
bottom: 10px;
top: 10px;
right: 10px;
}

Expand Down
2 changes: 1 addition & 1 deletion site/learn/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ layout: ../_core/DocsLayout
category: Learn
permalink: /learn/api/
sublinks: Restful, Cli
next: /learn/algorithms/
next: /learn/installCLI/
---

HKube supports two types of APIs, Restful and Cli.
Expand Down
2 changes: 1 addition & 1 deletion site/learn/AdvancedPipelineDescriptor.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ layout: ../_core/DocsLayout
category: Learn
permalink: /learn/advancedPipeline/
sublinks: Advance Options
next: /learn/install/
next: /learn/triggers/
---

## Advance Options
Expand Down
2 changes: 1 addition & 1 deletion site/learn/Algorithms.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ layout: ../_core/DocsLayout
category: Learn
sublinks: Integration Methods, Events & Communication, Implementation
permalink: /learn/algorithms/
next: /learn/sidecars/
next: /learn/streaming/
---

HKube offers two ways to integrate your algorithm:
Expand Down
2 changes: 1 addition & 1 deletion site/learn/Caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ layout: ../_core/DocsLayout
category: Learn
sublinks: Introduction, Use Cases, How to activate cache
permalink: /learn/caching/
next: /learn/debug/
next: /learn/codeapi/
---

## Introduction
Expand Down
6 changes: 3 additions & 3 deletions site/learn/Debug.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: Debug algorithm
sidebarTitle: Debug algorithm
title: Debug Algorithm
sidebarTitle: Debug Algorithm
layout: ../_core/DocsLayout
category: Learn
sublinks: Introduction, Use Cases, How To
permalink: /learn/debug/
next: /learn/tensorboard/
next: /learn/pipelines/
---
## Introduction
HKube enable debugging algorithm on your local IDE as part of a pipeline executed on the cluster
Expand Down
2 changes: 1 addition & 1 deletion site/learn/Execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Pipeline Execution
layout: ../_core/DocsLayout
category: Learn
permalink: /learn/execution/
next: /learn/streaming/
next: /learn/advancedPipeline/
sublinks: Flow Input, Reference, Batch, Batch Reference, Wait Any, Output
---

Expand Down
Loading