Added some doc and tests

This commit is contained in:
2020-03-27 18:26:31 +01:00
parent 2e0c16e97c
commit 488ceba1bb
5 changed files with 163 additions and 41 deletions

View File

@@ -1,3 +1,17 @@
#![crate_name = "lang_evolve_core"]
//! # LangEvolveCore
//!
//! `lang_evolve_core` is the core crate used by two other crates:
//! `lang_evolve_cli` and `lang_evolve_gui`.
//!
//! # What it does
//!
//! LangEvolveCore is the crate that hosts all the core logic behind LangEvolve,
//! a conlanging software developped after the
//! [original software](https://github.com/ceronyon/LangEvolve) which applies
//! user-defined sound changes to words and texts based on regex expressions.
use std::fs::File;
use std::io::Result;
use std::path::PathBuf;
@@ -7,13 +21,28 @@ extern crate simplelog;
use log::{info, warn};
use simplelog::*;
#[cfg(test)]
mod tests;
pub mod settings;
use settings::utils;
#[allow(dead_code)]
/// Initializes the crate
///
/// # What it does
///
/// Initializing the crate allows to initialize its logging system. All its logs
/// will be written to the file `core.log` while the errors will also be shown
/// in the terminal.
///
/// # Return type
///
/// This function returns a null object if it succeeds. However, if it does not,
/// it will send a `log::SetLoggerError` back.
///
/// # Example usage
///
/// Its usage is extremely simple, just call it before you do anything with it:
/// ```
/// lang_evolve_core::init();
/// ```
pub fn init() -> std::result::Result<(), log::SetLoggerError> {
match CombinedLogger::init(vec![
TermLogger::new(
@@ -39,6 +68,7 @@ pub fn init() -> std::result::Result<(), log::SetLoggerError> {
}
}
/// Import user input from a text file and return them as a String
pub fn import_input(path: PathBuf) -> Result<String> {
utils::read_file(&path)
}