1 | #![allow (clippy::uninlined_format_args)] |
2 | |
3 | use proc_macro::TokenStream; |
4 | use proc_macro2::Ident; |
5 | use quote::quote; |
6 | use syn::{parse_macro_input, ItemFn}; |
7 | |
8 | #[proc_macro_attribute ] |
9 | pub fn corresponds (attr: TokenStream, item: TokenStream) -> TokenStream { |
10 | let function: Ident = parse_macro_input!(attr as Ident); |
11 | let item: ItemFn = parse_macro_input!(item as ItemFn); |
12 | |
13 | let function: String = function.to_string(); |
14 | let line: String = format!( |
15 | "This corresponds to [` {0}`](https://www.openssl.org/docs/manmaster/man3/ {0}.html)." , |
16 | function |
17 | ); |
18 | |
19 | let attrs: Vec = item.attrs; |
20 | let vis: Visibility = item.vis; |
21 | let sig: Signature = item.sig; |
22 | let block: Box = item.block; |
23 | |
24 | let out: TokenStream = quote! { |
25 | #(#attrs)* |
26 | #[doc = "" ] |
27 | #[doc = #line] |
28 | #[doc(alias = #function)] |
29 | #vis #sig #block |
30 | }; |
31 | out.into() |
32 | } |
33 | |