Skip to content

Hide non essential parts of "Network" snippets by default #107

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

Merged
merged 1 commit into from
May 19, 2017

Conversation

budziq
Copy link
Collaborator

@budziq budziq commented May 17, 2017

Updated net.md to hide error_chain boilerplate by default
it can be exposed by selecting the "expand button"
The expand button is no longer hidden

This is connected to https://github.com/brson/rust-cookbook/issues/106
@dtolnay please check if net.md and decide if such approach is acceptable

  • Please note no other section was updated as this is only a demo for the moment ;)

@budziq budziq changed the title RFC - INCOMPLETE - Hide non essential parts of snippets by default RFC - INCOMPLETE - Hide non essential parts of "Network" snippets by default May 17, 2017
@dtolnay
Copy link
Member

dtolnay commented May 17, 2017

Thanks! This is great.

Looks like the hidden parts are awkwardly indented by one space when visible. Is that something we can fix or a mdBook bug?

Is // fn main() required?

@budziq
Copy link
Collaborator Author

budziq commented May 17, 2017

both indentation and // fn main() are problems with mdbook:

  • the hidden code has to have at least one space from # char or the doctests will not compile. Possibly this could be solved in mdbook
  • // fn main() - is a workaround for mdbook inserting its own boilerplate
#![allow(unused_variables)]
fn main() {
...

around playpen if it does not find string fn main() in the example (due to quick_main!)

@dtolnay
Copy link
Member

dtolnay commented May 17, 2017

Let's fix both of those in mdBook before merging this. I think the solutions are:

  • It should treat # the same way rustdoc does. That means no awkward one space indent.
  • Do not insert boilerplate if there is a quick_main!.

@dtolnay
Copy link
Member

dtolnay commented May 17, 2017

@budziq
Copy link
Collaborator Author

budziq commented May 17, 2017

@dtolnay I made (hopefully nonidiotic) PR's for both of these issues.
For what is worth the indentation problem can be solved by locally patching the book.js
but I would strongly prefer for this problem to be solved in mdbook.

@budziq
Copy link
Collaborator Author

budziq commented May 18, 2017

Rebased and cleaned up the commit. As both problems are now fixed in upstream mdbook I would wait for the next mdbook release (0.0.22) @azerupi

Updated net.md to hide error_chain boilerplate by default
it can be exposed by selecting the "expand button"
The expand button is no longer hidden
@budziq budziq force-pushed the hide_error_noise branch from 6b5b156 to 20c1e2c Compare May 19, 2017 23:02
@budziq budziq changed the title RFC - INCOMPLETE - Hide non essential parts of "Network" snippets by default Hide non essential parts of "Network" snippets by default May 19, 2017
@budziq
Copy link
Collaborator Author

budziq commented May 19, 2017

@dtolnay mdbook has released a version (0.0.22) with fixes for both blockers.
I have rebased the PR for your consideration.

If the idea and this PR is ok then I'll gladly update rest of the examples.

@dtolnay dtolnay merged commit 3c1d3aa into rust-lang-nursery:master May 19, 2017
@dtolnay
Copy link
Member

dtolnay commented May 19, 2017

Thanks!

@budziq budziq deleted the hide_error_noise branch June 7, 2017 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants