Skip to content

Commit

Permalink
chore: add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rubik committed Sep 13, 2020
1 parent cdb5b57 commit 2005b89
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/lib.rs
@@ -1,3 +1,34 @@
//! The parser handles comments, strings and the `export` syntax automatically.
//!
//! # Example
//! ```
//! use dotenv_parser::parse_dotenv;
//!
//! fn main() {
//! let source = r#"
//! ## main comment
//! ENV_FOR_HYDRO='testing 2' # another one here
//! export USER_ID=5gpPN5rcv5G41U_S
//! API_TOKEN=30af563ccc668bc8ced9e24e # relax! these values are fake
//! APP_SITE_URL=https://my.example.com
//! "#;
//!
//! let map = vec![
//! ("ENV_FOR_HYDRO", "testing 2"),
//! ("USER_ID", "5gpPN5rcv5G41U_S"),
//! ("API_TOKEN", "30af563ccc668bc8ced9e24e"),
//! ("APP_SITE_URL", "https://my.example.com"),
//! ]
//! .into_iter()
//! .map(|(a, b)| (a.into(), b.into()))
//! .collect();
//!
//! let res = parse_dotenv(source).unwrap();
//! assert_eq!(res, map);
//! }

#![deny(missing_docs)]

extern crate pest;
#[macro_use]
extern crate pest_derive;
Expand Down
2 changes: 2 additions & 0 deletions src/parser.rs
Expand Up @@ -153,6 +153,8 @@ mod tests {
#[test]
fn complete_dotenv() {
let source = r#"
# main comment
ENV_FOR_HYDRO='testing 2' # another one here
export USER_ID=5gpPN5rcv5G41U_S
API_TOKEN=30af563ccc668bc8ced9e24e # relax! these values are fake
Expand Down

0 comments on commit 2005b89

Please sign in to comment.