Skip to content

It would be nice if the code examples could be edited in-place #1874

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

Closed
TobiasWehrum opened this issue Mar 20, 2019 · 3 comments
Closed

It would be nice if the code examples could be edited in-place #1874

TobiasWehrum opened this issue Mar 20, 2019 · 3 comments
Labels
blocked upstream Blocked on a change that needs to happen in a different repo first Enhancement Online only

Comments

@TobiasWehrum
Copy link

TobiasWehrum commented Mar 20, 2019

One thing that I really like about https://doc.rust-lang.org/stable/rust-by-example is that all code can be edited and run right in the browser. While The Book obviously has a different focus, sometimes I feel like it would be nice to make little changes to example code just to see what the result would be. (That applies to almost all code examples, but it's especially true e.g. in listing 7-11 - it would've been great if I could've just uncommented the code and see what happens.)

@TobiasWehrum
Copy link
Author

TobiasWehrum commented Mar 21, 2019

I tried to do that myself to see how hard it would be, and it seems that the main problem is that mdBook doesn't support both hidden code and editable code at the same time. Allowing code to be edited disables the automatic addition of #![allow(unused_variables)] fn main() { } which also means that the code is editable, but doesn't compile. Manually adding those lines with the syntax described here didn't work either - the playpen sections just displayed those lines as they are, with a # in front of them.

By the way, how does the automatic addition of the boilerplate work anyway? I didn't find any mechanism that decides whether to add it or not, nor did I find anything in the mdBook documentation. (edit: Okay, found it. Apparently it's done via some pre-processing magic in rustdoc that is also used in mdBook.)

@carols10cents
Copy link
Member

This sounds like there's an issue with mdBook that's blocking this; labeling appropriately.

@carols10cents carols10cents added the blocked upstream Blocked on a change that needs to happen in a different repo first label Mar 21, 2019
@carols10cents
Copy link
Member

I've decided to close this; if mdbook gets this support, we'll upgrade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked upstream Blocked on a change that needs to happen in a different repo first Enhancement Online only
Projects
None yet
Development

No branches or pull requests

3 participants