Skip to content

Commit

Permalink
Roll 0.4.0 release (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
coatless authored Feb 5, 2024
1 parent b9036bd commit 3bf20b2
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 2 deletions.
2 changes: 1 addition & 1 deletion _extensions/webr/_extension.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: webr
title: Embedded webr code cells
author: James Joseph Balamuta
version: 0.4.0-dev.9
version: 0.4.0
quarto-required: ">=1.2.198"
contributes:
filters:
Expand Down
136 changes: 136 additions & 0 deletions docs/demos/qwebr-auto-run.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
---
title: "Demo: Autorun Interactive Code Cells"
engine: knitr
webr:
packages: ['ggplot2', 'gapminder']
filters:
- webr
---

# Overview

This demo showcases the functionality of automatically executing code within an interactive area, revealing output before any modifications can be made to the document.

## `autorun` Option

The `autorun` option works in tandem with the `interactive` context, enabling a non-interactive execution of code within the editable code area before any changes can be made to the area.

To illustrate, let's imagine a situation where you are prompted to modify the statement "Hello ___!" In the default view of an interactive cell, the results are not initially displayed.

::: {.panel-tabset group="autoRunExmple"}
#### `{quarto-webr}` Output
```{webr-r}
#| context: interactive
# Write your name here by replace ___
name <- "_____"
print(paste0("Hello, ", name, "!"))
```
#### Cell Code
````md
```{webr-r}
#| context: interactive
# Write your name here by replace ___
name <- "_____"
print(paste0("Hello, ", name, "!"))
```
````
:::

By including `#| autorun: true`, we enable the display of results when the document first loads. Revisiting the previous example, the editable code area now presents a distinct output, prompting the user to "Fill in the blanks":

::: {.panel-tabset group="autoRunExmple"}
#### `{quarto-webr}` Output
```{webr-r}
#| context: interactive
#| autorun: true
# Write your name here by replace ___
name <- "_____"
print(paste0("Hello, ", name, "!"))
```
#### Cell Code
````md
```{webr-r}
#| context: interactive
#| autorun: true
# Write your name here by replace ___
name <- "_____"
print(paste0("Hello, ", name, "!"))
```
````
:::


## Target Practice

One key use of the non-interactive areas is to generate a targeted outcome and have iterative attempts to reach the desired output.

For example, consider the `gapminder` data set.

::: {.panel-tabset group="gapminderRecreate"}
#### `{quarto-webr}` Output
```{webr-r}
#| context: output
data("gapminder", package = "gapminder")
head(gapminder)
```
#### Cell Code
```{{webr-r}}
#| context: output
data("gapminder", package = "gapminder")
head(gapminder)
```
:::

How can we use `gapminder` data to re-create the following `ggplot2` graph?


::: {.panel-tabset}
#### `{quarto-webr}` Output
```{webr-r}
#| context: output
#| fig-width: 5
#| fig-height: 3
#| out-width: 500px
ggplot(gapminder, aes(lifeExp)) +
geom_density(aes(fill=continent), alpha=1/4) + theme_bw()
```
#### Cell Code
```{{webr-r}}
#| context: output
#| fig-width: 5
#| fig-height: 3
#| out-width: 500px
ggplot(gapminder, aes(lifeExp)) +
geom_density(aes(fill=continent), alpha=1/4) + theme_bw()
```
:::

We've provided a code area for you to explore creating different kinds of graphs and have already run its contents!

::: {.panel-tabset}
#### `{quarto-webr}` Output
```{webr-r}
#| context: interactive
#| autorun: true
#| fig-width: 5
#| fig-height: 3
#| out-width: 500px
ggplot(gapminder, aes(lifeExp)) +
theme_bw()
```
#### Cell Code
```{{webr-r}}
#| context: interactive
#| autorun: true
#| fig-width: 5
#| fig-height: 3
#| out-width: 500px
ggplot(gapminder, aes(lifeExp)) +
theme_bw()
```
:::

# Fin

This demo illustrated the ease with which an interactive editable code area can seamlessly transition into a non-interactive mode, allow its results to be shown when the page loads.

1 change: 1 addition & 0 deletions docs/demos/qwebr-feature-demos.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ title: "Feature Demonstrations"

Below is a list of different demonstrations of the extensions features. These demos were created to showcase different feature releases.

- [Autorun Interactive Code Cells](qwebr-auto-run.qmd)
- [Initial Code Cell Option Support](qwebr-code-cell-options.qmd)
- [Using Custom Repositories for R WASM Package binaries](qwebr-custom-repository.qmd)
- [Revamped Noninteractive Areas](qwebr-non-interactive-areas.qmd)
Expand Down
4 changes: 3 additions & 1 deletion docs/qwebr-release-notes.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ format:
toc: true
---

# 0.4.0: Ball of Yarn (??-??-????) [DEV]
# 0.4.0: Ball of Yarn (02-05-2024)

## Breaking changes

- Internal JavaScript functions used by the extension have been significantly changed.
- JavaScript initialization procedure has been further refined.

## Features

Expand Down Expand Up @@ -50,6 +51,7 @@ format:
- Added a demo on [non-interactive code cells](https://quarto-webr.thecoatlessprofessor.com/demos/qwebr-non-interactive-areas.html). ([#128](https://github.com/coatless/quarto-webr/pull/128))
- Added a demo on [using custom repositories to install R WASM package binaries](https://quarto-webr.thecoatlessprofessor.com/demos/qwebr-custom-repository.html). ([#128](https://github.com/coatless/quarto-webr/pull/132))
- Added a demo for showing [initial code cell option support](https://quarto-webr.thecoatlessprofessor.com/demos/qwebr-code-cell-options.html). ([#141](https://github.com/coatless/quarto-webr/pull/141))
- Added a demo for showing [autorunning interactive code cells](https://quarto-webr.thecoatlessprofessor.com/demos/qwebr-auto-run.html).
- Modified the RevealJS presentation YAML to include an option to disable the webR status message header ([#110](https://github.com/coatless/quarto-webr/issues/110))
- Updated [blog posts](https://quarto-webr.thecoatlessprofessor.com/qwebr-community-examples.html#blog-posts) on [community examples](https://quarto-webr.thecoatlessprofessor.com/qwebr-community-examples.html) page ([#135](https://github.com/coatless/quarto-webr/pull/135))
- Updated [Hiding and Executing Code
Expand Down

0 comments on commit 3bf20b2

Please sign in to comment.