mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-02 11:11:04 +02:00
feat(config): json schema support
This PR includes the necessary code changes, CI changes and documentation to generate and deploy a full JSON schema for each release and the master branch, which can be used within config files for autocomplete and type checking.
This commit is contained in:
parent
a47ef0c763
commit
36d724f148
36 changed files with 230 additions and 15 deletions
|
@ -16,6 +16,7 @@ use tracing::trace;
|
|||
/// see [here](script).
|
||||
/// For information on styling, please see the [styling guide](styling-guide).
|
||||
#[derive(Debug, Default, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct CommonConfig {
|
||||
/// Sets the unique widget name,
|
||||
/// allowing you to target it in CSS using `#name`.
|
||||
|
@ -160,6 +161,7 @@ pub struct CommonConfig {
|
|||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum TransitionType {
|
||||
None,
|
||||
Crossfade,
|
||||
|
@ -169,6 +171,7 @@ pub enum TransitionType {
|
|||
|
||||
#[derive(Debug, Default, Deserialize, Clone, Copy)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum ModuleOrientation {
|
||||
#[default]
|
||||
#[serde(alias = "h")]
|
||||
|
|
|
@ -36,11 +36,15 @@ use color_eyre::Result;
|
|||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[cfg(feature = "schema")]
|
||||
use schemars::JsonSchema;
|
||||
|
||||
pub use self::common::{CommonConfig, ModuleOrientation, TransitionType};
|
||||
pub use self::truncate::TruncateMode;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
pub enum ModuleConfig {
|
||||
#[cfg(feature = "cairo")]
|
||||
Cairo(Box<CairoModule>),
|
||||
|
@ -117,6 +121,7 @@ impl ModuleConfig {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
pub enum MonitorConfig {
|
||||
Single(BarConfig),
|
||||
Multiple(Vec<BarConfig>),
|
||||
|
@ -124,6 +129,7 @@ pub enum MonitorConfig {
|
|||
|
||||
#[derive(Debug, Deserialize, Copy, Clone, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
pub enum BarPosition {
|
||||
Top,
|
||||
Bottom,
|
||||
|
@ -138,6 +144,7 @@ impl Default for BarPosition {
|
|||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize, Copy, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
pub struct MarginConfig {
|
||||
#[serde(default)]
|
||||
pub bottom: i32,
|
||||
|
@ -156,6 +163,7 @@ pub struct MarginConfig {
|
|||
/// depending on your [use-case](#2-pick-your-use-case).
|
||||
///
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
pub struct BarConfig {
|
||||
/// A unique identifier for the bar, used for controlling it over IPC.
|
||||
/// If not set, uses a generated integer suffix.
|
||||
|
@ -292,6 +300,7 @@ impl Default for BarConfig {
|
|||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone, Default)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
pub struct Config {
|
||||
/// A map of [ironvar](ironvar) keys and values
|
||||
/// to initialize Ironbar with on startup.
|
||||
|
|
|
@ -4,6 +4,7 @@ use serde::Deserialize;
|
|||
|
||||
#[derive(Debug, Deserialize, Clone, Copy)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum EllipsizeMode {
|
||||
Start,
|
||||
Middle,
|
||||
|
@ -28,6 +29,7 @@ impl From<EllipsizeMode> for GtkEllipsizeMode {
|
|||
///
|
||||
#[derive(Debug, Deserialize, Clone, Copy)]
|
||||
#[serde(untagged)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum TruncateMode {
|
||||
/// Auto mode lets GTK decide when to ellipsize.
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue