Skip to content

emphasize that doctests don't run in bin crates #27926

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

Merged
merged 1 commit into from
Aug 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/doc/trpl/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ This will highlight according to whatever language you're showing off.
If you're just showing plain text, choose `text`.

It's important to choose the correct annotation here, because `rustdoc` uses it
in an interesting way: It can be used to actually test your examples, so that
they don't get out of date. If you have some C code but `rustdoc` thinks it's
Rust because you left off the annotation, `rustdoc` will complain when trying to
generate the documentation.
in an interesting way: It can be used to actually test your examples in a
library crate, so that they don't get out of date. If you have some C code but
`rustdoc` thinks it's Rust because you left off the annotation, `rustdoc` will
complain when trying to generate the documentation.

## Documentation as tests

Expand Down Expand Up @@ -377,8 +377,8 @@ $ rustdoc --test path/to/my/crate/root.rs
$ cargo test
```

That's right, `cargo test` tests embedded documentation too. However,
`cargo test` will not test binary crates, only library ones. This is
That's right, `cargo test` tests embedded documentation too. **However,
`cargo test` will not test binary crates, only library ones.** This is
due to the way `rustdoc` works: it links against the library to be tested,
but with a binary, there’s nothing to link to.

Expand Down
4 changes: 2 additions & 2 deletions src/doc/trpl/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ Let's finally check out that third section: documentation tests.
Nothing is better than documentation with examples. Nothing is worse than
examples that don't actually work, because the code has changed since the
documentation has been written. To this end, Rust supports automatically
running examples in your documentation. Here's a fleshed-out `src/lib.rs`
with examples:
running examples in your documentation (**note:** this only works in library
crates, not binary crates). Here's a fleshed-out `src/lib.rs` with examples:

```rust,ignore
//! The `adder` crate provides functions that add numbers to other numbers.
Expand Down