How can I add and use doc comments with a macro invocation?
macro_rules! foo {
(
$(#[$outer:meta])*
$name:ident
) => {
pub mod $name {
$(#[$outer])*
pub const THE_ANSWER: i32 = 42;
}
}
}
/// doc for macro created module
foo!(bar);
fn main() {
println!("{}", bar::THE_ANSWER);
}
I seem to be doing what's recommended by this question but I still get the warning.
warning: unused doc comment
--> src/main.rs:13:1
|
13 | /// doc for macro created module
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ rustdoc does not generate documentation for macro invocations
|
= note: `#[warn(unused_doc_comments)]` on by default
= help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion