Skip to content

Commit 9827595

Browse files
committed
feat: add playpen topic
1 parent ef4ad08 commit 9827595

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,4 @@
213213

214214
- [Meta](meta.md)
215215
- [Documentation](meta/doc.md)
216+
- [Playpen](meta/playpen.md)

src/meta/playpen.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Playpen
2+
3+
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/).
4+
5+
## Using it with `mdbook`
6+
7+
In [`mdbook`][mdbook], you can make code examples playable and editable.
8+
9+
```rust,editable
10+
fn main() {
11+
println!("Hello World!");
12+
}
13+
```
14+
15+
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.
16+
17+
````markdown
18+
```rust,editable
19+
//...place your code here
20+
```
21+
````
22+
23+
## Using it with docs
24+
25+
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].
26+
27+
### See also:
28+
29+
- [The Rust Playground][rust-playground]
30+
- [The next-gen playpen][next-gen-playpen]
31+
- [The rustdoc Book][rustdoc-book]
32+
33+
[rust-playground]: https://play.rust-lang.org/
34+
[next-gen-playpen]: https://github.com/integer32llc/rust-playground/
35+
[mdbook]: https://github.com/rust-lang/mdBook
36+
[official-rust-docs]: https://doc.rust-lang.org/core/
37+
[rustdoc-book]: https://doc.rust-lang.org/rustdoc/what-is-rustdoc.html
38+
[html-playground-url]: https://doc.rust-lang.org/rustdoc/the-doc-attribute.html#html_playground_url

0 commit comments

Comments
 (0)