Skip to content

Commit 8683efe

Browse files
committed
docs: tidy and improve config comments and schema gen
1 parent ee76a26 commit 8683efe

File tree

22 files changed

+202
-70
lines changed

22 files changed

+202
-70
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,5 +199,5 @@ rustix = { version = "1.1.3", default-features = false, features = ["std", "fs",
199199
serde_json = { version = "1.0.148", optional = true } # ipc, niri
200200

201201
# extras
202-
schemars = { version = "1.2.0", optional = true, features = ["indexmap2"] }
202+
schemars = { version = "1.2.0", optional = true, features = ["preserve_order", "indexmap2"] }
203203
clap_complete = { version = "4.5.62", optional = true }

src/config/layout.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use serde::Deserialize;
66
#[cfg_attr(feature = "extras", derive(schemars::JsonSchema))]
77
pub struct LayoutConfig {
88
/// The orientation to display the widget contents.
9-
/// Setting to vertical will rotate text 90 degrees.
109
///
1110
/// **Valid options**: `horizontal`, `vertical`
1211
/// <br>

src/config/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ pub struct Config {
505505

506506
// force type to be included in schema
507507
#[cfg(feature = "extras")]
508-
__common: CommonConfig
508+
__common: CommonConfig,
509509
}
510510

511511
/// Double-click time configuration

src/config/truncate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ impl From<EllipsizeMode> for GtkEllipsizeMode {
3434
#[derive(Debug, Deserialize, Clone, Copy)]
3535
#[serde(untagged)]
3636
#[cfg_attr(feature = "extras", derive(schemars::JsonSchema))]
37+
#[cfg_attr(feature = "extras", schemars(_unstable_ref_variants))] // fix unit variant showing as null
3738
pub enum TruncateMode {
3839
/// Do not truncate content.
3940
///

src/dynamic_value/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![doc = include_str!("../../docs/Dynamic values.md")]
1+
#![doc = include_str!("../../docs/dynamic content/Dynamic values.md")]
22

33
mod dynamic_bool;
44
mod dynamic_string;

src/ironvar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![doc = include_str!("../docs/Ironvars.md")]
1+
#![doc = include_str!("../docs/dynamic content/Ironvars.md")]
22

33
use crate::channels::SyncSenderExt;
44
use crate::{arc_rw, read_lock, write_lock};

src/modules/battery.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,15 @@ const MINUTE: i64 = 60;
2929
#[serde(default)]
3030
pub struct BatteryModule {
3131
/// The format string to use for the widget button label.
32-
/// For available tokens, see [below](#formatting-tokens).
32+
///
33+
/// The following tokens can be used
34+
/// and will be replaced with values from the battery state:
35+
///
36+
/// | Token | Description |
37+
/// |---------------------|------------------------------------------|
38+
/// | `{percentage}` | The battery charge percentage. |
39+
/// | `{state}` | The current battery (dis)charging state. |
40+
/// | `{time_remaining}` | The ETA to battery empty or full. |
3341
///
3442
/// **Default**: `{percentage}%`
3543
format: String,

src/modules/bluetooth/config.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ impl Default for BluetoothModule {
4444
}
4545
}
4646

47+
/// Format strings for each of the bluetooth adapter states.
48+
///
49+
/// The following tokens can be used:
50+
///
51+
/// | Token | Description |
52+
/// |----------------------------|-------------------------------------------------------------------------------------------------------------------------|
53+
/// | `{adapter_status}` | The current adapter status. The mapping of a status to a string could be defined using `adapter_status` config section. |
54+
/// | `{device_alias}` | The device name or address if name is not available. |
55+
/// | `{device_status}` | The current device status. The mapping of a status to a string could be defined using `device_status` config section. |
56+
/// | `{device_battery_percent}` | The device battery percentage. |
57+
/// | `{device_address}` | The device address, e.g `00:11:22:33:FF:EE`. |
58+
4759
#[derive(Debug, Deserialize, Clone)]
4860
#[cfg_attr(feature = "extras", derive(schemars::JsonSchema))]
4961
#[serde(default)]
@@ -90,7 +102,9 @@ impl Default for FormatConfig {
90102
#[cfg_attr(feature = "extras", derive(schemars::JsonSchema))]
91103
#[serde(rename_all = "lowercase")]
92104
pub enum SizeLimit {
105+
/// The maximum number of devices the window can reach before scrolling.
93106
Devices(i32),
107+
/// The maximum number of pixels the window can reach before scrolling.
94108
Pixels(i32),
95109
}
96110

src/modules/cairo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ use tracing::{debug, error};
1919

2020
#[derive(Debug, Clone, Deserialize)]
2121
#[cfg_attr(feature = "extras", derive(schemars::JsonSchema))]
22+
#[cfg_attr(feature = "extras", schemars(extend("required" = ["path"])))]
2223
#[serde(default)]
2324
pub struct CairoModule {
2425
/// The path to the Lua script to load.
2526
/// This can be absolute, or relative to the working directory.
2627
///
2728
/// The script must contain the entry `draw` function.
28-
///
29-
/// **Required**
3029
path: PathBuf,
3130

3231
/// The number of milliseconds between each draw call.
@@ -45,6 +44,7 @@ pub struct CairoModule {
4544
height: u32,
4645

4746
/// See [common options](module-level-options#common-options).
47+
#[serde(flatten)]
4848
pub common: Option<CommonConfig>,
4949
}
5050

0 commit comments

Comments
 (0)