From 21911153355b4bf9612c38f5ac92562aec02ffd9 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 19 Mar 2023 12:36:01 +0100 Subject: docs: add documentation comments --- macros/src/lib.rs | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'macros/src/lib.rs') 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(&self, a: A) -> B; +/// } +/// +/// mock! { +/// MockFoo {} +/// +/// impl Foo for MockFoo +/// { +/// fn bar(&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::(123), "Hello 123"); +/// } +/// ``` #[proc_macro] #[proc_macro_error] pub fn mock(input_stream: TokenStream) -> TokenStream -- cgit v1.2.3-18-g5258