Skip to content

Commit c0c1bc9

Browse files
authored
Merge pull request #8358 from quarto-dev/bugfix/docusaurus-chap-2
Docusaurus - add more snapshot tests
2 parents 06e9487 + dd6d9ed commit c0c1bc9

File tree

9 files changed

+248
-0
lines changed

9 files changed

+248
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
format: docusaurus-md
3+
code-annotations: true
4+
code-line-numbers: true
5+
---
6+
7+
```r
8+
library(tidyverse)
9+
library(palmerpenguins)
10+
penguins |> # <1>
11+
mutate( # <2>
12+
bill_ratio = bill_depth_mm / bill_length_mm, # <2>
13+
bill_area = bill_depth_mm * bill_length_mm # <2>
14+
) # <2>
15+
```
16+
1. Take `penguins`, and then,
17+
2. add new columns for the bill ratio and bill area.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
format: docusaurus-md
3+
---
4+
5+
```{=mdx}
6+
export const Highlight = ({children, color}) => (
7+
<span
8+
style={{
9+
backgroundColor: color,
10+
borderRadius: '2px',
11+
color: '#fff',
12+
padding: '0.2rem',
13+
}}>
14+
{children}
15+
</span>
16+
);
17+
```
18+
19+
<Highlight color="#25c2a0">Docusaurus GREEN</Highlight> and <Highlight color="#1877F2">Rams blue</Highlight> are my favorite colors.
20+
21+
I can write **Markdown** alongside my _JSX_!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
format: docusaurus-md
3+
---
4+
5+
::: {.panel-tabset}
6+
## R
7+
8+
``` {.r}
9+
fizz_buzz <- function(fbnums = 1:50) {
10+
output <- dplyr::case_when(
11+
fbnums %% 15 == 0 ~ "FizzBuzz",
12+
fbnums %% 3 == 0 ~ "Fizz",
13+
fbnums %% 5 == 0 ~ "Buzz",
14+
TRUE ~ as.character(fbnums)
15+
)
16+
print(output)
17+
}
18+
```
19+
20+
## Python
21+
22+
``` {.python}
23+
def fizz_buzz(num):
24+
if num % 15 == 0:
25+
print("FizzBuzz")
26+
elif num % 5 == 0:
27+
print("Buzz")
28+
elif num % 3 == 0:
29+
print("Fizz")
30+
else:
31+
print(num)
32+
```
33+
34+
:::
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
format: docusaurus-md
3+
code-annotations: true
4+
code-line-numbers: true
5+
---
6+
7+
8+
9+
10+
11+
```r showLineNumbers
12+
library(tidyverse)
13+
library(palmerpenguins)
14+
penguins |>
15+
mutate(
16+
bill_ratio = bill_depth_mm / bill_length_mm,
17+
bill_area = bill_depth_mm * bill_length_mm
18+
)
19+
```
20+
21+
Line 3
22+
Take `penguins`, and then,
23+
24+
Lines 4-7
25+
add new columns for the bill ratio and bill area.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
format: docusaurus-md
3+
code-annotations: true
4+
code-line-numbers: true
5+
_quarto:
6+
tests:
7+
docusaurus-md:
8+
ensureSnapshotMatches: true
9+
---
10+
11+
```r
12+
library(tidyverse)
13+
library(palmerpenguins)
14+
penguins |> # <1>
15+
mutate( # <2>
16+
bill_ratio = bill_depth_mm / bill_length_mm, # <2>
17+
bill_area = bill_depth_mm * bill_length_mm # <2>
18+
) # <2>
19+
```
20+
1. Take `penguins`, and then,
21+
2. add new columns for the bill ratio and bill area.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
format: docusaurus-md
3+
---
4+
5+
6+
7+
8+
````mdx-code-block
9+
export const Highlight = ({children, color}) => (
10+
<span
11+
style={{
12+
backgroundColor: color,
13+
borderRadius: '2px',
14+
color: '#fff',
15+
padding: '0.2rem',
16+
}}>
17+
{children}
18+
</span>
19+
);
20+
````
21+
22+
<Highlight color="#25c2a0">Docusaurus GREEN</Highlight> and
23+
<Highlight color="#1877F2">Rams blue</Highlight> are my favorite colors.
24+
25+
I can write **Markdown** alongside my *JSX*!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
format: docusaurus-md
3+
_quarto:
4+
tests:
5+
docusaurus-md:
6+
ensureSnapshotMatches: true
7+
---
8+
9+
```{=mdx}
10+
export const Highlight = ({children, color}) => (
11+
<span
12+
style={{
13+
backgroundColor: color,
14+
borderRadius: '2px',
15+
color: '#fff',
16+
padding: '0.2rem',
17+
}}>
18+
{children}
19+
</span>
20+
);
21+
```
22+
23+
<Highlight color="#25c2a0">Docusaurus GREEN</Highlight> and <Highlight color="#1877F2">Rams blue</Highlight> are my favorite colors.
24+
25+
I can write **Markdown** alongside my _JSX_!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
format: docusaurus-md
3+
---
4+
5+
6+
7+
8+
import Tabs from '@theme/Tabs';
9+
import TabItem from '@theme/TabItem';
10+
11+
<Tabs>
12+
<TabItem value="R">
13+
14+
```r
15+
fizz_buzz <- function(fbnums = 1:50) {
16+
output <- dplyr::case_when(
17+
fbnums %% 15 == 0 ~ "FizzBuzz",
18+
fbnums %% 3 == 0 ~ "Fizz",
19+
fbnums %% 5 == 0 ~ "Buzz",
20+
TRUE ~ as.character(fbnums)
21+
)
22+
print(output)
23+
}
24+
```
25+
26+
</TabItem>
27+
<TabItem value="Python">
28+
29+
```python
30+
def fizz_buzz(num):
31+
if num % 15 == 0:
32+
print("FizzBuzz")
33+
elif num % 5 == 0:
34+
print("Buzz")
35+
elif num % 3 == 0:
36+
print("Fizz")
37+
else:
38+
print(num)
39+
```
40+
41+
</TabItem>
42+
</Tabs>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
format: docusaurus-md
3+
_quarto:
4+
tests:
5+
docusaurus-md:
6+
ensure-snapshot-matches: true
7+
---
8+
9+
::: {.panel-tabset}
10+
## R
11+
12+
``` {.r}
13+
fizz_buzz <- function(fbnums = 1:50) {
14+
output <- dplyr::case_when(
15+
fbnums %% 15 == 0 ~ "FizzBuzz",
16+
fbnums %% 3 == 0 ~ "Fizz",
17+
fbnums %% 5 == 0 ~ "Buzz",
18+
TRUE ~ as.character(fbnums)
19+
)
20+
print(output)
21+
}
22+
```
23+
24+
## Python
25+
26+
``` {.python}
27+
def fizz_buzz(num):
28+
if num % 15 == 0:
29+
print("FizzBuzz")
30+
elif num % 5 == 0:
31+
print("Buzz")
32+
elif num % 3 == 0:
33+
print("Fizz")
34+
else:
35+
print(num)
36+
```
37+
38+
:::

0 commit comments

Comments
 (0)