Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add playpen topic #1324

Merged
merged 5 commits into from
Mar 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
book

# Auto-generated files from macOS
.DS_Store
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,4 @@

- [Meta](meta.md)
- [Documentation](meta/doc.md)
- [Playpen](meta/playpen.md)
12 changes: 6 additions & 6 deletions src/meta.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Some topics aren't exactly relevant to how you program but provide you
tooling or infrastructure support which just makes things better for
everyone. These topics include:

* Documentation: Generate library documentation for users via the included
`rustdoc`.
* Testing: Create testsuites for libraries to give confidence that your
library does exactly what it's supposed to.
* Benchmarking: Create benchmarks for functionality to be confident that
they run quickly.
- [Documentation][doc]: Generate library documentation for users via the included
`rustdoc`.
- [Playpen][playpen]: Integrate the Rust Playpen(also known as the Rust Playground) in your documentation.

[doc]: meta/doc.md
[playpen]: meta/playpen.md
38 changes: 38 additions & 0 deletions src/meta/playpen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Playpen

The [Rust Playpen](https://github.com/rust-lang/rust-playpen) is a way to experiment with Rust code through a web interface. This project is now commonly referred to as [Rust Playground](https://play.rust-lang.org/).

## Using it with `mdbook`

In [`mdbook`][mdbook], you can make code examples playable and editable.

```rust,editable
fn main() {
println!("Hello World!");
}
```

This allows the reader to both run your code sample, but also modify and tweak it. The key here is the adding the word `editable` to your codefence block separated by a comma.

````markdown
```rust,editable
//...place your code here
```
````

## Using it with docs

You may have noticed in some of the [official Rust docs][official-rust-docs] a button that says "Run", which opens the code sample up in a new tab in Rust Playground. This feature is enabled if you use the #[doc] attribute called [`html_playground_url`][html-playground-url].
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gut check: is this correct and accurate?


### See also:

- [The Rust Playground][rust-playground]
- [The next-gen playpen][next-gen-playpen]
- [The rustdoc Book][rustdoc-book]

[rust-playground]: https://play.rust-lang.org/
[next-gen-playpen]: https://github.com/integer32llc/rust-playground/
[mdbook]: https://github.com/rust-lang/mdBook
[official-rust-docs]: https://doc.rust-lang.org/core/
[rustdoc-book]: https://doc.rust-lang.org/rustdoc/what-is-rustdoc.html
[html-playground-url]: https://doc.rust-lang.org/rustdoc/the-doc-attribute.html#html_playground_url