Fix some types missing in widget docs

This commit is contained in:
elkowar 2022-05-26 15:00:34 +02:00
parent fe7bc30fc9
commit 0b0715fd50
No known key found for this signature in database
GPG key ID: E321AD71B1D1F27F
3 changed files with 14 additions and 15 deletions

2
Cargo.lock generated
View file

@ -403,7 +403,7 @@ dependencies = [
[[package]]
name = "eww"
version = "0.2.0"
version = "0.3.0"
dependencies = [
"anyhow",
"bincode",

View file

@ -452,14 +452,14 @@ fn build_gtk_button(bargs: &mut BuilderArgs) -> Result<gtk::Button> {
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<gtk::EventBox> {
}));
},
// @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<gtk::EventBox> {
// 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<Transform> {
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)?; },

View file

@ -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<string, string> {
}
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