From bfebc84abfa93df78e30d0b14e6ad581fbdccb32 Mon Sep 17 00:00:00 2001 From: Justin Duch Date: Tue, 9 Jan 2024 16:07:45 +1100 Subject: [PATCH] fix docs --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/lib.rs | 38 +++++++++--------- src/models/subreddit/mod.rs | 78 ++++++++++++++++++------------------- src/models/user/mod.rs | 28 ++++++------- 5 files changed, 74 insertions(+), 74 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 77db120..a9815fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -674,7 +674,7 @@ dependencies = [ [[package]] name = "roux" -version = "2.2.10" +version = "2.2.11" dependencies = [ "dotenv", "maybe-async", diff --git a/Cargo.toml b/Cargo.toml index ab8a7b3..9b2258a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "roux" -version = "2.2.10" +version = "2.2.11" authors = ["Justin Duch "] edition = "2021" license = "MIT" diff --git a/src/lib.rs b/src/lib.rs index 7560942..1b60809 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,19 +7,19 @@ //! To create an OAuth client with the reddit API, use the `Reddit` class. //! ```no_run //! use roux::Reddit; -//! #[cfg(not(feature = "blocking"))] -//! use tokio; +//! # #[cfg(not(feature = "blocking"))] +//! # use tokio; //! -//! #[cfg_attr(not(feature = "blocking"), tokio::main)] -//! #[maybe_async::maybe_async] -//! async fn main() { +//! # #[cfg_attr(not(feature = "blocking"), tokio::main)] +//! # #[maybe_async::maybe_async] +//! # async fn main() { //! let client = Reddit::new("USER_AGENT", "CLIENT_ID", "CLIENT_SECRET") //! .username("USERNAME") //! .password("PASSWORD") //! .login() //! .await; //! let me = client.unwrap(); -//! } +//! # } //! ``` //! //! It is important that you pick a good user agent. The ideal format is @@ -34,12 +34,12 @@ //! ### Submit A Text Post //! ```no_run //! use roux::Reddit; -//! #[cfg(not(feature = "blocking"))] -//! use tokio; +//! # #[cfg(not(feature = "blocking"))] +//! # use tokio; //! -//! #[cfg_attr(not(feature = "blocking"), tokio::main)] -//! #[maybe_async::maybe_async] -//! async fn main() { +//! # #[cfg_attr(not(feature = "blocking"), tokio::main)] +//! # #[maybe_async::maybe_async] +//! # async fn main() { //! let client = Reddit::new("USER_AGENT", "CLIENT_ID", "CLIENT_SECRET") //! .username("USERNAME") //! .password("PASSWORD") @@ -48,18 +48,18 @@ //! let me = client.unwrap(); //! //! me.submit_text("TEXT_TITLE", "TEXT_BODY", "SUBREDDIT"); -//! } +//! # } //! ``` //! //! ### Submit A Link Post //! ```no_run //! use roux::Reddit; -//! #[cfg(not(feature = "blocking"))] -//! use tokio; +//! # #[cfg(not(feature = "blocking"))] +//! # use tokio; //! -//! #[cfg_attr(not(feature = "blocking"), tokio::main)] -//! #[maybe_async::maybe_async] -//! async fn main() { +//! # #[cfg_attr(not(feature = "blocking"), tokio::main)] +//! # #[maybe_async::maybe_async] +//! # async fn main() { //! let client = Reddit::new("USER_AGENT", "CLIENT_ID", "CLIENT_SECRET") //! .username("USERNAME") //! .password("PASSWORD") @@ -67,8 +67,8 @@ //! .await; //! let me = client.unwrap(); //! -//! me.submit_link("LINK_TITLE", "LINK", "SUBREDDIT"); -//! } +//! # me.submit_link("LINK_TITLE", "LINK", "SUBREDDIT"); +//! # } //! ``` use serde::Deserialize; diff --git a/src/models/subreddit/mod.rs b/src/models/subreddit/mod.rs index d23669a..1df75b2 100644 --- a/src/models/subreddit/mod.rs +++ b/src/models/subreddit/mod.rs @@ -4,35 +4,35 @@ //! # Basic Usage //! ```no_run //! use roux::Subreddit; -//! #[cfg(not(feature = "blocking"))] -//! use tokio; +//! # #[cfg(not(feature = "blocking"))] +//! # use tokio; //! -//! #[cfg_attr(not(feature = "blocking"), tokio::main)] -//! #[maybe_async::maybe_async] -//! async fn main() { -//! let subreddit = Subreddit::new("rust"); -//! // Now you are able to: +//! # #[cfg_attr(not(feature = "blocking"), tokio::main)] +//! # #[maybe_async::maybe_async] +//! # async fn main() { +//! let subreddit = Subreddit::new("rust"); +//! // Now you are able to: //! -//! // Get moderators. -//! let moderators = subreddit.moderators().await; +//! // Get moderators. +//! let moderators = subreddit.moderators().await; //! -//! // Get hot posts with limit = 25. -//! let hot = subreddit.hot(25, None).await; +//! // Get hot posts with limit = 25. +//! let hot = subreddit.hot(25, None).await; //! -//! // Get rising posts with limit = 30. -//! let rising = subreddit.rising(30, None).await; +//! // Get rising posts with limit = 30. +//! let rising = subreddit.rising(30, None).await; //! -//! // Get top posts with limit = 10. -//! let top = subreddit.top(10, None).await; +//! // Get top posts with limit = 10. +//! let top = subreddit.top(10, None).await; //! -//! // Get latest comments. -//! // `depth` and `limit` are optional. -//! let latest_comments = subreddit.latest_comments(None, Some(25)).await; +//! // Get latest comments. +//! // `depth` and `limit` are optional. +//! let latest_comments = subreddit.latest_comments(None, Some(25)).await; //! -//! // Get comments from a submission. -//! let article_id = &hot.unwrap().data.children.first().unwrap().data.id.clone(); -//! let article_comments = subreddit.article_comments(article_id, None, Some(25)); -//! } +//! // Get comments from a submission. +//! let article_id = &hot.unwrap().data.children.first().unwrap().data.id.clone(); +//! let article_comments = subreddit.article_comments(article_id, None, Some(25)); +//! # } //! ``` //! //! # Usage with feed options @@ -40,28 +40,28 @@ //! ```no_run //! use roux::Subreddit; //! use roux::util::{FeedOption, TimePeriod}; -//! #[cfg(not(feature = "blocking"))] -//! use tokio; +//! # #[cfg(not(feature = "blocking"))] +//! # use tokio; //! -//! #[cfg_attr(not(feature = "blocking"), tokio::main)] -//! #[maybe_async::maybe_async] -//! async fn main() { -//! let subreddit = Subreddit::new("astolfo"); +//! # #[cfg_attr(not(feature = "blocking"), tokio::main)] +//! # #[maybe_async::maybe_async] +//! # async fn main() { +//! let subreddit = Subreddit::new("astolfo"); //! -//! // Gets top 10 posts from this month -//! let options = FeedOption::new().period(TimePeriod::ThisMonth); -//! let top = subreddit.top(25, Some(options)).await; +//! // Gets top 10 posts from this month +//! let options = FeedOption::new().period(TimePeriod::ThisMonth); +//! let top = subreddit.top(25, Some(options)).await; //! -//! // Gets hot 10 -//! let hot = subreddit.hot(25, None).await; +//! // Gets hot 10 +//! let hot = subreddit.hot(25, None).await; //! -//! // Get after param from `hot` -//! let after = hot.unwrap().data.after.unwrap(); -//! let after_options = FeedOption::new().after(&after); +//! // Get after param from `hot` +//! let after = hot.unwrap().data.after.unwrap(); +//! let after_options = FeedOption::new().after(&after); //! -//! // Gets next 25 -//! let next_hot = subreddit.hot(25, Some(after_options)).await; -//! } +//! // Gets next 25 +//! let next_hot = subreddit.hot(25, Some(after_options)).await; +//! # } //! ``` pub mod response; extern crate serde_json; diff --git a/src/models/user/mod.rs b/src/models/user/mod.rs index 52eea75..3544424 100644 --- a/src/models/user/mod.rs +++ b/src/models/user/mod.rs @@ -5,24 +5,24 @@ //! ```no_run //! use roux::User; //! use roux::util::FeedOption; -//! #[cfg(not(feature = "blocking"))] -//! use tokio; +//! # #[cfg(not(feature = "blocking"))] +//! # use tokio; //! -//! #[cfg_attr(not(feature = "blocking"), tokio::main)] -//! #[maybe_async::maybe_async] -//! async fn main() { -//! let user = User::new("kasuporo"); -//! // Now you are able to: +//! # #[cfg_attr(not(feature = "blocking"), tokio::main)] +//! # #[maybe_async::maybe_async] +//! # async fn main() { +//! let user = User::new("kasuporo"); +//! // Now you are able to: //! -//! // Get overview -//! let overview = user.overview(None).await; +//! // Get overview +//! let overview = user.overview(None).await; //! -//! // Get submitted posts. -//! let submitted = user.submitted(None).await; +//! // Get submitted posts. +//! let submitted = user.submitted(None).await; //! -//! // Get comments. -//! let comments = user.comments(None).await; -//! } +//! // Get comments. +//! let comments = user.comments(None).await; +//! # } //! ``` extern crate serde_json;