From 0b0715fd505200db5954432b8a27ed57e3e6a72a Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Thu, 26 May 2022 15:00:34 +0200 Subject: [PATCH] Fix some types missing in widget docs --- Cargo.lock | 2 +- crates/eww/src/widgets/widget_definitions.rs | 20 ++++++++++---------- gen-docs.ts | 7 +++---- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ae7ab9..c810728 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -403,7 +403,7 @@ dependencies = [ [[package]] name = "eww" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "bincode", diff --git a/crates/eww/src/widgets/widget_definitions.rs b/crates/eww/src/widgets/widget_definitions.rs index 98444ed..f9a08da 100644 --- a/crates/eww/src/widgets/widget_definitions.rs +++ b/crates/eww/src/widgets/widget_definitions.rs @@ -452,14 +452,14 @@ fn build_gtk_button(bargs: &mut BuilderArgs) -> Result { let gtk_widget = gtk::Button::new(); def_widget!(bargs, _g, gtk_widget, { - // @prop onclick - a command that get's run when the button is clicked - // @prop onmiddleclick - a command that get's run when the button is middleclicked - // @prop onrightclick - a command that get's run when the button is rightclicked - // @prop timeout - timeout of the command prop( + // @prop timeout - timeout of the command timeout: as_duration = Duration::from_millis(200), + // @prop onclick - a command that get's run when the button is clicked onclick: as_string = "", + // @prop onmiddleclick - a command that get's run when the button is middleclicked onmiddleclick: as_string = "", + // @prop onrightclick - a command that get's run when the button is rightclicked onrightclick: as_string = "" ) { gtk_widget.add_events(gdk::EventMask::BUTTON_PRESS_MASK); @@ -705,7 +705,7 @@ fn build_gtk_event_box(bargs: &mut BuilderArgs) -> Result { })); }, // @prop timeout - timeout of the command - // @prop on_dropped - Command to execute when something is dropped on top of this element. The placeholder `{}` used in the command will be replaced with the uri to the dropped thing. + // @prop ondropped - Command to execute when something is dropped on top of this element. The placeholder `{}` used in the command will be replaced with the uri to the dropped thing. prop(timeout: as_duration = Duration::from_millis(200), ondropped: as_string) { gtk_widget.drag_dest_set( DestDefaults::ALL, @@ -753,14 +753,14 @@ fn build_gtk_event_box(bargs: &mut BuilderArgs) -> Result { // TODO the fact that we have the same code here as for button is ugly, as we want to keep consistency - // @prop onclick - a command that get's run when the button is clicked - // @prop onmiddleclick - a command that get's run when the button is middleclicked - // @prop onrightclick - a command that get's run when the button is rightclicked - // @prop timeout - timeout of the command prop( + // @prop timeout - timeout of the command timeout: as_duration = Duration::from_millis(200), + // @prop onclick - a command that get's run when the button is clicked onclick: as_string = "", + // @prop onmiddleclick - a command that get's run when the button is middleclicked onmiddleclick: as_string = "", + // @prop onrightclick - a command that get's run when the button is rightclicked onrightclick: as_string = "" ) { gtk_widget.add_events(gdk::EventMask::BUTTON_PRESS_MASK); @@ -910,7 +910,7 @@ const WIDGET_NAME_TRANSFORM: &str = "transform"; fn build_transform(bargs: &mut BuilderArgs) -> Result { let w = Transform::new(); def_widget!(bargs, _g, w, { - // @prop rotation - the percentage to rotate + // @prop rotate - the percentage to rotate prop(rotate: as_f64) { w.set_property("rotate", rotate)?; }, // @prop translate-x - the amount to translate in the x direction (px or %) prop(translate_x: as_string) { w.set_property("translate-x", translate_x)?; }, diff --git a/gen-docs.ts b/gen-docs.ts index bc88324..65d5d48 100644 --- a/gen-docs.ts +++ b/gen-docs.ts @@ -50,7 +50,7 @@ function parseMagicVariables(data: string) { } let output = ""; for (const {name, desc, prop} of defs) { - output += + output += `### \`${name}\`\n` + `${desc}\n`; if(prop != null) { @@ -82,7 +82,6 @@ function parseVars(code: string): Record { } function replaceTypeNames(type: string) { - switch (type) { case "f64": case "f32": @@ -114,8 +113,7 @@ function parseDocs(code: string) { if (newWidgetMatch && newWidgetMatch.length >= 3) { const name = newWidgetMatch[2]; - /** @type string[] */ - const exts = newWidgetMatch[3] + const exts: string[] = newWidgetMatch[3] ? newWidgetMatch[3].split(/, */) : []; currentWidget = name; @@ -135,6 +133,7 @@ function parseDocs(code: string) { continue; } + // if we find a property, check through the following lines until we reach the actual property definition const propMatch = line.match(PROP_PATTERN); if (propMatch && propMatch.length == 3) { let no = lineIndex + 1