mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-13 12:16:54 +00:00
docs: Document environment variables for config options
This commit is contained in:
1 parent
24e289113b
commit
7da0ef6e2b
4 files changed
+294
-1
No files matched your search
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user