Add doc warning about the crate feature

This commit is contained in:
Yash Karandikar 2021-12-06 11:46:00 -06:00
parent 535718afba
commit 0415684558
2 changed files with 13 additions and 5 deletions

View file

@ -32,3 +32,7 @@ default = ["tls"]
tls = ["native-tls"]
debug = []
toml_support = ["toml", "serde", "serde_derive"]
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

View file

@ -22,17 +22,21 @@
#![warn(missing_docs)]
#![allow(clippy::too_many_lines)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#[cfg(feature = "tls")]
use native_tls::TlsConnector;
use std::borrow::Cow;
use std::fs::File;
use std::io::{Error, Read, Write};
use std::net::TcpStream;
use std::path::Path;
#[cfg(feature = "toml_support")]
use serde_derive::Deserialize;
#[cfg(feature = "toml_support")]
use std::fs::File;
#[cfg(feature = "toml_support")]
use std::path::Path;
/// IRC comamnds
pub mod commands;
@ -47,7 +51,8 @@ pub struct Client {
}
/// Config for the IRC client
#[derive(Clone, Deserialize, Default)]
#[derive(Clone, Default)]
#[cfg_attr(feature = "toml_support", derive(Deserialize))]
pub struct Config {
channels: Vec<String>,
host: String,
@ -620,8 +625,6 @@ impl Config {
}
}
/// _This feature requires the `toml_support` feature to be enabled._
///
/// Create a config from a toml file
/// ```toml
/// channels = ["#main", "#main2"]
@ -634,6 +637,7 @@ impl Config {
/// # Errors
/// Returns an Error if the file cannot be opened or if the TOML is invalid
///
#[cfg_attr(docsrs, doc(cfg(feature = "toml_support")))]
#[cfg(feature = "toml_support")]
pub fn from_toml<P: AsRef<Path>>(path: P) -> Result<Self, Error> {
let mut file = File::open(&path)?;