Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Use Skeptic to compile tests in README.md #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
**/*.rs.bk
Cargo.lock
Cargo.lock
libtest.rmeta
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ travis-ci = { repository = "phw/rust-discid" }
[dependencies]
bitflags = "1.0.4"
discid-sys = "0.2.0"

[build-dependencies]
skeptic = "0.13"

[dev-dependencies]
skeptic = "0.13"
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,30 @@ This library is currently in early development and the API may still change.

### Read only the TOC

```rust
```rust,no_run
use discid::DiscId;

// Specifying the device is optional. If set to `None` a platform
// specific default will be used.
let device = Some("/dev/cdrom");
let disc = DiscId::read(device).expect("Reading disc failed");
println!("ID: {}", disc.id());
fn main() {
// Specifying the device is optional. If set to `None` a platform
// specific default will be used.
let device = Some("/dev/cdrom");
let disc = DiscId::read(device).expect("Reading disc failed");
println!("ID: {}", disc.id());
}
```

### Read the TOC and ISRCs

```rust
```rust,no_run
use discid::{DiscId, Features};

let disc = DiscId::read_features(None, Features::ISRC).expect("Reading disc failed");
println!("Disc ID: {}", disc.id());
fn main() {
let disc = DiscId::read_features(None, Features::ISRC).expect("Reading disc failed");
println!("Disc ID: {}", disc.id());

for track in disc.tracks() {
for track in disc.tracks() {
println!("Track #{} ISRC: {}", track.number, track.isrc);
}
}
```

Expand Down
6 changes: 6 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extern crate skeptic;

fn main() {
// generates doc tests for `README.md`.
skeptic::generate_doc_tests(&["README.md"]);
}
1 change: 1 addition & 0 deletions tests/skeptic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include!(concat!(env!("OUT_DIR"), "/skeptic-tests.rs"));