Add comon docs
This commit is contained in:
parent
64803a2d16
commit
95104b653b
|
@ -9,42 +9,39 @@ pub fn create_method_without_params(
|
||||||
method_name: proc_macro2::Ident,
|
method_name: proc_macro2::Ident,
|
||||||
url: &str,
|
url: &str,
|
||||||
) -> (proc_macro2::TokenStream, Option<proc_macro2::TokenStream>) {
|
) -> (proc_macro2::TokenStream, Option<proc_macro2::TokenStream>) {
|
||||||
match create_return_type(group, method) {
|
let res = match create_return_type(group, method) {
|
||||||
Some((return_type_name, return_type)) => (
|
Some((return_type_name, return_type)) => (
|
||||||
util::add_docs(
|
quote! {
|
||||||
&method.description,
|
pub async fn #method_name(&self) -> Result<#return_type_name> {
|
||||||
quote! {
|
let res = self.auth
|
||||||
pub async fn #method_name(&self) -> Result<#return_type_name> {
|
.authenticated_client(#url)
|
||||||
let res = self.auth
|
.send()
|
||||||
.authenticated_client(#url)
|
.await?
|
||||||
.send()
|
.json::<#return_type_name>()
|
||||||
.await?
|
.await?;
|
||||||
.json::<#return_type_name>()
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
|
||||||
Some(return_type),
|
Some(return_type),
|
||||||
),
|
),
|
||||||
None => (
|
None => (
|
||||||
util::add_docs(
|
quote! {
|
||||||
&method.description,
|
pub async fn #method_name(&self) -> Result<String> {
|
||||||
quote! {
|
let res = self.auth
|
||||||
pub async fn #method_name(&self) -> Result<String> {
|
.authenticated_client(#url)
|
||||||
let res = self.auth
|
.send()
|
||||||
.authenticated_client(#url)
|
.await?
|
||||||
.send()
|
.text()
|
||||||
.await?
|
.await?;
|
||||||
.text()
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
), // assume that all methods without a return type returns a string
|
// assume that all methods without a return type returns a string
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
}
|
};
|
||||||
|
|
||||||
|
(util::add_docs(&method.description, res.0), res.1)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user