Skip to content

Commit

Permalink
remove doc comment dependency (hyprland-community#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
REALERvolker1 committed Apr 10, 2024
1 parent 8389d4c commit 3077f71
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 35 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ regex = { version = "1.10", default-features = false, features = [
"unicode",
] }
num-traits = "0.2.18"
doc-comment = "0.3.3"
paste = "1.0.14"
derive_more = { version = "0.99", default-features = false, features = [
"display",
Expand Down
40 changes: 16 additions & 24 deletions src/event_listener/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,69 +34,65 @@ macro_rules! add_listener_reg {
($name:ident $end:ident,$f:ty,$c:literal,$c2:expr => $id:ident) => {
paste! {
impl EventListener {
doc_comment! { concat!("This methods adds a event which ", $c, r#"
#[doc = concat!("This methods adds a event which ", stringify!($c), r#"
```rust, no_run
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_"#, stringify!($name), r#"_handler(|"#, stringify!($id), r#"| println!(""#, $c2, ": {", stringify!($id), r#":#?}"));
listener.start_listener();"#),
listener.start_listener();"#)]
pub fn [<add_ $name _handler>](&mut self, f: impl Fn($f) + 'static) {
self.events.[<$name $end _events>].push(EventTypes::Regular(Box::new(f)));
}
}
}
}
};
($name:ident,$f:ty,$c:literal,$c2:expr => $id:ident) => {
paste! {
impl EventListener {
doc_comment! { concat!("This methods adds a event which executes when ", $c, r#"
#[doc = concat!("This methods adds a event which executes when ", $c, r#"
```rust, no_run
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_"#, stringify!($name), r#"_handler(|"#, stringify!($id), r#"| println!(""#, $c2, ": {", stringify!($id), r#":#?}"));
listener.start_listener();"#),
listener.start_listener();"#)]
pub fn [<add_ $name _handler>](&mut self, f: impl Fn($f) + 'static) {
self.events.[<$name _events>].push(EventTypes::Regular(Box::new(f)));
}
}
}
}
};
}

macro_rules! add_async_listener {
($name:ident $end:ident,$f:ty,$c:literal,$c2:expr => $id:ident) => {
paste! {
impl AsyncEventListener {
doc_comment! { concat!("This methods adds a event which ", $c, r#"
#[doc = concat!("This methods adds a event which ", $c, r#"
```rust, no_run
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_"#, stringify!($name), r#"_handler(|"#, stringify!($id), r#"| println!(""#, $c2, ": {", stringify!($id), r#":#?}"));
listener.start_listener();"#),
listener.start_listener();"#)]
pub fn [<add_ $name _handler>](&mut self, f: impl Fn($f) -> VoidFuture + Send + Sync + 'static) {
self.events.[<$name $end _events>].push(AsyncEventTypes::Regular(Box::pin(f)));
}
}
}
}
};
($name:ident,$f:ty,$c:literal,$c2:expr => $id:ident) => {
paste! {
impl AsyncEventListener {
doc_comment! { concat!("This methods adds a event which executes when ", $c, r#"
#[doc = concat!("This methods adds a event which executes when ", $c, r#"
```rust, no_run
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_"#, stringify!($name), r#"_handler(|"#, stringify!($id), r#"| println!(""#, $c2, ": {", stringify!($id), r#":#?}"));
listener.start_listener();"#),
listener.start_listener();"#)]
pub fn [<add_ $name _handler>](&mut self, f: impl Fn($f) -> VoidFuture + Send + Sync + 'static) {
self.events.[<$name _events>].push(AsyncEventTypes::Regular(Box::pin(f)));
}
}
}
}
};
}

Expand All @@ -105,69 +101,65 @@ macro_rules! add_mut_async_listener {
($name:ident $end:ident,$f:ty,$c:literal,$c2:expr => $id:ident) => {
paste! {
impl AsyncMutableEventListener {
doc_comment! { concat!("This methods adds a event which ", $c, r#"
#[doc = concat!("This methods adds a event which ", $c, r#"
```rust, no_run
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_"#, stringify!($name), r#"_handler(|"#, stringify!($id), r#"| println!(""#, $c2, ": {", stringify!($id), r#":#?}"));
listener.start_listener();"#),
listener.start_listener();"#)]
pub fn [<add_ $name _handler>](&mut self, f: impl Fn($f, &mut StateV2) -> VoidFuture + Send + Sync + 'static) {
self.events.[<$name $end _events>].push(AsyncEventTypes::MutableState(Box::pin(f)));
}
}
}
}
};
($name:ident,$f:ty,$c:literal,$c2:expr => $id:ident) => {
paste! {
impl AsyncMutableEventListener {
doc_comment! { concat!("This methods adds a event which executes when ", $c, r#"
#[doc = concat!("This methods adds a event which executes when ", $c, r#"
```rust, no_run
use hyprland::event_listener::EventListener;
let mut listener = EventListener::new();
listener.add_"#, stringify!($name), r#"_handler(|"#, stringify!($id), r#"| println!(""#, $c2, ": {", stringify!($id), r#":#?}"));
listener.start_listener();"#),
listener.start_listener();"#)]
pub fn [<add_ $name _handler>](&mut self, f: impl Fn($f, &mut StateV2) -> VoidFuture + Send + Sync + 'static) {
self.events.[<$name _events>].push(AsyncEventTypes::MutableState(Box::pin(f)));
}
}
}
}
};
}

macro_rules! mut_add_listener {
($name:ident $end:ident,$f:ty,$c:literal,$c2:expr => $id:ident) => {
paste! {
impl EventListenerMutable {
doc_comment! { concat!("This methods adds a event which ", $c, r#"
#[doc = concat!("This methods adds a event which ", $c, r#"
```rust, no_run
use hyprland::event_listener::EventListenerMutable as EventListener;
let mut listener = EventListener::new();
listener.add_"#, stringify!($name), r#"_handler(|"#, stringify!($id), r#", _| println!(""#, $c2, ": {", stringify!($id), r#":#?}"));
listener.start_listener();"#),
listener.start_listener();"#)]
pub fn [<add_ $name _handler>](&mut self, f: impl Fn($f, &mut State) + 'static) {
self.events.[<$name $end _events>].push(EventTypes::MutableState(Box::new(f)));
}
}
}
}
};
($name:ident,$f:ty,$c:literal,$c2:expr => $id:ident) => {
paste! {
impl EventListenerMutable {
doc_comment! { concat!("This methods adds a event which executes when ", $c, r#"
#[doc = concat!("This methods adds a event which executes when ", $c, r#"
```rust, no_run
use hyprland::event_listener::EventListenerMutable as EventListener;
let mut listener = EventListener::new();
listener.add_"#, stringify!($name), r#"_handler(|"#, stringify!($id), r#", _| println!(""#, $c2, ": {", stringify!($id), r#":#?}"));
listener.start_listener();"#),
listener.start_listener();"#)]
pub fn [<add_ $name _handler>](&mut self, f: impl Fn($f, &mut State) + 'static) {
self.events.[<$name _events>].push(EventTypes::MutableState(Box::new(f)));
}
}
}
}
};
}

Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#![deny(unsafe_code)]
#![allow(async_fn_in_trait)]

#[macro_use]
extern crate doc_comment;

#[macro_use]
extern crate paste;

Expand Down

0 comments on commit 3077f71

Please sign in to comment.