#macro-rules

docgen

Rust library made for dynamically documenting Rust items created by a macro

3 releases

0.1.2 May 6, 2021
0.1.1 May 5, 2021
0.1.0 May 4, 2021

#2108 in Rust patterns

Download history 21/week @ 2023-10-17 23/week @ 2023-10-24 13/week @ 2023-10-31 24/week @ 2023-11-07 23/week @ 2023-11-14 24/week @ 2023-11-21 32/week @ 2023-11-28 19/week @ 2023-12-05 22/week @ 2023-12-12 21/week @ 2023-12-19 30/week @ 2023-12-26 21/week @ 2024-01-02 21/week @ 2024-01-09 18/week @ 2024-01-16 24/week @ 2024-01-23 33/week @ 2024-01-30

99 downloads per month

MIT license

4KB

docgen  Build Status Latest Version

Rust library made for dynamically documenting Rust items created by a macro. View the documentation on docs.rs here.

License

This crate is available as open source under the terms of the MIT License.


lib.rs:

This small crate is to let developers easily document items generated in macros where the content of the documentation is dynamic.

Examples

#[macro_use]
extern crate docgen;

doc!(
    "Here is some documentation!"
    ""
    "Empty lines are represented by empty strings.";
    pub fn foo() {}
);

Commas can be used as delimitter between lines:

#[macro_use]
extern crate docgen;

doc!(
    "Here is some documentation!",
    "",
    "Empty lines are represented by empty strings.";
    pub fn foo() {}
);

This is particularly useful when documenting items created by macros:

#[macro_use]
extern crate docgen;

macro_rules! add_fn {
    ($name:ident, $ty:ty) => {
        doc!(
            concat!("Add two [`", stringify!($ty), "`] values together.");
            pub fn $name(a: $ty, b: $ty) -> $ty {
                a + b
            }
        );
    }
}

add_fn!(add_u8, u8);
add_fn!(add_i8, i8);

No runtime deps