From: Shannon Sterz <s.sterz@proxmox.com>
To: yew-devel@lists.proxmox.com
Subject: [yew-devel] [PATCH yew-widget-toolkit 4/4] macros: update dummy pwt implementations so that the doc tests succeed
Date: Tue, 14 Jan 2025 12:44:40 +0100 [thread overview]
Message-ID: <20250114114440.177877-5-s.sterz@proxmox.com> (raw)
In-Reply-To: <20250114114440.177877-1-s.sterz@proxmox.com>
adds the updated trait definitions and adds a dummy `oncklick`
implementation so that the doc tests succeed again
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
pwt-macros/src/lib.rs | 49 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 47 insertions(+), 2 deletions(-)
diff --git a/pwt-macros/src/lib.rs b/pwt-macros/src/lib.rs
index 1b62d1d9..1e353a0d 100644
--- a/pwt-macros/src/lib.rs
+++ b/pwt-macros/src/lib.rs
@@ -60,11 +60,25 @@ use builder::*;
/// # #[derive(Clone, PartialEq, Default)]
/// # pub struct WidgetStdProps {
/// # pub class: yew::Classes,
+/// # pub key: Option<yew::virtual_dom::Key>,
+/// # pub styles: CssStyles,
+/// # }
+/// # pub trait FieldBuilder {
+/// # fn as_input_props(&self) -> &FieldStdProps;
+/// # fn as_input_props_mut(&mut self) -> &mut FieldStdProps;
/// # }
/// # #[derive(Clone, PartialEq, Default)]
/// # pub struct ListenersWrapper;
-/// # pub trait WidgetBuilder {
+/// # pub trait WidgetBuilder: Sized {
/// # fn as_std_props_mut(&mut self) -> &mut WidgetStdProps;
+/// # fn as_std_props(&self) -> &WidgetStdProps;
+/// # fn class(mut self, class: impl Into<yew::Classes>) -> Self {
+/// # self.add_class(class);
+/// # self
+/// # }
+/// # fn add_class(&mut self, class: impl Into<yew::Classes>) {
+/// # self.as_std_props_mut().class.push(class);
+/// # }
/// # }
/// # pub trait AsClassesMut {
/// # fn as_classes_mut(&mut self) -> &mut yew::Classes;
@@ -72,12 +86,22 @@ use builder::*;
/// # pub trait CssBorderBuilder {}
/// # pub trait CssMarginBuilder {}
/// # pub trait CssPaddingBuilder {}
+/// # pub trait AsCssStylesMut {
+/// # fn as_css_styles_mut(&mut self) -> &mut CssStyles;
+/// # }
+/// # #[derive(Clone, Default, Debug, PartialEq)]
+/// # pub struct CssStyles {}
/// # pub trait EventSubscriber: Sized {
/// # fn as_listeners_mut(&mut self) -> &mut ListenersWrapper;
+/// #
+/// # // dummy implementation so that the test case succeeds below
/// # fn onclick(mut self, _cb: impl yew::html::IntoEventCallback<yew::MouseEvent>) -> Self {
/// # self
/// # }
/// # }
+/// # pub trait WidgetStyleBuilder {}
+/// # #[derive(PartialEq, Default, Clone)]
+/// # pub struct FieldStdProps {}
/// # }
/// # }
/// use pwt_macros::widget;
@@ -121,11 +145,24 @@ use builder::*;
/// # pub struct WidgetStdProps {
/// # pub class: yew::Classes,
/// # pub key: Option<yew::virtual_dom::Key>,
+/// # pub styles: CssStyles,
+/// # }
+/// # pub trait FieldBuilder {
+/// # fn as_input_props(&self) -> &FieldStdProps;
+/// # fn as_input_props_mut(&mut self) -> &mut FieldStdProps;
/// # }
/// # #[derive(Clone, PartialEq, Default)]
/// # pub struct ListenersWrapper;
-/// # pub trait WidgetBuilder {
+/// # pub trait WidgetBuilder: Sized {
/// # fn as_std_props_mut(&mut self) -> &mut WidgetStdProps;
+/// # fn as_std_props(&self) -> &WidgetStdProps;
+/// # fn class(mut self, class: impl Into<yew::Classes>) -> Self {
+/// # self.add_class(class);
+/// # self
+/// # }
+/// # fn add_class(&mut self, class: impl Into<yew::Classes>) {
+/// # self.as_std_props_mut().class.push(class);
+/// # }
/// # }
/// # pub trait AsClassesMut {
/// # fn as_classes_mut(&mut self) -> &mut yew::Classes;
@@ -133,9 +170,17 @@ use builder::*;
/// # pub trait CssBorderBuilder {}
/// # pub trait CssMarginBuilder {}
/// # pub trait CssPaddingBuilder {}
+/// # pub trait AsCssStylesMut {
+/// # fn as_css_styles_mut(&mut self) -> &mut CssStyles;
+/// # }
+/// # #[derive(Clone, Default, Debug, PartialEq)]
+/// # pub struct CssStyles {}
/// # pub trait EventSubscriber: Sized {
/// # fn as_listeners_mut(&mut self) -> &mut ListenersWrapper;
/// # }
+/// # pub trait WidgetStyleBuilder {}
+/// # #[derive(PartialEq, Default, Clone)]
+/// # pub struct FieldStdProps {}
/// # }
/// # }
/// use pwt_macros::widget;
--
2.39.5
_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel
next prev parent reply other threads:[~2025-01-14 11:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-14 11:44 [yew-devel] [PATCH yew-widget-toolkit 0/4] update macro tests Shannon Sterz
2025-01-14 11:44 ` [yew-devel] [PATCH yew-widget-toolkit 1/4] macros: update compiler version in invalid_type test Shannon Sterz
2025-01-14 11:44 ` [yew-devel] [PATCH yew-widget-toolkit 2/4] macros: update no_clone test to adjust to new additional traits Shannon Sterz
2025-01-14 11:44 ` [yew-devel] [PATCH yew-widget-toolkit 3/4] macros: update wrong_comp " Shannon Sterz
2025-01-14 11:44 ` Shannon Sterz [this message]
2025-01-14 12:24 ` [yew-devel] applied: [PATCH yew-widget-toolkit 0/4] update macro tests Dietmar Maurer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250114114440.177877-5-s.sterz@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=yew-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.