Skip to content

Commit

Permalink
Config documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
o0Ignition0o committed Dec 21, 2019
1 parent f193542 commit 90fa141
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions cargo-scout-lib/src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,78 @@
pub mod rust;

/// This trait is responsible for providing a list of members,
/// which are directories to be linted against.
pub trait Config {
/// This function should return a list of relative paths
/// a linter will iterate on.
///
/// If only the current working directory must be checked, it must return `vec![".".to_string()]`
///
/// If several directories must be checked,
/// return their relative path as strings.
///
/// For example if your current working directory is `foo`,
/// and you want to check `./bar` and `./baz`,
/// return `vec!["bar".to_string(), "baz".to_string()]`
///
/// # Example with the root directory
/// ```
/// # use cargo_scout_lib::config::Config;
/// # struct CustomConfig{}
/// # impl CustomConfig {
/// # fn new() -> Self {
/// # Self {}
/// # }
/// # }
/// # // Your own implementation goes here
/// # impl Config for CustomConfig {
/// # fn get_members(&self) -> Vec<String> {
/// # vec![".".to_string()]
/// # }
/// # }
/// let config = CustomConfig::new();
/// // Only the current directory must be linted
/// assert_eq!(vec![".".to_string()], config.get_members());
/// ```
///
/// # Example with two subdirectories
/// ```
/// # use cargo_scout_lib::config::Config;
/// # struct CustomConfig{}
/// # impl CustomConfig {
/// # fn new() -> Self {
/// # Self {}
/// # }
/// # }
/// # // Your own implementation goes here
/// # impl Config for CustomConfig {
/// # fn get_members(&self) -> Vec<String> {
/// # vec!["foo".to_string(), "bar".to_string()]
/// # }
/// # }
/// let config = CustomConfig::new();
/// // Directories ./foo and ./bar must be linted
/// assert_eq!(vec!["foo".to_string(), "bar".to_string()], config.get_members());
/// ```
///
/// # Implementing your own Config
/// ```
/// use cargo_scout_lib::config::Config;
///
/// struct CustomConfig{}
///
/// # impl CustomConfig {
/// # fn new() -> Self {
/// # Self {}
/// # }
/// # }
/// impl Config for CustomConfig {
/// fn get_members(&self) -> Vec<String> {
/// // Your own code to fetch the list of
/// // directories to iterate on goes here
/// # vec![".".to_string()]
/// }
/// }
/// ```
fn get_members(&self) -> Vec<String>;
}

0 comments on commit 90fa141

Please sign in to comment.