Skip to content

Commit 791cfee

Browse files
Kirill BolotskyPepe Cano
authored andcommitted
BREAKING CHANGE: adjusted code blocks syntax in mdx to match updated API
Side: - adjusted comment tokens style - removed redundant console.log
1 parent 16f91c9 commit 791cfee

File tree

174 files changed

+2309
-2420
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+2309
-2420
lines changed

CONTRIBUTING_FILE_FORMAT.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ And, as a result:
218218

219219
![internal-images/Untitled%207.png](internal-images/Untitled%207.png)
220220

221-
If we want line numbers to be rendered, we shall add the wrapper and adjust our data-props to:
221+
If we want line numbers to be rendered, we shall add the wrapper and adjust our props to:
222222

223-
<div class="code-group" data-props='{"labels": [], "lineNumbers": [true]}'>
223+
<CodeGroup labels={[]} lineNumbers={[true]}>
224224

225225
```javascript
226226
for (var id = 1; id <= 100; id++) {
@@ -231,17 +231,17 @@ If we want line numbers to be rendered, we shall add the wrapper and adjust our
231231
// tags.name="http://example.com/posts/${}"
232232
```
233233

234-
</div>
234+
</CodeGroup>
235235

236236
Here you go:
237237

238238
![internal-images/Untitled%208.png](internal-images/Untitled%208.png)
239239

240240
### Headerfull
241241

242-
Pretty much the same routine as with headerless ones, but one difference in data-props, labels field, but I bet, you already got that:
242+
Pretty much the same routine as with headerless ones, but with one difference in props, labels field, but I bet, you already got that:
243243

244-
<div class="code-group" data-props='{"labels": ["Nice code!"], "lineNumbers": [true]}'>
244+
<CodeGroup labels={["Nice code!"]} lineNumbers={[true]}>
245245

246246
```javascript
247247
for (var id = 1; id <= 100; id++) {
@@ -252,15 +252,15 @@ Pretty much the same routine as with headerless ones, but one difference in data
252252
// tags.name="http://example.com/posts/${}"
253253
```
254254

255-
</div>
255+
</CodeGroup>
256256

257257
![internal-images/Untitled%209.png](internal-images/Untitled%209.png)
258258

259259
### Multiple tabs
260260

261261
To be able to switch between different code tabs, we have to repeat the headerfull routine, but extend labels and md code blocks:
262262

263-
<div class="code-group" data-props='{"labels": ["Nice code!", "This one is better", "Oh my.."], "lineNumbers": [true, true, true]}'>
263+
<CodeGroup labels={["Nice code!", "This one is better", "Oh my.."]} lineNumbers={[true, true, true]}>
264264

265265
```javascript
266266
for (var id = 1; id <= 100; id++) {
@@ -290,7 +290,7 @@ To be able to switch between different code tabs, we have to repeat the headerfu
290290
```
291291

292292

293-
</div>
293+
</CodeGroup>
294294

295295
![internal-images/Untitled%2010.png](internal-images/Untitled%2010.png)
296296

@@ -306,7 +306,7 @@ Line numbers are optional not for the whole code block, but for each tab. That i
306306

307307
See _'Then do this?'_ text line between tabs? **You can not do that**. Put nothing in `code-group` except code blocks, or you'll broke the page.
308308

309-
<div class="code-group" data-props='{"labels": ["Nice code!"], "lineNumbers": [true]}'>
309+
<CodeGroup labels={["Nice code!"]} lineNumbers={[true]}>
310310

311311
```javascript
312312
for (var id = 1; id <= 100; id++) {
@@ -324,7 +324,7 @@ See _'Then do this?'_ text line between tabs? **You can not do that**. Put nothi
324324

325325
```
326326

327-
</div>
327+
</CodeGroup>
328328

329329
## Table data
330330

src/components/shared/code/code.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import styles from './code.module.scss';
88

99
const Code = ({ children, showLineNumbers }) => {
1010
if (!children) return null;
11-
console.log(children);
1211
const codeContainerRef = useRef(null);
1312
const [codeToCopy, setCodeToCopy] = useState('');
1413

src/components/shared/code/code.module.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
text-align: right;
1212
padding-right: 1em;
1313
user-select: none;
14-
opacity: 0.5;
14+
color: $color-additional-1;
1515
}
1616

1717
.line-content {
@@ -65,6 +65,9 @@
6565
&-line {
6666
display: table-row;
6767
}
68+
&.comment {
69+
opacity: 0.5;
70+
}
6871
&.keyword {
6972
color: #00cdff;
7073
}

src/data/markdown/docs/01 guides/01 Getting started/03 Running k6.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ excerpt: ''
88
Let's start by running a simple local script. Copy the code below, paste it into your
99
favourite editor, and save it as "script.js":
1010

11-
<div class="code-group" data-props='{"labels": ["script.js"], "lineNumbers": [true]}'>
11+
<CodeGroup labels={["script.js"]} lineNumbers={[true]}>
1212

1313
```javascript
1414
import http from 'k6/http';
@@ -20,11 +20,11 @@ export default function () {
2020
}
2121
```
2222

23-
</div>
23+
</CodeGroup>
2424

2525
Then run k6 using this command:
2626

27-
<div class="code-group" data-props='{"labels": ["CLI", "Docker", "Docker in Win PowerShell"]}'>
27+
<CodeGroup labels={["CLI", "Docker", "Docker in Win PowerShell"]}>
2828

2929
```shell
3030
$ k6 run script.js
@@ -44,13 +44,13 @@ $ docker run -i loadimpact/k6 run - <script.js
4444
$ cat script.js | docker run -i loadimpact/k6 run -
4545
```
4646

47-
</div>
47+
</CodeGroup>
4848

4949
## Adding more VUs
5050

5151
Now we'll try running a load test with more than 1 virtual user and a slightly longer duration:
5252

53-
<div class="code-group" data-props='{"labels": ["CLI", "Docker", "Docker in Win PowerShell"]}'>
53+
<CodeGroup labels={["CLI", "Docker", "Docker in Win PowerShell"]}>
5454

5555
```shell
5656
k6 run --vus 10 --duration 30s script.js
@@ -64,7 +64,7 @@ docker run -i loadimpact/k6 run --vus 10 --duration 30s - <script.js
6464
cat script.js | docker run -i loadimpact/k6 run --vus 10 --duration 30s -
6565
```
6666

67-
</div>
67+
</CodeGroup>
6868

6969
_Running a 30-second, 10-VU load test_
7070

@@ -75,15 +75,15 @@ which allows you to break larger tests into smaller pieces, or make reusable pie
7575
Scripts must contain, at the very least, a `default` function - this defines the entry point for
7676
your VUs, similar to the `main()` function in many other languages:
7777

78-
<div class="code-group" data-props='{"labels": []}'>
78+
<CodeGroup labels={[]}>
7979

8080
```javascript
8181
export default function () {
8282
// vu code: do things here...
8383
}
8484
```
8585

86-
</div>
86+
</CodeGroup>
8787

8888
### The init context and the default function
8989

@@ -93,7 +93,7 @@ but code inside and outside your default function can do different things.
9393
Code _inside_ `default` is called "VU code", and is run over and over for as long as the test is
9494
running. Code _outside_ of it is called "init code", and is run only once per VU.
9595

96-
<div class="code-group" data-props='{"labels": [""]}'>
96+
<CodeGroup labels={[""]}>
9797

9898
```js
9999
// init code
@@ -104,7 +104,7 @@ export default function( {
104104

105105
```
106106
107-
</div>
107+
</CodeGroup>
108108
109109
VU code can make HTTP requests, emit metrics, and generally do everything you'd expect a load test
110110
to do - with a few important exceptions: you can't load anything from your local filesystem, or
@@ -117,7 +117,7 @@ Read more about the different [life cycle stages of a k6 test](/using-k6/test-li
117117
If you want to avoid having to type `--vus 10` and `--duration 30s` all the time, you can include
118118
those settings inside your JavaScript file also:
119119
120-
<div class="code-group" data-props='{"labels": ["script.js"], "lineNumbers": [true]}'>
120+
<CodeGroup labels={["script.js"]} lineNumbers={[true]}>
121121
122122
```javascript
123123
import http from 'k6/http';
@@ -132,11 +132,11 @@ export default function () {
132132
}
133133
```
134134
135-
</div>
135+
</CodeGroup>
136136
137137
Then you just run the script without those parameters on the command line:
138138
139-
<div class="code-group" data-props='{"labels": ["CLI", "Docker", "Docker in Win PowerShell"]}'>
139+
<CodeGroup labels={["CLI", "Docker", "Docker in Win PowerShell"]}>
140140
141141
```shell
142142
$ k6 run script.js
@@ -150,14 +150,14 @@ $ docker run -i loadimpact/k6 run - <script.js
150150
C:\ cat script.js | docker run -i loadimpact/k6 run -
151151
```
152152
153-
</div>
153+
</CodeGroup>
154154
155155
## Stages: ramping up/down VUs
156156
157157
You can also have the VU level ramp up and down during the test. The `options.stages` property
158158
allows you to configure ramping behaviour.
159159
160-
<div class="code-group" data-props='{"labels": ["stages.js"], "lineNumbers": [true]}'>
160+
<CodeGroup labels={["stages.js"]} lineNumbers={[true]}>
161161
162162
```javascript
163163
import http from 'k6/http';
@@ -178,7 +178,7 @@ export default function () {
178178
}
179179
```
180180
181-
</div>
181+
</CodeGroup>
182182
183183
This can also be accomplished with more advanced configuration using
184184
[scenarios](/using-k6/scenarios) and the `ramping-vus` executor.
@@ -195,12 +195,12 @@ One of the goals with k6 is to support running a test in the three execution mod
195195
196196
For running cloud tests from the CLI, you must first register a k6 Cloud account and then log into your account via the CLI. Then, you only have to pass your existing script to the `k6 cloud` command.
197197
198-
<div class="code-group" data-props='{"labels": ["Running a cloud test"]}'>
198+
<CodeGroup labels={["Running a cloud test"]}>
199199
200200
```shell
201201
$ k6 cloud script.js
202202
```
203203
204-
</div>
204+
</CodeGroup>
205205
206206
For detailed instructions and the different options, read more on [running cloud tests from the CLI](/cloud/creating-and-running-a-test/cloud-tests-from-the-cli).

src/data/markdown/docs/01 guides/01 Getting started/04 Results Output.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ When k6 displays the results to `stdout`, it will show the k6 logo and the follo
1717

1818
### Test details
1919

20-
<div class="code-group" data-props='{"labels": []}'>
20+
<CodeGroup labels={[]}>
2121

2222
```shell
2323
execution: local
@@ -28,7 +28,7 @@ duration: 1m0s, iterations: -
2828
vus: 100, max: 100
2929
```
3030

31-
</div>
31+
</CodeGroup>
3232

3333
- `execution: local` the k6 execution mode (local or cloud).
3434
- `output: -` the output of the test results. The default is `stdout`.
@@ -46,7 +46,7 @@ The test summary provides a general overview of your test result. The summary pr
4646
- [Checks](/using-k6/checks) and [thresholds](/using-k6/thresholds).
4747
- [Groups](/using-k6/tags-and-groups#groups) and [tags](/using-k6/tags-and-groups#tags).
4848

49-
<div class="code-group" data-props='{"labels": []}'>
49+
<CodeGroup labels={[]}>
5050

5151
```shell
5252
data_received..............: 148 MB 2.5 MB/s
@@ -65,31 +65,31 @@ vus........................: 100 min=100 max=100
6565
vus_max....................: 100 min=100 max=100
6666
```
6767

68-
</div>
68+
</CodeGroup>
6969

7070
> To learn more about the metrics k6 collects and reports, read the [Metrics guide](/using-k6/metrics).
7171
7272
**Output of trend metrics**
7373

7474
[Trend metrics](/using-k6/metrics#metric-types) collect trend statistics (min/max/avg/percentiles) for a series of values. On stdout they are printed like this:
7575

76-
<div class="code-group" data-props='{"labels": []}'>
76+
<CodeGroup labels={[]}>
7777

7878
```shell
7979
http_req_duration..........: avg=143.14ms min=112.87ms med=136.03ms max=1.18s p(90)=164.2ms p(95)=177.75ms
8080
```
8181

82-
</div>
82+
</CodeGroup>
8383

8484
You could use the [summary-trend-stats](/using-k6/options#summary-trend-stats) option to change the stats reported for Trend metrics.
8585

86-
<div class="code-group" data-props='{"labels": []}'>
86+
<CodeGroup labels={[]}>
8787

8888
```shell
8989
$ k6 run --summary-trend-stats="avg,p(99)" script.js
9090
```
9191

92-
</div>
92+
</CodeGroup>
9393

9494
## Output plugins
9595

@@ -113,28 +113,28 @@ The list of output plugins are:
113113

114114
You can simultaneously send metrics to several outputs by using the CLI `--out` flag multiple times, for example:
115115

116-
<div class="code-group" data-props='{"labels": []}'>
116+
<CodeGroup labels={[]}>
117117

118118
```shell
119119
$ k6 run \
120120
--out json=test.json \
121121
--out influxdb=http://localhost:8086/k6
122122
```
123123

124-
</div>
124+
</CodeGroup>
125125

126126
## Summary export
127127

128128
Additionally, the `k6 run` command can export the end-of-test summary report to a JSON file that includes data for all test metrics, checks and thresholds.
129129

130130
This is useful to get the aggregated test results in a machine-readable format, for integration with dashboards, external alerts, etc.
131131

132-
<div class="code-group" data-props='{"labels": [] }'>
132+
<CodeGroup labels={[]}>
133133

134134
```shell
135135
$ k6 run --summary-export=export.json script.js
136136
```
137137

138-
</div>
138+
</CodeGroup>
139139

140140
> Read more about the summary on the [JSON plugin documentation](/results-visualization/json#summary-export)

0 commit comments

Comments
 (0)