-
Notifications
You must be signed in to change notification settings - Fork 47
Add new method and tidy examples #110
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
Add new method and tidy examples #110
Conversation
6de9fda to
76ed47c
Compare
|
Looks like CI tests are failing due to rust-lang/rustup#4220. |
This allows simpler instantiation of a new Gpx object.
These changes simplify the example and allow it to be ran as a doctest. - Use ::new() functions instead of struct literals to make the code easier to read. - Use the tempfile crate so that we can write to a throw-away file. - Convert the example to a main() function with a simpler function signature. - Re-arrange statements so that we populate the Gpx object first then open the output file and write to it.
These changes allow the example to be ran as a doctest.
76ed47c to
4343e29
Compare
michaelkirk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I rebased and will merge as soon as tests pass. Thank you!
| pub mod errors; | ||
|
|
||
| // Ensure that examples in the README are tested | ||
| #[doc = include_str!("../README.md")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never seen this before. Love it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found an example in the docs: https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#include-items-only-when-collecting-doctests
Another possible use of #[cfg(doctest)] is to test doctests that are included in your README file without including it in your main documentation. For example, you could write this into your lib.rs to test your README as part of your doctests:
#[doc = include_str!("../README.md")] #[cfg(doctest)] pub struct ReadmeDoctests;This will include your README as documentation on the hidden struct ReadmeDoctests, which will then be tested alongside the rest of your doctests.
CHANGELOG.mdif knowledge of this change could be valuable to users.