docs: Document environment variables for config options

This commit is contained in:
Erwan Leboucher authored and Jade Ellis committed 2026-10-12 11:32:45 +01:00
1 parent 24e289113b
commit 7da0ef6e2b
4 files changed
+294 -1

No files matched your search

+21
View File
@@ -89,6 +89,8 @@ fn generate_example(input: &ItemStruct, args: &[Meta], write: bool) -> Result<To
}
}
let env_prefix = env_prefix(section);
let mut summary: Vec<TokenStream2> = Vec::new();
let mut nested_displays: Vec<TokenStream2> = Vec::new();
@@ -144,6 +146,12 @@ fn generate_example(input: &ItemStruct, args: &[Meta], write: bool) -> Result<To
file.write_fmt(format_args!("\n{doc}"))
.expect("written to config file");
file.write_fmt(format_args!(
"# env: {env_prefix}{}\n",
ident.to_string().to_uppercase()
))
.expect("written to config file");
file.write_fmt(format_args!("#{ident} ={default}\n"))
.expect("written to config file");
}
@@ -213,6 +221,19 @@ fn generate_example(input: &ItemStruct, args: &[Meta], write: bool) -> Result<To
Ok(display)
}
fn env_prefix(section: &str) -> String {
let nested = section
.strip_prefix("global")
.unwrap_or(section)
.trim_start_matches('.');
if nested.is_empty() {
"CONTINUWUITY_".to_owned()
} else {
format!("CONTINUWUITY_{}__", nested.replace('.', "__").to_uppercase())
}
}
fn get_default(field: &Field) -> Option<String> {
for attr in &field.attrs {
let Meta::List(MetaList { path, tokens, .. }) = &attr.meta else {