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