docs(config): encode defaults of unwrapped options into schema

This commit ensures that the various default values that the different
Option<T> config properties can be unwrapped to are encoded by schemars
so that they can be picked up by docgen.
This commit is contained in:
LGUG2Z
2025-12-26 18:16:55 -08:00
parent 66c5766848
commit a42e809ade
13 changed files with 709 additions and 396 deletions
+9 -2
View File
@@ -14,12 +14,17 @@ use std::process::Command;
use std::time::Duration;
use std::time::Instant;
mod defaults {
pub const DATA_REFRESH_INTERVAL: u64 = 12;
}
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct UpdateConfig {
/// Enable the Update widget
pub enable: bool,
/// Data refresh interval (default: 12 hours)
/// Data refresh interval in hours
#[cfg_attr(feature = "schemars", schemars(extend("default" = defaults::DATA_REFRESH_INTERVAL)))]
pub data_refresh_interval: Option<u64>,
/// Display label prefix
pub label_prefix: Option<LabelPrefix>,
@@ -27,7 +32,9 @@ pub struct UpdateConfig {
impl From<UpdateConfig> for Update {
fn from(value: UpdateConfig) -> Self {
let data_refresh_interval = value.data_refresh_interval.unwrap_or(12);
let data_refresh_interval = value
.data_refresh_interval
.unwrap_or(defaults::DATA_REFRESH_INTERVAL);
let mut latest_version = String::new();