doc: fix doc tests
This commit is contained in:
parent
c460f11dce
commit
e6b7121508
2 changed files with 18 additions and 43 deletions
59
src/lib.rs
59
src/lib.rs
|
@ -3,23 +3,23 @@
|
||||||
//! Simple configuration with macro for rust application.
|
//! Simple configuration with macro for rust application.
|
||||||
//!
|
//!
|
||||||
//!
|
//!
|
||||||
//!
|
|
||||||
//! ## Example usage
|
//! ## Example usage
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```rust
|
||||||
//! #[macro_use] extern crate itconfig;
|
//! #[macro_use] extern crate itconfig;
|
||||||
//! use dotenv::dotenv;
|
//! // use dotenv::dotenv;
|
||||||
//!
|
//!
|
||||||
//! config! {
|
//! config! {
|
||||||
//! DATABASE_URL: bool,
|
//! DEBUG: bool => true,
|
||||||
//! HOST: String => "127.0.0.1",
|
//! HOST: String => "127.0.0.1".to_string(),
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! fn main () {
|
//! fn main () {
|
||||||
//! dotenv().ok();
|
//! // dotenv().ok();
|
||||||
//! cfg::init();
|
//! cfg::init();
|
||||||
//! assert_eq(cfg::HOST(), String::from("127.0.0.1");
|
//! assert_eq!(cfg::HOST(), String::from("127.0.0.1"));
|
||||||
//! }
|
//! }
|
||||||
|
//! ```
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
macro_rules! __impl_from_for_numbers {
|
macro_rules! __impl_from_for_numbers {
|
||||||
|
@ -86,16 +86,10 @@ impl From<EnvValue> for String {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # #[macro_use] extern crate itconfig;
|
/// # #[macro_use] extern crate itconfig;
|
||||||
/// config! {
|
/// config! {
|
||||||
/// DATABASE_URL: bool,
|
/// DATABASE_URL: String,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// # fn main () {
|
/// # fn main () {}
|
||||||
/// # use std::env;
|
|
||||||
/// # env::set_var("DATABASE_URL", "sqlite://");
|
|
||||||
/// #
|
|
||||||
/// # cfg::init();
|
|
||||||
/// # assert_eq(cfg::DATABASE_URL(), true);
|
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Config with default value
|
/// Config with default value
|
||||||
|
@ -103,14 +97,11 @@ impl From<EnvValue> for String {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # #[macro_use] extern crate itconfig;
|
/// # #[macro_use] extern crate itconfig;
|
||||||
/// config! {
|
/// config! {
|
||||||
/// DATABASE_URL: bool,
|
/// DATABASE_URL: String,
|
||||||
/// HOST: String => "127.0.0.1",
|
/// HOST: String => "127.0.0.1".to_string(),
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// # fn main () {
|
/// # fn main () {}
|
||||||
/// # cfg::init();
|
|
||||||
/// # assert_eq(cfg::HOST(), String::from("127.0.0.1");
|
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// This module will also contain helper method:
|
/// This module will also contain helper method:
|
||||||
|
@ -123,33 +114,17 @@ impl From<EnvValue> for String {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #[macro_use] extern crate itconfig;
|
/// #[macro_use] extern crate itconfig;
|
||||||
|
/// // use dotenv::dotenv;
|
||||||
///
|
///
|
||||||
/// config! {
|
/// config! {
|
||||||
/// DATABASE_URL: bool,
|
/// DEBUG: bool => true,
|
||||||
/// HOST: String => "127.0.0.1",
|
/// HOST: String => "127.0.0.1".to_string(),
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// fn main () {
|
/// fn main () {
|
||||||
|
/// // dotenv().ok();
|
||||||
/// cfg::init();
|
/// cfg::init();
|
||||||
/// assert_eq(cfg::HOST(), String::from("127.0.0.1");
|
/// assert_eq!(cfg::HOST(), String::from("127.0.0.1"));
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// Also dotenv module is supported
|
|
||||||
///
|
|
||||||
/// ```rust
|
|
||||||
/// #[macro_use] extern crate itconfig;
|
|
||||||
/// use dotenv::dotenv;
|
|
||||||
///
|
|
||||||
/// config! {
|
|
||||||
/// DATABASE_URL: bool,
|
|
||||||
/// HOST: String => "127.0.0.1",
|
|
||||||
/// }
|
|
||||||
///
|
|
||||||
/// fn main () {
|
|
||||||
/// dotenv().ok();
|
|
||||||
/// cfg::init();
|
|
||||||
/// assert_eq(cfg::HOST(), String::from("127.0.0.1");
|
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate it_config;
|
extern crate itconfig;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn one_variable() {
|
fn one_variable() {
|
||||||
|
|
Reference in a new issue