3 releases
0.1.2 | May 6, 2021 |
---|---|
0.1.1 | May 5, 2021 |
0.1.0 | May 4, 2021 |
#38 in #created
4KB
docgen
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);