mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 23:01: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
|
@ -6,6 +6,7 @@ use gtk::prelude::*;
|
|||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct BoxWidget {
|
||||
/// Widget name.
|
||||
///
|
||||
|
|
|
@ -10,6 +10,7 @@ use crate::{build, try_send};
|
|||
use super::{CustomWidget, CustomWidgetContext, ExecEvent, WidgetConfig};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct ButtonWidget {
|
||||
/// Widget name.
|
||||
///
|
||||
|
|
|
@ -9,6 +9,7 @@ use crate::image::ImageProvider;
|
|||
use super::{CustomWidget, CustomWidgetContext};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct ImageWidget {
|
||||
/// Widget name.
|
||||
///
|
||||
|
|
|
@ -9,6 +9,7 @@ use crate::dynamic_value::dynamic_string;
|
|||
use super::{CustomWidget, CustomWidgetContext};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct LabelWidget {
|
||||
/// Widget name.
|
||||
///
|
||||
|
|
|
@ -28,6 +28,7 @@ use tokio::sync::{broadcast, mpsc};
|
|||
use tracing::{debug, error};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct CustomModule {
|
||||
/// Modules and widgets to add to the bar container.
|
||||
///
|
||||
|
@ -45,6 +46,7 @@ pub struct CustomModule {
|
|||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct WidgetConfig {
|
||||
/// One of a custom module native Ironbar module.
|
||||
#[serde(flatten)]
|
||||
|
@ -57,6 +59,7 @@ pub struct WidgetConfig {
|
|||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(untagged)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum WidgetOrModule {
|
||||
/// A custom-module specific basic widget
|
||||
Widget(Widget),
|
||||
|
@ -67,6 +70,7 @@ pub enum WidgetOrModule {
|
|||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum Widget {
|
||||
/// A container to place nested widgets inside.
|
||||
Box(BoxWidget),
|
||||
|
|
|
@ -13,6 +13,7 @@ use crate::{build, glib_recv_mpsc, spawn, try_send};
|
|||
use super::{CustomWidget, CustomWidgetContext};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct ProgressWidget {
|
||||
/// Widget name.
|
||||
///
|
||||
|
|
|
@ -16,6 +16,7 @@ use crate::{build, glib_recv_mpsc, spawn, try_send};
|
|||
use super::{CustomWidget, CustomWidgetContext, ExecEvent};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct SliderWidget {
|
||||
/// Widget name.
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue