moverox_codegen/attributes.rs
1use move_syn::Attribute;
2use quote::quote;
3use unsynn::{ToTokens as _, TokenStream};
4
5/// Filter Move attributes and convert them to Rust.
6///
7/// For now, we process only doc attributes.
8pub(super) fn to_rust(attrs: &[Attribute]) -> TokenStream {
9 attrs
10 .iter()
11 .filter(|attr| attr.is_doc())
12 .map(|attr| {
13 let inner = attr.contents().to_token_stream();
14 // NOTE: disable when compiling doctests to avoid Rust interpreting code blocks as
15 // runnable tests.
16 quote!(#[cfg_attr(not(doctest), #inner)])
17 })
18 .collect()
19}