Skip to content

Commit d45b1f8

Browse files
Automatically check if README.md examples are working when running "cargo test"
1 parent 5611490 commit d45b1f8

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ rand = "0.6"
3434
rand_xorshift = "0.1"
3535
serde = "1"
3636
serde_derive = "1"
37+
doc-comment = "0.3"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ command to get a visualization of an nbody simulation. To see the
104104
effect of using Rayon, press `s` to run sequentially and `p` to run in
105105
parallel.
106106

107-
```
107+
```text
108108
> cd rayon-demo
109109
> cargo run --release -- nbody visualize
110110
```
111111

112112
For more information on demos, try:
113113

114-
```
114+
```text
115115
> cd rayon-demo
116116
> cargo run --release -- --help
117117
```

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ extern crate rayon_core;
8585
extern crate rand;
8686
#[cfg(test)]
8787
extern crate rand_xorshift;
88+
#[cfg(test)]
89+
#[macro_use]
90+
extern crate doc_comment;
91+
92+
#[cfg(test)]
93+
doctest!("../README.md");
8894

8995
#[macro_use]
9096
mod delegate;

0 commit comments

Comments
 (0)