-
Notifications
You must be signed in to change notification settings - Fork 432
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
Some more documentation work #366
Some more documentation work #366
Conversation
03312b4
to
df0ee65
Compare
src/distributions/range.rs
Outdated
@@ -88,6 +88,7 @@ impl<X: SampleRange> Distribution<X> for Range<X> { | |||
/// Helper trait for creating objects using the correct implementation of | |||
/// `RangeImpl` for the sampling type; this enables `Range::new(a, b)` to work. | |||
pub trait SampleRange: PartialOrd+Sized { | |||
/// Actual `RangeImpl` implementation for `X`. |
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'd prefer you didn't use 'actual'; try "The RangeImpl
implementation supporting type X
."
Also, it would make sense now to rename X
→ T
and T
to something else (perhaps Impl
; it's not something users will see a lot). This is what Huon suggested I think.
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.
That sounds better, as always.
#![deny(missing_debug_implementations)] | ||
#![doc(test(attr(allow(unused_variables), deny(warnings))))] |
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 generally prefer warnings to errors (#![warn(...)]
) simply because new compiler versions may add warnings without considering backwards compatibility, thus breaking builds. In the latter case unfortunately we have no choice since warnings from examples are not shown; also "missing docs" is not something the compiler can break so that's fine.
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.
Good point, I'll keep that in mind!
src/lib.rs
Outdated
#[cfg(feature="std")] pub use os::OsRng; | ||
#[doc(inline)] pub use jitter::JitterRng; | ||
#[cfg(feature="std")] | ||
#[doc(inline)] pub use os::OsRng; |
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.
Keep the OsRng import on a single line please; this causes chaos with diff tools.
src/lib.rs
Outdated
@@ -489,61 +388,101 @@ pub trait Rng: RngCore { | |||
Range::sample_single(low, high, self) | |||
} | |||
|
|||
/// Return a bool with a 1 in n chance of true | |||
/// Sample a new value, using the given distribution. |
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.
This commit is just reordering, and this is the diff tool getting confused?
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.
Yes, I made sure not to change anything but the order.
df0ee65
to
208fee3
Compare
Needs rebase |
These traits/methods etc. are re-exported by Rand, so we can just link to ours.
208fee3
to
a70e32e
Compare
That rebase was harder than I thought 😄. I removed the commit that reordered the Rng methods, and recreated it at the end, to make sure I did not lose changes during the rebase. |
ac4290a
to
dc381cf
Compare
Added three more commits, that may need some explanation.
I set the dependency to The line "[ Finally I tried to clean up the list of exported items in Two exceptions: I broke Also the One oddity: even when we build the documentation with "--all-features" |
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 see a couple more significant import changes too:
- no longer expose
Hc128Rng
directly; 👍 - make
reseeding
module private and exposeReseedingRng
directly; breaking (except any usage will be broken anyway); not quite sure about this
I'd have preferred it if you'd brought up the breaking changes in a separate issue/PR. The only one I'm really concerned about is the read
module.
.travis.yml
Outdated
@@ -34,6 +34,8 @@ matrix: | |||
- cargo test --features serde-1,log,nightly | |||
- cargo test --benches | |||
- cargo doc --no-deps --all --all-features | |||
- cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks | |||
- cargo deadlinks |
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 not used it but apparently it only checks local links by default. Is this what we want?
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.
Yes, only the documentation cross-links. But I suppose checking all links can be useful...
src/lib.rs
Outdated
pub use rand_core::{RngCore, BlockRngCore, CryptoRng, SeedableRng}; | ||
pub use rand_core::{ErrorKind, Error}; | ||
|
||
// external rngs | ||
#[doc(inline)] pub use jitter::JitterRng; |
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.
No longer exporting JitterRng
is a breaking change, but I approve.
src/lib.rs
Outdated
#[cfg(feature="std")] pub use entropy_rng::EntropyRng; | ||
#[cfg(feature="std")] pub use os::OsRng; | ||
#[cfg(feature="std")] pub use read::ReadRng; |
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.
This is more convenient but still a significant change. Do we want it? Potentially a Read
wrapper (#254) could also live in rand::read
.
Yes, that would have been better. It was kind of necessary to make the links checking work out, so it would have been hard to separate. |
Mostly just hide, to avoid API breakage.
dc381cf
to
f953c4b
Compare
Updated the commits. |
#![doc(test(attr(allow(unused_variables), deny(warnings))))]
we now make sure all doctest warnings do not get ignored, see Use imported thread_rng() in main doc example. #363.JitterRng
.Rng
, so they show up in a somewhat more logical order in the documentation.rand_core
on docs.rs. Because Rand re-exports the things that are linked to, we can just link to the documentation of the re-exports.I think this is best to review per commit.