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

Adding imports and main to first README example #10

Closed
wants to merge 1 commit into from
Closed

Adding imports and main to first README example #10

wants to merge 1 commit into from

Conversation

arashout
Copy link

Hey I'm a rust newbie and it took awhile to get the first example to work. So I thought I would the imports you need to get going

Hey I'm a rust newbie and it took awhile to get the first example to work. So I thought I would the imports you need to get going
@jonhoo
Copy link
Owner

jonhoo commented Apr 11, 2018

Hey! And welcome!

This repository uses cargo-readme, which causes README.md to be generated from the top-level crate documentation in src/lib.rs. This is so that any example code is also run as documentation tests, so I'll know if I accidentally break an example. In this particular case, I was taking advantage of hidden statements so that the user isn't distracted by all the boilerplate of extern crate (which will soon go away) and use statements. But, as you have just demonstrated, that hiding backfires! If you look at the raw example code in src/lib.rs, you'll see that the lines you added are in fact there:

https://github.com/jonhoo/fantoccini/blob/master/src/lib.rs#L30-L36

That's why the test indeed passes, even though it is seemingly missing some lines.

I think the right thing to do here would be to keep the extern crate and fn main() { lines hidden, but unhide the use statements in the first example. Hopefully that'll make it clearer to newcomers to the library what they need to do without introducing too much extra noise. The compiler will suggest the missing extern crate statements.

If you want to submit a PR that unhides the lines in src/lib.rs, I can re-run cargo readme. Or you can re-generate README.md yourself with cargo readme > README.md if you want and include it in the PR.

Thanks!

@arashout arashout closed this Apr 12, 2018
@arashout arashout deleted the patch-1 branch April 12, 2018 13:34
@arashout
Copy link
Author

Oh! That's pretty cool, I did not realize that. Will create another PR doing it the right way

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