Added and updated documentation and tests
Some undocumented functions and methods are now documented and tested. Some doc tests were modified to become compilable, going from `ignore` to `no_run`, or runable, going from `no_run` to regular tests.
This commit is contained in:
@@ -24,17 +24,17 @@ const RULESET_CURRENT_VERSION: i32 = 1;
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```ignore
|
||||
/// # use lang_evolve_core::settings::*;
|
||||
/// # use lang_evolve_core::encode_settings;
|
||||
/// use std::io::{Error, ErrorKind};
|
||||
/// ```no_run
|
||||
/// use std::path::Path;
|
||||
/// let filetype = utils::get_file_type(Path::new("./path/to/file.json"));
|
||||
/// let s = Settings::new();
|
||||
/// use lang_evolve_core::utils;
|
||||
///
|
||||
/// let settings = Settings::new();
|
||||
/// let filetype = utils::get_file_type(Path::new("settings.yml"));
|
||||
///
|
||||
/// let content = match filetype {
|
||||
/// utils::SettingsType::Yaml => encode_settings!(serde_yaml, &s).unwrap(),
|
||||
/// utils::SettingsType::Json => encode_settings!(serde_json, &s).unwrap(),
|
||||
/// _ => panic!("Could not encode settings"),
|
||||
/// SettingsType::Yaml => encode_settings!(serde_yaml, &settings),
|
||||
/// SettingsType::Json => encode_settings!(serde_json, &settings),
|
||||
/// _ => String::from("Error!"),
|
||||
/// };
|
||||
/// ```
|
||||
///
|
||||
@@ -64,7 +64,7 @@ macro_rules! encode_settings {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```no_run
|
||||
/// # use lang_evolve_core::decode_settings;
|
||||
/// let str = r#"{"version":"1","categories":[],"rules":[]}"#;
|
||||
/// let settings = decode_settings!(serde_json, str);
|
||||
@@ -162,9 +162,15 @@ impl Settings {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```no_run
|
||||
/// ```
|
||||
/// use std::path::Path;
|
||||
/// use lang_evolve_core::settings::Settings;
|
||||
/// # use lang_evolve_core::settings::Settings;
|
||||
/// # let s = Settings::new();
|
||||
/// # for path in vec!["settings.json", "settings.yaml", "settings.yml"] {
|
||||
/// # let path = Path::new(path);
|
||||
/// # s.export(&path).unwrap();
|
||||
/// # }
|
||||
///
|
||||
/// let path_json = Path::new("settings.json");
|
||||
/// let _s_json = Settings::import(&path_json).unwrap();
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user