rust-random / book

The Rust Rand Book
Other
49 stars 19 forks source link

Add test harness #49

Closed dhardy closed 2 years ago

dhardy commented 2 years ago

Uses doc_comment to add a test harness for the code samples within documentation. This allows us to specify dependency versions (not possible through mdbook).

Note that not all code samples actually run since this uses the playground, which currently uses an old version of rand_pcg.

As for testing links... in theory mdbook-linkcheck does this, but using it on this repo generates a lot of errors like this:

error: Linking outside of the "root" directory is forbidden
    ┌─ update-0.8.md:190:1
    │
190 │ [`IteratorRandom::choose_stable`] was added to provide an alternative that
    │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Linking outside of the "root" directory is forbidden

These links (e.g. ../rand/rand/seq/trait.IteratorRandom.html#method.choose_stable) work where deployed (and locally with a symlink to the built docs). We could replace with absolute URLs, but I suspect linkcheck would ignore them in that case.

... thus, I just laboriously clicked on every link to test.

Some documentation got updated here: the Sequences page, part of the Distributions page. @vks would be nice if you do a quick review.

Closes #46. Closes #2 (well, link checks are omitted — without a plan for handling cross-crate links I don't see much use for it).