Skip to content

Commit

Permalink
Rename playpen to playground. (#1241)
Browse files Browse the repository at this point in the history
looks good
  • Loading branch information
ehuss authored Jun 22, 2020
1 parent fe1ba71 commit bc23d08
Show file tree
Hide file tree
Showing 19 changed files with 191 additions and 169 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ preprocessors are:
all `README.md` chapters to `index.md` so `foo/README.md` can be accessed via
the url `foo/` when published to a browser
- `links` - a built-in preprocessor (enabled by default) for expanding the
`{{# playpen}}` and `{{# include}}` helpers in a chapter.
`{{# playground}}` and `{{# include}}` helpers in a chapter.
Renderers are given the final book so they can do something with it. This is
typically used for, as the name suggests, rendering the document in a particular
Expand Down
2 changes: 1 addition & 1 deletion book-example/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ edition = "2018"
[output.html]
mathjax-support = true

[output.html.playpen]
[output.html.playground]
editable = true
line-numbers = true

Expand Down
8 changes: 4 additions & 4 deletions book-example/src/format/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ This controls the build process of your book.

The following preprocessors are available and included by default:

- `links`: Expand the `{{ #playpen }}`, `{{ #include }}`, and `{{ #rustdoc_include }}` handlebars
- `links`: Expand the `{{ #playground }}`, `{{ #include }}`, and `{{ #rustdoc_include }}` handlebars
helpers in a chapter to include the contents of a file.
- `index`: Convert all chapter files named `README.md` into `index.md`. That is
to say, all `README.md` would be rendered to an index file `index.html` in the
Expand Down Expand Up @@ -191,7 +191,7 @@ The following configuration options are available:
contents column. For example, "1.", "2.1". Set this option to true to disable
those labels. Defaults to `false`.
- **fold:** A subtable for configuring sidebar section-folding behavior.
- **playpen:** A subtable for configuring various playpen settings.
- **playground:** A subtable for configuring various playground settings.
- **search:** A subtable for configuring the in-browser search functionality.
mdBook must be compiled with the `search` feature enabled (on by default).
- **git-repository-url:** A url to the git repository for the book. If provided
Expand All @@ -212,7 +212,7 @@ Available configuration options for the `[output.html.fold]` table:
- **level:** The higher the more folded regions are open. When level is 0, all
folds are closed. Defaults to `0`.

Available configuration options for the `[output.html.playpen]` table:
Available configuration options for the `[output.html.playground]` table:

- **editable:** Allow editing the source code. Defaults to `false`.
- **copyable:** Display the copy button on code snippets. Defaults to `true`.
Expand Down Expand Up @@ -271,7 +271,7 @@ git-repository-icon = "fa-github"
enable = false
level = 0

[output.html.playpen]
[output.html.playground]
editable = false
copy-js = true
line-numbers = false
Expand Down
14 changes: 7 additions & 7 deletions book-example/src/format/mdbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,17 @@ impl System for MySystem { ... }
Then in the book, all you have to do is:
````hbs
Here is a component:
```rust,no_run,noplaypen
```rust,no_run,noplayground
\{{#include file.rs:component}}
```
Here is a system:
```rust,no_run,noplaypen
```rust,no_run,noplayground
\{{#include file.rs:system}}
```
This is the full file.
```rust,no_run,noplaypen
```rust,no_run,noplayground
\{{#include file.rs:all}}
```
````
Expand Down Expand Up @@ -178,17 +178,17 @@ That is, it looks like this (click the "expand" icon to see the rest of the file
With the following syntax, you can insert runnable Rust files into your book:

```hbs
\{{#playpen file.rs}}
\{{#playground file.rs}}
```

The path to the Rust file has to be relative from the current source file.

When play is clicked, the code snippet will be sent to the [Rust Playpen] to be
When play is clicked, the code snippet will be sent to the [Rust Playground] to be
compiled and run. The result is sent back and displayed directly underneath the
code.

Here is what a rendered code snippet looks like:

{{#playpen example.rs}}
{{#playground example.rs}}

[Rust Playpen]: https://play.rust-lang.org/
[Rust Playground]: https://play.rust-lang.org/
10 changes: 5 additions & 5 deletions book-example/src/format/theme/editor.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Editor

In addition to providing runnable code playpens, mdBook optionally allows them
In addition to providing runnable code playgrounds, mdBook optionally allows them
to be editable. In order to enable editable code blocks, the following needs to
be added to the ***book.toml***:

```toml
[output.html.playpen]
[output.html.playground]
editable = true
```

Expand All @@ -19,7 +19,7 @@ fn main() {
}
```</code></pre>

The above will result in this editable playpen:
The above will result in this editable playground:

```rust,editable
fn main() {
Expand All @@ -28,15 +28,15 @@ fn main() {
}
```

Note the new `Undo Changes` button in the editable playpens.
Note the new `Undo Changes` button in the editable playgrounds.

## Customizing the Editor

By default, the editor is the [Ace](https://ace.c9.io/) editor, but, if desired,
the functionality may be overriden by providing a different folder:

```toml
[output.html.playpen]
[output.html.playground]
editable = true
editor = "/path/to/editor"
```
Expand Down
35 changes: 18 additions & 17 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl Config {
/// Fetch an arbitrary item from the `Config` as a `toml::Value`.
///
/// You can use dotted indices to access nested items (e.g.
/// `output.html.playpen` will fetch the "playpen" out of the html output
/// `output.html.playground` will fetch the "playground" out of the html output
/// table).
pub fn get(&self, key: &str) -> Option<&Value> {
self.rest.read(key)
Expand Down Expand Up @@ -451,11 +451,11 @@ impl Default for BuildConfig {
}
}

/// Configuration for the Rust compiler(e.g., for playpen)
/// Configuration for the Rust compiler(e.g., for playground)
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case")]
pub struct RustConfig {
/// Rust edition used in playpen
/// Rust edition used in playground
pub edition: Option<RustEdition>,
}

Expand Down Expand Up @@ -496,8 +496,9 @@ pub struct HtmlConfig {
pub additional_js: Vec<PathBuf>,
/// Fold settings.
pub fold: Fold,
/// Playpen settings.
pub playpen: Playpen,
/// Playground settings.
#[serde(alias = "playpen")]
pub playground: Playground,
/// Don't render section labels.
pub no_section_label: bool,
/// Search settings. If `None`, the default will be used.
Expand Down Expand Up @@ -533,7 +534,7 @@ impl Default for HtmlConfig {
additional_css: Vec::new(),
additional_js: Vec::new(),
fold: Fold::default(),
playpen: Playpen::default(),
playground: Playground::default(),
no_section_label: false,
search: None,
git_repository_url: None,
Expand Down Expand Up @@ -567,24 +568,24 @@ pub struct Fold {
pub level: u8,
}

/// Configuration for tweaking how the the HTML renderer handles the playpen.
/// Configuration for tweaking how the the HTML renderer handles the playground.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case")]
pub struct Playpen {
/// Should playpen snippets be editable? Default: `false`.
pub struct Playground {
/// Should playground snippets be editable? Default: `false`.
pub editable: bool,
/// Display the copy button. Default: `true`.
pub copyable: bool,
/// Copy JavaScript files for the editor to the output directory?
/// Default: `true`.
pub copy_js: bool,
/// Display line numbers on playpen snippets. Default: `false`.
/// Display line numbers on playground snippets. Default: `false`.
pub line_numbers: bool,
}

impl Default for Playpen {
fn default() -> Playpen {
Playpen {
impl Default for Playground {
fn default() -> Playground {
Playground {
editable: false,
copyable: true,
copy_js: true,
Expand Down Expand Up @@ -694,7 +695,7 @@ mod tests {
git-repository-url = "https://foo.com/"
git-repository-icon = "fa-code-fork"
[output.html.playpen]
[output.html.playground]
editable = true
editor = "ace"
Expand Down Expand Up @@ -725,7 +726,7 @@ mod tests {
use_default_preprocessors: true,
};
let rust_should_be = RustConfig { edition: None };
let playpen_should_be = Playpen {
let playground_should_be = Playground {
editable: true,
copyable: true,
copy_js: true,
Expand All @@ -737,7 +738,7 @@ mod tests {
additional_css: vec![PathBuf::from("./foo/bar/baz.css")],
theme: Some(PathBuf::from("./themedir")),
default_theme: Some(String::from("rust")),
playpen: playpen_should_be,
playground: playground_should_be,
git_repository_url: Some(String::from("https://foo.com/")),
git_repository_icon: Some(String::from("fa-code-fork")),
redirect: vec![
Expand Down Expand Up @@ -854,7 +855,7 @@ mod tests {
// is happy...
let src = COMPLEX_CONFIG;
let mut config = Config::from_str(src).unwrap();
let key = "output.html.playpen.editable";
let key = "output.html.playground.editable";

assert_eq!(config.get(key).unwrap(), &Value::Boolean(true));
*config.get_mut(key).unwrap() = Value::Boolean(false);
Expand Down
Loading

0 comments on commit bc23d08

Please sign in to comment.