Skip to content

Commit 2c59f87

Browse files
author
Zeyla Hellyer
committed
Fix doctests for a variety of feature targets
1 parent ccbc3b3 commit 2c59f87

File tree

6 files changed

+36
-9
lines changed

6 files changed

+36
-9
lines changed

src/cache/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,14 @@ impl Cache {
266266
/// use serenity::CACHE;
267267
///
268268
/// struct Handler;
269+
///
269270
/// impl EventHandler for Handler {
270271
/// fn on_ready(&self, _: Context, _: Ready) {
271-
/// println!("Guilds in the Cache: {:?}", CACHE.read().unwrap().all_guilds());
272+
/// let guilds = CACHE.read().unwrap().guilds.len();
273+
///
274+
/// println!("Guilds in the Cache: {}", guilds);
272275
/// }
273276
/// }
274-
/// let mut client = Client::new("token", Handler);
275277
/// # }
276278
/// #
277279
/// # #[cfg(not(feature = "client"))]

src/client/context.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ impl Context {
263263
/// playing:
264264
///
265265
/// ```rust,no_run
266+
/// # #[cfg(feature = "model")]
267+
/// # fn main() {
266268
/// # use serenity::prelude::*;
267269
/// # use serenity::model::*;
268270
/// #
@@ -282,6 +284,10 @@ impl Context {
282284
/// }
283285
///
284286
/// let mut client = Client::new("token", Handler); client.start().unwrap();
287+
/// # }
288+
/// #
289+
/// # #[cfg(not(feature = "model"))]
290+
/// # fn main() { }
285291
/// ```
286292
///
287293
/// [`Online`]: ../model/enum.OnlineStatus.html#variant.Online

src/gateway/shard.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ impl Shard {
235235
/// Setting the current game to playing `"Heroes of the Storm"`:
236236
///
237237
/// ```rust,no_run
238+
/// # #[cfg(feature = "model")]
239+
/// # fn main() {
238240
/// # use serenity::client::gateway::Shard;
239241
/// # use std::sync::{Arc, Mutex};
240242
/// #
@@ -245,6 +247,10 @@ impl Shard {
245247
/// use serenity::model::Game;
246248
///
247249
/// shard.set_game(Some(Game::playing("Heroes of the Storm")));
250+
/// # }
251+
/// #
252+
/// # #[cfg(not(feature = "model"))]
253+
/// # fn main() { }
248254
/// ```
249255
pub fn set_game(&mut self, game: Option<Game>) {
250256
self.current_presence.0 = game;
@@ -299,6 +305,8 @@ impl Shard {
299305
/// and not being afk:
300306
///
301307
/// ```rust,no_run
308+
/// # #[cfg(feature = "model")]
309+
/// # fn main() {
302310
/// # use serenity::client::gateway::Shard;
303311
/// # use std::sync::{Arc, Mutex};
304312
/// #
@@ -308,8 +316,11 @@ impl Shard {
308316
/// #
309317
/// use serenity::model::{Game, OnlineStatus};
310318
///
311-
/// shard.set_presence(Some(Game::playing("Heroes of the Storm")), OnlineStatus::Online,
312-
/// false);
319+
/// shard.set_presence(Some(Game::playing("Heroes of the Storm")), OnlineStatus::Online, false);
320+
/// # }
321+
/// #
322+
/// # #[cfg(not(feature = "model"))]
323+
/// # fn main() { }
313324
/// ```
314325
pub fn set_presence(&mut self, game: Option<Game>, mut status: OnlineStatus, afk: bool) {
315326
if status == OnlineStatus::Offline {
@@ -569,6 +580,8 @@ impl Shard {
569580
/// message handled through [`Client::on_message`].
570581
///
571582
/// ```rust,no_run
583+
/// # #[cfg(feature = "model")]
584+
/// # fn main() {
572585
/// # use serenity::prelude::*;
573586
/// # use serenity::model::*;
574587
/// struct Handler;
@@ -587,6 +600,10 @@ impl Shard {
587600
/// }
588601
/// }
589602
/// let mut client = Client::new("token", Handler); client.start().unwrap();
603+
/// # }
604+
/// #
605+
/// # #[cfg(not(feature = "model"))]
606+
/// # fn main() { }
590607
/// ```
591608
///
592609
/// [`Client`]: ../struct.Client.html

src/model/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ use super::Permissions;
1313
/// re-ban all members with an odd discriminator:
1414
///
1515
/// ```rust,no_run
16-
/// # #[cfg(feature="client")]
16+
/// # #[cfg(all(feature = "client", feature = "model"))]
1717
/// # use std::error::Error;
1818
/// #
19-
/// # #[cfg(feature="client")]
19+
/// # #[cfg(all(feature = "client", feature = "model"))]
2020
/// # fn try_main() -> Result<(), Box<Error>> {
2121
/// use serenity::prelude::*;
2222
/// use serenity::model::*;
@@ -51,12 +51,12 @@ use super::Permissions;
5151
/// # Ok(())
5252
/// # }
5353
/// #
54-
/// # #[cfg(feature="client")]
54+
/// # #[cfg(all(feature = "client", feature = "model"))]
5555
/// # fn main() {
5656
/// # try_main().unwrap();
5757
/// # }
5858
/// #
59-
/// # #[cfg(not(feature="client"))]
59+
/// # #[cfg(not(all(feature="client", feature = "model")))]
6060
/// # fn main() { }
6161
/// ```
6262
///

tests/test_channels.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(feature = "model")]
2+
13
extern crate serenity;
24

35
#[cfg(feature = "utils")]

tests/test_create_embed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![cfg_attr(feature = "cargo-clippy", allow(unreadable_literal))]
2-
#![cfg(feature = "utils")]
2+
#![cfg(all(feature = "builder", feature = "utils"))]
33

44
#[macro_use]
55
extern crate serde_json;

0 commit comments

Comments
 (0)