Closed Michael-F-Bryan closed 4 years ago
I am tentatively interested in supporting this.
As an alternative to :stringify
, it's possible we could just concatenate anything inside a doc attribute.
#[doc = "Create a new [`" $ret "`] object."]
pub fn $name() -> $ret { todo!() }
Your proposed solution feels a lot more powerful and ergonomic. It'd be a pain to make a new #[doc = [< $ret:stringify >] ]
attribute every time you want to add something to a doc-comment.
I have not found a way to do this (with this or any other crate). Having the ability to do this would make my day!
I don't suppose we ever implemented something like Michael suggested?
My use case is to inject a stringified ident into another macro, e.g. #[sbor(categorize_as = [< $generic_ident:stringify >])]
- I've tried the short-hand #[sbor(categorize_as = "" $generic_ident "")]
just in case the doc string parsing was more generic, but it didn't work.
EDIT: I've published my own pre-processor which is inspired by paste, but more powerful - this is available now in this crate, but might move out soon: https://docs.rs/sbor-derive/1.2.0/sbor_derive/macro.eager_replace.html
Would it be possible to use
paste
as a workaround for rust-lang/rust#52607? I was thinking you could add a:stringify
modifier which will wrap the concatenated text in a string literal.Imagine being able to write something like this:
This is kinda related to #29 in that we're playing with
#[doc]
attributes, with the difference being where the string comes from. In that issue it comes fromstringify!($name)
in a previous macro invocation, but here we'd be usingpaste
to generate the doc string directly.