Crates.io | sample-config |
lib.rs | sample-config |
version | 0.2.0 |
source | src |
created_at | 2022-11-06 14:09:27.773553 |
updated_at | 2023-01-07 14:45:10.64442 |
description | Generation of sample configs with documentation comments. |
homepage | https://github.com/FlixCoder/sample-config |
repository | https://github.com/FlixCoder/sample-config |
max_upload_size | |
id | 706547 |
size | 22,594 |
Automatic generation of sample configs with documentation comments. Just derive the SampleConfig
trait on your config types, create an example object and generate a configuration file using that.
Example:
use sample_config::SampleConfig;
/// Example enum.
#[derive(Debug, Default, SampleConfig)]
enum ExampleEnum {
/// A.
#[default]
VariantA,
}
/// General documentation isn't used.
#[derive(Debug, Default, SampleConfig)]
struct ExampleConfig {
/// Some optional string.
string: Option<String>,
/// Some list of numbers.
numbers: Vec<usize>,
/// Enumeration of values.
value: ExampleEnum,
}
let instance = ExampleConfig::default();
let yaml_file_string = instance.generate_sample_yaml();
std::fs::write("output.yaml", &yaml_file_string).unwrap();
std::fs::remove_file("output.yaml").unwrap()
Please take a look at the tests to see more complicated examples.
This projects uses a bunch of clippy lints for higher code quality and style.
Install cargo-lints
using cargo install --git https://github.com/FlixCoder/cargo-lints
. The lints are defined in lints.toml
and can be checked by running cargo lints clippy --all-targets --workspace
.