Function doku::to_toml_fmt_val
source · pub fn to_toml_fmt_val<T>(fmt: &Formatting, val: &T) -> Stringwhere
T: Document + Serialize,
Expand description
Generates a TOML documentation for specified type using custom formatting settings, and extracting example values from given serializable object.
Example
use doku::Document;
use serde::Serialize;
#[derive(Serialize, Document)]
struct Config {
/// Database's host
db_host: String,
}
impl Default for Config {
fn default() -> Self {
Self {
db_host: "localhost".to_string(),
}
}
}
let fmt = doku::toml::Formatting {
layout: doku::toml::Layout::TwoColumns {
align: true,
spacing: 1,
},
..Default::default()
};
let doc = doku::to_toml_fmt_val(&fmt, &Config::default());
doku::assert_doc!(r#"
db_host = "localhost" # Database's host
"#, doc);