Added doc_comment to properly doc functions

master
Aaron Power 6 years ago
parent 142d8e7572
commit 87a0c103e6
  1. 3
      Cargo.toml
  2. 69
      src/lib.rs

@ -11,10 +11,11 @@ keywords = ["api", "web", "social", "mastodon", "wrapper"]
categories = ["web-programming", "http-client"]
[dependencies]
doc-comment = "0.1"
reqwest = "0.8"
serde = "1"
serde_json = "1"
serde_derive = "1"
serde_json = "1"
url = "1"
[dependencies.chrono]

@ -36,6 +36,7 @@
#![cfg_attr(test, deny(missing_docs))]
#[macro_use] extern crate serde_derive;
#[macro_use] extern crate doc_comment;
#[macro_use] extern crate serde_json as json;
extern crate chrono;
extern crate reqwest;
@ -92,11 +93,11 @@ macro_rules! methods {
macro_rules! paged_routes {
(($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
/// Equivalent to /api/v1/
#[doc = $url]
///
#[doc = "# Errors"]
/// If `access_token` is not set.
doc_comment! {
concat!(
"Equivalent to `/api/v1/",
$url,
"`\n# Errors\nIf `access_token` is not set."),
pub fn $name(&self) -> Result<Page<$ret>> {
let url = self.route(concat!("/api/v1/", $url));
let response = self.client.$method(&url)
@ -106,6 +107,8 @@ macro_rules! paged_routes {
Page::new(self, response)
}
}
paged_routes!{$($rest)*}
};
@ -115,11 +118,11 @@ macro_rules! paged_routes {
macro_rules! route {
((post multipart ($($param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
/// Equivalent to /api/v1/
#[doc = $url]
///
#[doc = "# Errors"]
/// If `access_token` is not set.
doc_comment! {
concat!(
"Equivalent to `/api/v1/",
$url,
"`\n# Errors\nIf `access_token` is not set."),
pub fn $name(&self, $($param: $typ,)*) -> Result<$ret> {
use reqwest::multipart::Form;
@ -143,16 +146,18 @@ macro_rules! route {
deserialise(response)
}
}
route!{$($rest)*}
};
(($method:ident ($($param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
/// Equivalent to /api/v1/
#[doc = $url]
///
#[doc = "# Errors"]
/// If `access_token` is not set.
doc_comment! {
concat!(
"Equivalent to `/api/v1/",
$url,
"`\n# Errors\nIf `access_token` is not set."),
pub fn $name(&self, $($param: $typ,)*) -> Result<$ret> {
let form_data = json!({
@ -176,19 +181,21 @@ macro_rules! route {
deserialise(response)
}
}
route!{$($rest)*}
};
(($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
/// Equivalent to /api/v1/
#[doc = $url]
///
#[doc = "# Errors"]
/// If `access_token` is not set.
doc_comment! {
concat!(
"Equivalent to `/api/v1/",
$url,
"`\n# Errors\nIf `access_token` is not set."),
pub fn $name(&self) -> Result<$ret> {
self.$method(self.route(concat!("/api/v1/", $url)))
}
}
route!{$($rest)*}
};
@ -200,14 +207,15 @@ macro_rules! route_id {
($(($method:ident) $name:ident: $url:expr => $ret:ty,)*) => {
$(
/// Equivalent to /api/v1/
#[doc = $url]
///
#[doc = "# Errors"]
/// If `access_token` is not set.
doc_comment! {
concat!(
"Equivalent to `/api/v1/",
$url,
"`\n# Errors\nIf `access_token` is not set."),
pub fn $name(&self, id: u64) -> Result<$ret> {
self.$method(self.route(&format!(concat!("/api/v1/", $url), id)))
}
}
)*
}
@ -215,11 +223,11 @@ macro_rules! route_id {
macro_rules! paged_routes_with_id {
(($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
/// Equivalent to /api/v1/
#[doc = $url]
///
#[doc = "# Errors"]
/// If `access_token` is not set.
doc_comment! {
concat!(
"Equivalent to `/api/v1/",
$url,
"`\n# Errors\nIf `access_token` is not set."),
pub fn $name(&self, id: &str) -> Result<Page<$ret>> {
let url = self.route(&format!(concat!("/api/v1/", $url), id));
let response = self.client.$method(&url)
@ -228,6 +236,7 @@ macro_rules! paged_routes_with_id {
Page::new(self, response)
}
}
route!{$($rest)*}
};

Loading…
Cancel
Save