• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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]
corresponds(attr: TokenStream, item: TokenStream) -> TokenStream9 pub fn corresponds(attr: TokenStream, item: TokenStream) -> TokenStream {
10     let function = parse_macro_input!(attr as Ident);
11     let item = parse_macro_input!(item as ItemFn);
12 
13     let function = function.to_string();
14     let line = format!(
15         "This corresponds to [`{0}`](https://www.openssl.org/docs/manmaster/man3/{0}.html).",
16         function
17     );
18 
19     let attrs = item.attrs;
20     let vis = item.vis;
21     let sig = item.sig;
22     let block = item.block;
23 
24     let out = quote! {
25         #(#attrs)*
26         #[doc = ""]
27         #[doc = #line]
28         #[doc(alias = #function)]
29         #vis #sig #block
30     };
31     out.into()
32 }
33