Skip to content

Commit

Permalink
Add Doctest for README.md
Browse files Browse the repository at this point in the history
Ensure testing of examples in the README.
  • Loading branch information
johnstonskj committed Jul 18, 2022
1 parent 982e923 commit 90532f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ serde = { optional = true, version = "1.0.110", features = ["derive"] }
[dev-dependencies]
proptest = "1.0.0"
pretty_assertions = "1.0.0"
doc-comment = "0.3"

[dev-dependencies.cargo-husky]
version = "1"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ Another approach is to use a more readable *builder* which also allows you to ig
in the ARN you don't always need and uses a more fluent style of ARN construction.

```rust
45Muse aws_arn::builder::{ArnBuilder, ResourceBuilder};
use aws_arn::builder::{ArnBuilder, ResourceBuilder};
use aws_arn::known::{Partition, Service};
use aws_arn::{ResourceName, Identifier};
use aws_arn::{ResourceName, Identifier, IdentifierLike};
use std::str::FromStr;

let arn: ResourceName = ArnBuilder::service_id(Service::S3.into())
Expand Down
9 changes: 8 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,13 @@ impl ResourceName {
}
}

// ------------------------------------------------------------------------------------------------
// External Doc Tests
// ------------------------------------------------------------------------------------------------

#[cfg(doctest)]
doc_comment::doctest!("../README.md");

// ------------------------------------------------------------------------------------------------
// Modules
// ------------------------------------------------------------------------------------------------
Expand All @@ -678,4 +685,4 @@ pub mod known;

#[doc(hidden)]
mod error;
pub use crate::error::Error;
pub use error::Error;

0 comments on commit 90532f0

Please sign in to comment.