Skip to content

Commit 5d8443a

Browse files
talk about --playground-url
1 parent bb32823 commit 5d8443a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/doc/rustdoc/src/unstable-features.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,26 @@ Just like `--html-after-content`, this allows you to insert extra content before
231231
but after the other content `rustdoc` would normally produce in the rendered documentation.
232232
However, instead of directly inserting the file verbatim, `rustdoc` will pass the files through a
233233
Markdown renderer before inserting the result into the file.
234+
235+
### `--playground-url`: control the location of the playground
236+
237+
Using this flag looks like this:
238+
239+
```bash
240+
$ rustdoc src/lib.rs -Z unstable-options --playground-url https://play.rust-lang.org/
241+
```
242+
243+
When rendering a crate's docs, this flag gives the base URL of the Rust Playground, to use for
244+
generating `Run` buttons. Unlike `--markdown-playground-url`, this argument works for standalone
245+
Markdown files *and* Rust crates. This works the same way as adding `#![doc(html_playground_url =
246+
"url")]` to your crate root, as mentioned in [the chapter about the `#[doc]`
247+
attribute][doc-playground]. Please be aware that the official Rust Playground at
248+
https://play.rust-lang.org does not have every crate available, so if your examples require your
249+
crate, make sure the playground you provide has your crate available.
250+
251+
[doc-playground]: the-doc-attribute.html#html_playground_url
252+
253+
If both `--playground-url` and `--markdown-playground-url` are present when rendering a standalone
254+
Markdown file, the URL given to `--markdown-playground-url` will take precedence. If both
255+
`--playground-url` and `#![doc(html_playground_url = "url")]` are present when rendering crate docs,
256+
the attribute will take precedence.

0 commit comments

Comments
 (0)