diff options
author | HampusM <hampus@hampusmat.com> | 2023-03-19 12:36:01 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2023-03-19 12:36:01 +0100 |
commit | 21911153355b4bf9612c38f5ac92562aec02ffd9 (patch) | |
tree | e17fab91a142f6d5fe3d2bfe820dbd8bdee46ee6 | |
parent | 2d964b39da09ad82eccf09abdea73967bbff76f2 (diff) |
docs: add documentation comments
-rw-r--r-- | macros/Cargo.toml | 3 | ||||
-rw-r--r-- | macros/src/lib.rs | 34 | ||||
-rw-r--r-- | src/lib.rs | 3 |
3 files changed, 38 insertions, 2 deletions
diff --git a/macros/Cargo.toml b/macros/Cargo.toml index 00efccf..818cf8c 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -11,3 +11,6 @@ quote = "1.0.26" syn = { version = "1.0.109", features = ["full", "printing"] } proc-macro-error = "1.0.4" proc-macro2 = "1.0.52" + +[dev-dependencies] +ridicule = { version = "0.1.0", path = ".." } diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 8106a8c..f11c064 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -1,4 +1,5 @@ -#![deny(clippy::all, clippy::pedantic)] +//! Macros for Ridicule, a mocking library supporting non-static generics. +#![deny(clippy::all, clippy::pedantic, missing_docs)] use proc_macro::TokenStream; use proc_macro_error::{proc_macro_error, ResultExt}; use quote::{format_ident, quote}; @@ -14,6 +15,37 @@ mod mock_input; mod syn_ext; mod util; +/// Creates a mock. +/// +/// # Examples +/// ``` +/// use ridicule::mock; +/// +/// trait Foo +/// { +/// fn bar<A, B>(&self, a: A) -> B; +/// } +/// +/// mock! { +/// MockFoo {} +/// +/// impl Foo for MockFoo +/// { +/// fn bar<A, B>(&self, a: A) -> B; +/// } +/// } +/// +/// fn main() +/// { +/// let mut mock_foo = MockFoo::new(); +/// +/// mock_foo +/// .expect_bar() +/// .returning(|foo, a: u32| format!("Hello {a}")); +/// +/// assert_eq!(mock_foo.bar::<u32, String>(123), "Hello 123"); +/// } +/// ``` #[proc_macro] #[proc_macro_error] pub fn mock(input_stream: TokenStream) -> TokenStream @@ -1,4 +1,5 @@ -#![deny(clippy::all, clippy::pedantic)] +//! Mocking library supporting non-static generics. +#![deny(clippy::all, clippy::pedantic, missing_docs)] pub use ridicule_macros::mock; |