-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Make hiding and showing of setup code in code examples more obvious #663
Comments
This already exists today http://rust-lang-nursery.github.io/mdBook/format/mdbook.html#hiding-code-lines |
Oh, you want a new, additional syntax. Sorry! I missed that. |
Yup, also see how the reader can expand the example to see the setup. This is nice, because the author can focus in on a specific point, while still allowing folks to copy-paste a working thing if they want to. |
That's already in there today; this would purely be about the new comment style. |
OHH, we're talking about the 'fullscreen' icon here? I thought it was a full screen icon, so I never tried clicking on it. Also, it would be nice to have some styling that separated the hidden code from the non-hidden code in the expanded mode. The UX design on the Kotlin docs seems to have been nicely thought through in that respect. I do understand that there might have been time and resource allocation constraints when the feature was first added. But yeah, all the more reason to be inspired by other people's good ideas! |
Updated the title and issue description to reflect the discussion! |
I would say that one issue with the Also, does Rustdoc fix the indentation of stuff like: #fn main() {
println!("hi");
#} So that it renders like this in the collapsed mode: println!("hi"); And not this: println!("hi"); |
It's too hard to fix in the general case, so we don't deal with indentation at all. |
Just wanted to echo the sentiment here:
It took me a long time to notice that icon, then to not dismiss it as something like "open in a new window" or "fullscreen" to the point where I actually hovered over and saw the title. Sharing the fact this feature exists with others has made me feel popular and smart, but this definitely seems like the icon could be working harder to promote itself. An "eye" icon in open and closed variants was suggested and makes a lot of sense to me. |
Wow just found out about the hidden-code-lines! I think an icon similar to https://image.flaticon.com/icons/png/512/56/56181.png would be more appropriate. But yeah, the way it is in the Kotlin docs is really nice! Much more intuitive. |
I believe this is what we'd use: |
In a recent discussion in the amethyst docs discord channel, it was suggested that using an "eye" icon might make the show hidden lines feature of mdbook's code sample rendering more discoverable. I myself overlooked the arrows that are in use now. Fixes rust-lang#663 at least in part.
In a recent discussion in the amethyst docs discord channel, it was suggested that using an "eye" icon might make the show hidden lines feature of mdbook's code sample rendering more discoverable. I myself overlooked the arrows that are in use now. Fixes rust-lang#663 at least in part.
In a recent discussion in the amethyst docs discord channel, it was suggested that using an "eye" icon might make the show hidden lines feature of mdbook's code sample rendering more discoverable. I myself overlooked the arrows that are in use now. Fixes rust-lang#663 at least in part.
Just came across this in the Kotlin docs - they let you hide and show the setup code in examples:
Very slick!
It seems that instead of the
#
comments like we currently have for hiding code lines, they use special comments to mark the beginning and end of samples:Also note that code is re-indented as necessary:
Edit
I didn't actually realise you could hide/show code in mdBook, but it seems you can! Alas it's hidden behind a non-obvious icon that I interpreted to mean 'fullscreen':
Also, the Kotlin examples have a different background behind the setup code in the expanded mode, which is really nice touch. Makes the setup code recede into the background, and you don't have to remember so much what the original example looked like. The is very handy for more involved examples.
The text was updated successfully, but these errors were encountered: