Added doc_comment to properly doc functions
This commit is contained in:
+2
-1
@@ -11,10 +11,11 @@ keywords = ["api", "web", "social", "mastodon", "wrapper"]
|
|||||||
categories = ["web-programming", "http-client"]
|
categories = ["web-programming", "http-client"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
doc-comment = "0.1"
|
||||||
reqwest = "0.8"
|
reqwest = "0.8"
|
||||||
serde = "1"
|
serde = "1"
|
||||||
serde_json = "1"
|
|
||||||
serde_derive = "1"
|
serde_derive = "1"
|
||||||
|
serde_json = "1"
|
||||||
url = "1"
|
url = "1"
|
||||||
|
|
||||||
[dependencies.chrono]
|
[dependencies.chrono]
|
||||||
|
|||||||
+39
-30
@@ -36,6 +36,7 @@
|
|||||||
#![cfg_attr(test, deny(missing_docs))]
|
#![cfg_attr(test, deny(missing_docs))]
|
||||||
|
|
||||||
#[macro_use] extern crate serde_derive;
|
#[macro_use] extern crate serde_derive;
|
||||||
|
#[macro_use] extern crate doc_comment;
|
||||||
#[macro_use] extern crate serde_json as json;
|
#[macro_use] extern crate serde_json as json;
|
||||||
extern crate chrono;
|
extern crate chrono;
|
||||||
extern crate reqwest;
|
extern crate reqwest;
|
||||||
@@ -92,11 +93,11 @@ macro_rules! methods {
|
|||||||
macro_rules! paged_routes {
|
macro_rules! paged_routes {
|
||||||
|
|
||||||
(($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
|
(($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
|
||||||
/// Equivalent to /api/v1/
|
doc_comment! {
|
||||||
#[doc = $url]
|
concat!(
|
||||||
///
|
"Equivalent to `/api/v1/",
|
||||||
#[doc = "# Errors"]
|
$url,
|
||||||
/// If `access_token` is not set.
|
"`\n# Errors\nIf `access_token` is not set."),
|
||||||
pub fn $name(&self) -> Result<Page<$ret>> {
|
pub fn $name(&self) -> Result<Page<$ret>> {
|
||||||
let url = self.route(concat!("/api/v1/", $url));
|
let url = self.route(concat!("/api/v1/", $url));
|
||||||
let response = self.client.$method(&url)
|
let response = self.client.$method(&url)
|
||||||
@@ -106,6 +107,8 @@ macro_rules! paged_routes {
|
|||||||
Page::new(self, response)
|
Page::new(self, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
paged_routes!{$($rest)*}
|
paged_routes!{$($rest)*}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -115,11 +118,11 @@ macro_rules! paged_routes {
|
|||||||
macro_rules! route {
|
macro_rules! route {
|
||||||
|
|
||||||
((post multipart ($($param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
|
((post multipart ($($param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
|
||||||
/// Equivalent to /api/v1/
|
doc_comment! {
|
||||||
#[doc = $url]
|
concat!(
|
||||||
///
|
"Equivalent to `/api/v1/",
|
||||||
#[doc = "# Errors"]
|
$url,
|
||||||
/// If `access_token` is not set.
|
"`\n# Errors\nIf `access_token` is not set."),
|
||||||
pub fn $name(&self, $($param: $typ,)*) -> Result<$ret> {
|
pub fn $name(&self, $($param: $typ,)*) -> Result<$ret> {
|
||||||
use reqwest::multipart::Form;
|
use reqwest::multipart::Form;
|
||||||
|
|
||||||
@@ -143,16 +146,18 @@ macro_rules! route {
|
|||||||
|
|
||||||
deserialise(response)
|
deserialise(response)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
route!{$($rest)*}
|
route!{$($rest)*}
|
||||||
};
|
};
|
||||||
|
|
||||||
(($method:ident ($($param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
|
(($method:ident ($($param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
|
||||||
/// Equivalent to /api/v1/
|
doc_comment! {
|
||||||
#[doc = $url]
|
concat!(
|
||||||
///
|
"Equivalent to `/api/v1/",
|
||||||
#[doc = "# Errors"]
|
$url,
|
||||||
/// If `access_token` is not set.
|
"`\n# Errors\nIf `access_token` is not set."),
|
||||||
|
|
||||||
pub fn $name(&self, $($param: $typ,)*) -> Result<$ret> {
|
pub fn $name(&self, $($param: $typ,)*) -> Result<$ret> {
|
||||||
|
|
||||||
let form_data = json!({
|
let form_data = json!({
|
||||||
@@ -176,19 +181,21 @@ macro_rules! route {
|
|||||||
|
|
||||||
deserialise(response)
|
deserialise(response)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
route!{$($rest)*}
|
route!{$($rest)*}
|
||||||
};
|
};
|
||||||
|
|
||||||
(($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
|
(($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
|
||||||
/// Equivalent to /api/v1/
|
doc_comment! {
|
||||||
#[doc = $url]
|
concat!(
|
||||||
///
|
"Equivalent to `/api/v1/",
|
||||||
#[doc = "# Errors"]
|
$url,
|
||||||
/// If `access_token` is not set.
|
"`\n# Errors\nIf `access_token` is not set."),
|
||||||
pub fn $name(&self) -> Result<$ret> {
|
pub fn $name(&self) -> Result<$ret> {
|
||||||
self.$method(self.route(concat!("/api/v1/", $url)))
|
self.$method(self.route(concat!("/api/v1/", $url)))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
route!{$($rest)*}
|
route!{$($rest)*}
|
||||||
};
|
};
|
||||||
@@ -200,14 +207,15 @@ macro_rules! route_id {
|
|||||||
|
|
||||||
($(($method:ident) $name:ident: $url:expr => $ret:ty,)*) => {
|
($(($method:ident) $name:ident: $url:expr => $ret:ty,)*) => {
|
||||||
$(
|
$(
|
||||||
/// Equivalent to /api/v1/
|
doc_comment! {
|
||||||
#[doc = $url]
|
concat!(
|
||||||
///
|
"Equivalent to `/api/v1/",
|
||||||
#[doc = "# Errors"]
|
$url,
|
||||||
/// If `access_token` is not set.
|
"`\n# Errors\nIf `access_token` is not set."),
|
||||||
pub fn $name(&self, id: u64) -> Result<$ret> {
|
pub fn $name(&self, id: u64) -> Result<$ret> {
|
||||||
self.$method(self.route(&format!(concat!("/api/v1/", $url), id)))
|
self.$method(self.route(&format!(concat!("/api/v1/", $url), id)))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,11 +223,11 @@ macro_rules! route_id {
|
|||||||
macro_rules! paged_routes_with_id {
|
macro_rules! paged_routes_with_id {
|
||||||
|
|
||||||
(($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
|
(($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
|
||||||
/// Equivalent to /api/v1/
|
doc_comment! {
|
||||||
#[doc = $url]
|
concat!(
|
||||||
///
|
"Equivalent to `/api/v1/",
|
||||||
#[doc = "# Errors"]
|
$url,
|
||||||
/// If `access_token` is not set.
|
"`\n# Errors\nIf `access_token` is not set."),
|
||||||
pub fn $name(&self, id: &str) -> Result<Page<$ret>> {
|
pub fn $name(&self, id: &str) -> Result<Page<$ret>> {
|
||||||
let url = self.route(&format!(concat!("/api/v1/", $url), id));
|
let url = self.route(&format!(concat!("/api/v1/", $url), id));
|
||||||
let response = self.client.$method(&url)
|
let response = self.client.$method(&url)
|
||||||
@@ -228,6 +236,7 @@ macro_rules! paged_routes_with_id {
|
|||||||
|
|
||||||
Page::new(self, response)
|
Page::new(self, response)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
route!{$($rest)*}
|
route!{$($rest)*}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user