Make doctests actually pass

This commit is contained in:
Yash Karandikar 2021-11-04 13:08:01 -05:00
parent 7041e723d5
commit a133c8ab1f
Signed by: karx
GPG key ID: A794DA2529474BA5

View file

@ -1,5 +1,5 @@
//! A simple IRC crate written in rust
//! ```rust
//! ```no_run
//! use circe::*;
//! fn main() -> Result<(), std::io::Error> {
//! let config = Config::from_toml("config.toml")?;
@ -12,7 +12,10 @@
//! print!("{}", line);
//! }
//! }
//! # break;
//! }
//!
//! # Ok(())
//! }
#![warn(missing_docs)]
@ -54,18 +57,22 @@ pub enum Command {
#[doc(hidden)]
CAP(CapMode),
/// Joins a channel
/// ```rust
/// ```no_run
/// # use circe::*;
/// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
/// client.write_command(Command::JOIN("#main".to_string()))?;
/// # Ok::<(), std::io::Error>(())
/// ```
JOIN(
/// Channel
String,
),
/// Sets the mode of the user
/// ```rust
/// ```no_run
/// # use circe::*;
/// client.write_command(Command::MODE("#main".to_string(), Some("+B")))?;
/// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
/// client.write_command(Command::MODE("#main".to_string(), Some("+B".to_string())))?;
/// # Ok::<(), std::io::Error>(())
/// ```
/// If the MODE is not given (e.g. None), then the client will send "MODE target"
MODE(
@ -86,9 +93,11 @@ pub enum Command {
#[doc(hidden)]
PONG(String),
/// Sends a message in a channel
/// ```rust
/// ```no_run
/// # use circe::*;
/// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
/// client.write_command(Command::PRIVMSG("#main".to_string(), "This is an example message".to_string()))?;
/// # Ok::<(), std::io::Error>(())
/// ```
PRIVMSG(
/// Channel
@ -115,9 +124,11 @@ impl Command {
impl Client {
/// Creates a new client with a given config
/// ```rust
/// ```no_run
/// # use circe::*;
/// # let config = Config::from_toml("config.toml")?;
/// let mut client = Client::new(config)?;
/// # Ok::<(), std::io::Error>(())
/// ```
///
/// Errors if the client could not connect to the given host.
@ -127,9 +138,11 @@ impl Client {
}
/// Identify user and join the specified channels
/// ```rust
/// ```no_run
/// # use circe::*;
/// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
/// client.identify()?;
/// # Ok::<(), std::io::Error>(())
/// ```
///
/// Errors if the client could not write to the stream.
@ -183,16 +196,17 @@ impl Client {
}
/// Read data coming from the IRC as a [`Command`]
/// ```rust
/// ```no_run
/// # use circe::*;
/// # fn main() -> Result<(), std::io::Error> {
/// # let config = Config::from_toml("config.toml");
/// # let client = Client::new(config)?;
/// # let config = Config::from_toml("config.toml")?;
/// # let mut client = Client::new(config)?;
/// if let Ok(ref command) = client.read() {
/// if let Command::OTHER(line) = command {
/// print!("{}", line);
/// }
/// }
/// # Ok::<(), std::io::Error>(())
/// # }
/// ```
///
@ -217,9 +231,11 @@ impl Client {
}
/// Send a [`Command`] to the IRC
/// ```rust
/// ```no_run
/// # use circe::*;
/// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
/// client.write_command(Command::PRIVMSG("#main".to_string(), "Hello".to_string()))?;
/// # Ok::<(), std::io::Error>(())
/// ```
///
/// Errors if the stream could not write.
@ -320,9 +336,10 @@ impl Config {
}
/// Create a config from a toml file
/// ```rust
/// ```no_run
/// # use circe::*;
/// let config = Config::from_toml("config.toml")?;
/// # Ok::<(), std::io::Error>(())
/// ```
///
/// ```toml