Skip to content

Commit

Permalink
Set autorun: false by default everywhere.
Browse files Browse the repository at this point in the history
Previously the cell option `autorun` defaulted to `true` for
"sandbox" type cells, but `false` for exercises. This has been
found to be confusing, and so `autorun: false` is now always the
default state. Autorun may still be enabled by setting the cell
option directly, or set document-wide using the `cell-options`
YAML header.
  • Loading branch information
georgestagg committed Sep 19, 2024
1 parent 21de538 commit 46f5dea
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

* Setup blocks may now be attached to multiple exercises by providing a list for the `exercise` cell option.

## Breaking changes

* Previously the cell option `autorun` defaulted to `true` for "sandbox" type cells, but `false` for exercises. This has been found to be confusing, and so `autorun: false` is now always the default state. Autorun may still be enabled by setting the cell option directly, or set document-wide using the `cell-options` YAML header.

## Bug fixes

* Ensure that JavaScript scripts that have been dynamically added via HTML output are executed.
Expand Down
2 changes: 1 addition & 1 deletion _extensions/live/resources/live-runtime.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion _extensions/live/templates/pyodide-exercise.ojs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ viewof _pyodide_editor_{{block_id}} = {
id: "pyodide-{{block_id}}-contents",
envir: `exercise-env-${block.attr.exercise}`,
error: false,
autorun: false,
caption: 'Exercise',
},
block.attr
Expand Down
1 change: 0 additions & 1 deletion _extensions/live/templates/webr-exercise.ojs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ viewof _webr_editor_{{block_id}} = {
id: "webr-{{block_id}}-contents",
envir: `exercise-env-${block.attr.exercise}`,
error: false,
autorun: false,
caption: 'Exercise',
},
block.attr
Expand Down
16 changes: 8 additions & 8 deletions docs/getting_started/editor.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,21 @@ In this mode only the source code will be shown when the page initially loads. A

## Autorun

Initial code cell contents will be automatically executed[^ex] once the WebAssembly engine has loaded into the page. That is, you do not need to click "Run Code" to see the initial evaluation output. However, this autorun feature can be disabled by setting `autorun: false`.

[^ex]: Note that code exercises do not autorun by default, see [Exercises and Grading](../exercises/exercises.qmd) for details.
Setting `autorun: true` evaluates initial code cell contents automatically, once the WebAssembly engine has loaded into the page. That is, you do not need to click "Run Code" to see the initial output.

#### Source

````markdown
```{{webr}}
#| autorun: false
#| autorun: true
123 + 456
```
````

#### Output

```{webr}
#| autorun: false
#| autorun: true
123 + 456
```

Expand All @@ -119,6 +117,7 @@ Setting `runbutton: false` will remove the "Run Code" button from the editor UI.
````markdown
```{{webr}}
#| caption: Immediate Execution
#| autorun: true
#| runbutton: false
foo <- 123
bar <- 246
Expand All @@ -130,6 +129,7 @@ foo + bar

```{webr}
#| caption: Immediate Execution
#| autorun: true
#| runbutton: false
foo <- 123
bar <- 246
Expand All @@ -144,12 +144,13 @@ This might be distracting and confusing for new learners, and so this mode shoul

## Autocomplete

Autocompletion code suggestions can be enabled with the code cell option `completion: true`.
Context aware autocomplete suggestions are shown in the code editor. This can be disabled by setting the cell option `completion: false`.

#### Source

````markdown
```{{webr}}
#| autorun: true
#| completion: true
n_mean <- 120
n_sd <- 5
Expand All @@ -161,6 +162,7 @@ n_sd <- 5
#### Output

```{webr}
#| autorun: true
#| completion: true
n_mean <- 120
n_sd <- 5
Expand Down Expand Up @@ -257,7 +259,6 @@ The default time limit is 30 seconds and setting `timelimit: 0` will disable the

````markdown
```{{webr}}
#| autorun: false
#| timelimit: 3
while (TRUE) {
# Loop, infinitely
Expand All @@ -268,7 +269,6 @@ while (TRUE) {
#### Output

```{webr}
#| autorun: false
#| timelimit: 3
while (TRUE) {
# Loop, infinitely
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/cell-options.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ The following code cell options can be used in `webr` or `pyodide` blocks, or se

| Option | Default | Description |
|--------|---------|-------------|
| `autorun` | `true` | Evaluate initial code block contents automatically? |
| `autorun` | `false` | Evaluate initial code block contents automatically? |
| `caption` | None | Heading text for code editor block. |
| `completion` | `false` | Show code completion and suggestions in editor? |
| `completion` | `true` | Show code completion and suggestions in editor? |
| `echo` | `false` | Show source code in output display? |
| `edit` | `true` | Show the code editor? If `false`, a read-only code block is shown. |
| `envir` | `"global"` | Label for execution environment. |
Expand Down
2 changes: 1 addition & 1 deletion live-runtime/src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ abstract class ExerciseEditor {

// Default editor options
this.options = Object.assign({
autorun: true,
autorun: false,
completion: true,
runbutton: true,
startover: true,
Expand Down

0 comments on commit 46f5dea

Please sign in to comment.