Skip to content
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

Hiding parts of examples #73

Closed
steveklabnik opened this issue Dec 17, 2015 · 9 comments
Closed

Hiding parts of examples #73

steveklabnik opened this issue Dec 17, 2015 · 9 comments

Comments

@steveklabnik
Copy link
Member

Rustdoc has a feature that allows you to hide parts of examples:

fn another_function(x: i32) {
# }

This will hide the closing }, but allow the example to compile. This is really useful for hiding parts of examples which confuse the point, yet allow them to still compile.

2015-12-17-125058_223x62_scrot

@azerupi
Copy link
Contributor

azerupi commented Dec 17, 2015

I could add this but I am a little worried it might conflict with some code snippets. For example, if you want to show some python example and have line comments in it, the comments will not be shown.

An easy way to solve this might be to enable this only for rust code.

@steveklabnik
Copy link
Member Author

An easy way to solve this might be to enable this only for rust code.

Yeah, that seems like a reasonable compromise, if this is a feature you're willing to support.

@azerupi
Copy link
Contributor

azerupi commented Dec 27, 2015

Thought to myself:
Maybe this could be implemented as a javascript plugin?

@steveklabnik
Copy link
Member Author

Oh that's interesting...

@steveklabnik
Copy link
Member Author

Actually, that idea is really great. I don't have time to type it all out right now, but this would solve a big problem we have with this feature...

@azerupi
Copy link
Contributor

azerupi commented Dec 27, 2015

Actually, that idea is really great. I don't have time to type it all out right now, but this would solve a big problem we have with this feature...

Would that be the show/hide full examples problem? Or something else entirely? :)

@steveklabnik
Copy link
Member Author

Yeah, the fact that people don't always see the context. It causes lots of issues in the stdlib with try!, specifically...

@azerupi
Copy link
Contributor

azerupi commented Dec 28, 2015

Yes, I have seen the debates 😉

I will try to hack something nice together, unless someone else beats me to it.

@azerupi
Copy link
Contributor

azerupi commented Dec 29, 2015

This should now work. For the moment only in Rust code, but this could be generalized in the future with a little work. I have also added an expand / collapse button, to show / hide the lines.

I haven't done a lot of testing so there could be some rough edges.

@azerupi azerupi closed this as completed Dec 29, 2015
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

No branches or pull requests

2 participants