* remove dioxus lib * inline some doc items * fix tests * test docs * Fix doc tests * Pull out dioxus/lib feature * disable logger and devtools in library feature * fix cargo doc * fix cargo doc
51 lines
1.1 KiB
Rust
51 lines
1.1 KiB
Rust
use crate::{DynIdx, PartialExpr};
|
|
use quote::{quote, ToTokens, TokenStreamExt};
|
|
use syn::parse::Parse;
|
|
|
|
#[derive(PartialEq, Eq, Clone, Debug)]
|
|
pub struct ExprNode {
|
|
pub expr: PartialExpr,
|
|
pub dyn_idx: DynIdx,
|
|
}
|
|
|
|
impl ExprNode {
|
|
pub fn span(&self) -> proc_macro2::Span {
|
|
self.expr.span()
|
|
}
|
|
}
|
|
|
|
impl Parse for ExprNode {
|
|
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
|
|
Ok(Self {
|
|
expr: input.parse()?,
|
|
dyn_idx: DynIdx::default(),
|
|
})
|
|
}
|
|
}
|
|
|
|
impl ToTokens for ExprNode {
|
|
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
|
|
let expr = &self.expr;
|
|
tokens.append_all(quote! {
|
|
{
|
|
#[allow(unused_braces)]
|
|
let ___nodes = dioxus_core::IntoDynNode::into_dyn_node(#expr);
|
|
___nodes
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn no_commas() {
|
|
use prettier_please::PrettyUnparse;
|
|
let input = quote! {
|
|
div {
|
|
{label("Hello, world!")},
|
|
}
|
|
};
|
|
|
|
let _expr: crate::BodyNode = syn::parse2(input).unwrap();
|
|
println!("{}", _expr.to_token_stream().pretty_unparse());
|
|
}
|