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