aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-11-01 13:10:16 -0700
committerZeyla Hellyer <[email protected]>2017-11-01 13:10:16 -0700
commit2c59f87c1408ef633b8749f6688dc42129054a36 (patch)
treeae94858d2a86dd23c0f4ad64c369069909c90050 /src
parentFix no-client cache tests (diff)
downloadserenity-2c59f87c1408ef633b8749f6688dc42129054a36.tar.xz
serenity-2c59f87c1408ef633b8749f6688dc42129054a36.zip
Fix doctests for a variety of feature targets
Diffstat (limited to 'src')
-rw-r--r--src/cache/mod.rs6
-rw-r--r--src/client/context.rs6
-rw-r--r--src/gateway/shard.rs21
-rw-r--r--src/model/error.rs8
4 files changed, 33 insertions, 8 deletions
diff --git a/src/cache/mod.rs b/src/cache/mod.rs
index 357092f..a663a79 100644
--- a/src/cache/mod.rs
+++ b/src/cache/mod.rs
@@ -266,12 +266,14 @@ impl Cache {
/// use serenity::CACHE;
///
/// struct Handler;
+ ///
/// impl EventHandler for Handler {
/// fn on_ready(&self, _: Context, _: Ready) {
- /// println!("Guilds in the Cache: {:?}", CACHE.read().unwrap().all_guilds());
+ /// let guilds = CACHE.read().unwrap().guilds.len();
+ ///
+ /// println!("Guilds in the Cache: {}", guilds);
/// }
/// }
- /// let mut client = Client::new("token", Handler);
/// # }
/// #
/// # #[cfg(not(feature = "client"))]
diff --git a/src/client/context.rs b/src/client/context.rs
index 2288f28..d0a6fc7 100644
--- a/src/client/context.rs
+++ b/src/client/context.rs
@@ -263,6 +263,8 @@ impl Context {
/// playing:
///
/// ```rust,no_run
+ /// # #[cfg(feature = "model")]
+ /// # fn main() {
/// # use serenity::prelude::*;
/// # use serenity::model::*;
/// #
@@ -282,6 +284,10 @@ impl Context {
/// }
///
/// let mut client = Client::new("token", Handler); client.start().unwrap();
+ /// # }
+ /// #
+ /// # #[cfg(not(feature = "model"))]
+ /// # fn main() { }
/// ```
///
/// [`Online`]: ../model/enum.OnlineStatus.html#variant.Online
diff --git a/src/gateway/shard.rs b/src/gateway/shard.rs
index f5888af..bd60b57 100644
--- a/src/gateway/shard.rs
+++ b/src/gateway/shard.rs
@@ -235,6 +235,8 @@ impl Shard {
/// Setting the current game to playing `"Heroes of the Storm"`:
///
/// ```rust,no_run
+ /// # #[cfg(feature = "model")]
+ /// # fn main() {
/// # use serenity::client::gateway::Shard;
/// # use std::sync::{Arc, Mutex};
/// #
@@ -245,6 +247,10 @@ impl Shard {
/// use serenity::model::Game;
///
/// shard.set_game(Some(Game::playing("Heroes of the Storm")));
+ /// # }
+ /// #
+ /// # #[cfg(not(feature = "model"))]
+ /// # fn main() { }
/// ```
pub fn set_game(&mut self, game: Option<Game>) {
self.current_presence.0 = game;
@@ -299,6 +305,8 @@ impl Shard {
/// and not being afk:
///
/// ```rust,no_run
+ /// # #[cfg(feature = "model")]
+ /// # fn main() {
/// # use serenity::client::gateway::Shard;
/// # use std::sync::{Arc, Mutex};
/// #
@@ -308,8 +316,11 @@ impl Shard {
/// #
/// use serenity::model::{Game, OnlineStatus};
///
- /// shard.set_presence(Some(Game::playing("Heroes of the Storm")), OnlineStatus::Online,
- /// false);
+ /// shard.set_presence(Some(Game::playing("Heroes of the Storm")), OnlineStatus::Online, false);
+ /// # }
+ /// #
+ /// # #[cfg(not(feature = "model"))]
+ /// # fn main() { }
/// ```
pub fn set_presence(&mut self, game: Option<Game>, mut status: OnlineStatus, afk: bool) {
if status == OnlineStatus::Offline {
@@ -569,6 +580,8 @@ impl Shard {
/// message handled through [`Client::on_message`].
///
/// ```rust,no_run
+ /// # #[cfg(feature = "model")]
+ /// # fn main() {
/// # use serenity::prelude::*;
/// # use serenity::model::*;
/// struct Handler;
@@ -587,6 +600,10 @@ impl Shard {
/// }
/// }
/// let mut client = Client::new("token", Handler); client.start().unwrap();
+ /// # }
+ /// #
+ /// # #[cfg(not(feature = "model"))]
+ /// # fn main() { }
/// ```
///
/// [`Client`]: ../struct.Client.html
diff --git a/src/model/error.rs b/src/model/error.rs
index 57801da..454b94b 100644
--- a/src/model/error.rs
+++ b/src/model/error.rs
@@ -13,10 +13,10 @@ use super::Permissions;
/// re-ban all members with an odd discriminator:
///
/// ```rust,no_run
-/// # #[cfg(feature="client")]
+/// # #[cfg(all(feature = "client", feature = "model"))]
/// # use std::error::Error;
/// #
-/// # #[cfg(feature="client")]
+/// # #[cfg(all(feature = "client", feature = "model"))]
/// # fn try_main() -> Result<(), Box<Error>> {
/// use serenity::prelude::*;
/// use serenity::model::*;
@@ -51,12 +51,12 @@ use super::Permissions;
/// # Ok(())
/// # }
/// #
-/// # #[cfg(feature="client")]
+/// # #[cfg(all(feature = "client", feature = "model"))]
/// # fn main() {
/// # try_main().unwrap();
/// # }
/// #
-/// # #[cfg(not(feature="client"))]
+/// # #[cfg(not(all(feature="client", feature = "model")))]
/// # fn main() { }
/// ```
///