(sig: &Signature)
| 804 | } |
| 805 | |
| 806 | fn func_sig(sig: &Signature) -> String { |
| 807 | sig.inputs |
| 808 | .iter() |
| 809 | .filter_map(|arg| { |
| 810 | use syn::FnArg::*; |
| 811 | let arg = match arg { |
| 812 | Typed(typed) => typed, |
| 813 | Receiver(_) => return Some("$self".to_owned()), |
| 814 | }; |
| 815 | let ty = arg.ty.as_ref(); |
| 816 | let ty = quote!(#ty).to_string(); |
| 817 | if ty == "FuncArgs" { |
| 818 | return Some("*args, **kwargs".to_owned()); |
| 819 | } |
| 820 | if ty.starts_with('&') && ty.ends_with("VirtualMachine") { |
| 821 | return None; |
| 822 | } |
| 823 | let ident = match arg.pat.as_ref() { |
| 824 | syn::Pat::Ident(p) => p.ident.to_string(), |
| 825 | // FIXME: other => unreachable!("function arg pattern must be ident but found `{}`", quote!(fn #ident(.. #other ..))), |
| 826 | other => quote!(#other).to_string(), |
| 827 | }; |
| 828 | if ident == "zelf" { |
| 829 | return Some("$self".to_owned()); |
| 830 | } |
| 831 | if ident == "vm" { |
| 832 | unreachable!("type &VirtualMachine(`{ty}`) must be filtered already"); |
| 833 | } |
| 834 | Some(ident) |
| 835 | }) |
| 836 | .collect::<Vec<_>>() |
| 837 | .join(", ") |
| 838 | } |
| 839 | |
| 840 | pub(crate) fn format_doc(sig: &str, doc: &str) -> String { |
| 841 | format!("{sig}\n--\n\n{doc}") |
no test coverage detected