Skip to content

Commit 325a512

Browse files
authored
Merge pull request #1324 from jsjoeio/jsjoeio/108-add-playpen-topic
feat: add playpen topic
2 parents 8e253cb + 3e42f06 commit 325a512

File tree

4 files changed

+48
-6
lines changed

4 files changed

+48
-6
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
book
2+
3+
# Auto-generated files from macOS
4+
.DS_Store

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.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Some topics aren't exactly relevant to how you program but provide you
44
tooling or infrastructure support which just makes things better for
55
everyone. These topics include:
66

7-
* Documentation: Generate library documentation for users via the included
8-
`rustdoc`.
9-
* Testing: Create testsuites for libraries to give confidence that your
10-
library does exactly what it's supposed to.
11-
* Benchmarking: Create benchmarks for functionality to be confident that
12-
they run quickly.
7+
- [Documentation][doc]: Generate library documentation for users via the included
8+
`rustdoc`.
9+
- [Playpen][playpen]: Integrate the Rust Playpen(also known as the Rust Playground) in your documentation.
10+
11+
[doc]: meta/doc.md
12+
[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)