Hi everybody,
I am using macros to define a number of structures for which I would like to add specific documentation.
I have created a simple example to illustrate what I mean below.
In this example, I would like that in the docs appears something like Pin 0 for P0.
At the moment all I can get is Pin $i.
Is there a way to achieve this?
Both forms take string literals as parameters, there is no pass that expands provided variables first. Maybe this is easily doable in macro context, maybe not; I think a new syntax will be necessary to achieve this effect.
The macros std::include! and variants suffer from a similar problem; they take an expression but only an actual string literal works. This means that you cannot call them 'dynamically' from another macro.
There is a way to make it work, though it requires two macro invocations. Basically, #[doc = concat!("stuff")] doesn't parse, while #[doc = $doc] does.