From 9dcee01b335901cf2c80b453b97180e0d2551dc2 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Sun, 28 Feb 2021 17:30:10 -0500 Subject: [PATCH] Chore: remove html crate --- Cargo.toml | 4 +- packages/core-macro/Cargo.toml | 1 + .../src/lib.rs => core-macro/src/htm.rs} | 17 ++----- packages/core-macro/src/lib.rs | 17 ++++++- packages/core/Cargo.toml | 2 +- packages/core/src/lib.rs | 5 +- packages/html-macro-2/Cargo.toml | 21 -------- packages/html-macro-2/examples/proof.rs | 48 ------------------- 8 files changed, 25 insertions(+), 90 deletions(-) rename packages/{html-macro-2/src/lib.rs => core-macro/src/htm.rs} (96%) delete mode 100644 packages/html-macro-2/Cargo.toml delete mode 100644 packages/html-macro-2/examples/proof.rs diff --git a/Cargo.toml b/Cargo.toml index 8c83a7269..e468c9027 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,8 +18,8 @@ members = [ # "packages/hooks", "packages/cli", "examples", - "packages/html-macro", - "packages/html-macro-2", + # "packages/html-macro", + # "packages/html-macro-2", # # # diff --git a/packages/core-macro/Cargo.toml b/packages/core-macro/Cargo.toml index 295ceee40..3abaab822 100644 --- a/packages/core-macro/Cargo.toml +++ b/packages/core-macro/Cargo.toml @@ -16,6 +16,7 @@ proc-macro-hack = "0.5.19" proc-macro2 = "1.0.6" quote = "1.0" syn = { version = "1.0.11", features = ["full"] } +style-shared = { git = "https://github.com/derekdreery/style" } # testing [dev-dependencies] diff --git a/packages/html-macro-2/src/lib.rs b/packages/core-macro/src/htm.rs similarity index 96% rename from packages/html-macro-2/src/lib.rs rename to packages/core-macro/src/htm.rs index e7764fddf..264b05fc4 100644 --- a/packages/html-macro-2/src/lib.rs +++ b/packages/core-macro/src/htm.rs @@ -13,7 +13,7 @@ //! //! -use ::{ +use { proc_macro::TokenStream, proc_macro2::{Span, TokenStream as TokenStream2}, quote::{quote, ToTokens, TokenStreamExt}, @@ -25,21 +25,10 @@ use ::{ }, }; -/// The html! macro makes it easy for developers to write jsx-style markup in their components. -/// We aim to keep functional parity with html templates. -#[proc_macro] -pub fn html(s: TokenStream) -> TokenStream { - let html: HtmlRender = match syn::parse(s) { - Ok(s) => s, - Err(e) => return e.to_compile_error().into(), - }; - html.to_token_stream().into() -} - // ============================================== // Parse any stream coming from the html! macro // ============================================== -struct HtmlRender { +pub struct HtmlRender { kind: NodeOrList, } @@ -402,6 +391,8 @@ impl ToTokens for ToToksCtx<&LitStr> { } } +mod styles {} + #[cfg(test)] mod test { fn parse(input: &str) -> super::Result { diff --git a/packages/core-macro/src/lib.rs b/packages/core-macro/src/lib.rs index b9eddc1fa..64fd61bc7 100644 --- a/packages/core-macro/src/lib.rs +++ b/packages/core-macro/src/lib.rs @@ -1,3 +1,4 @@ +use proc_macro::TokenStream; use quote::{quote, quote_spanned, ToTokens}; use syn::spanned::Spanned; use syn::{ @@ -9,12 +10,24 @@ use syn::{ }; mod fc; +mod htm; mod ifmt; +/// The html! macro makes it easy for developers to write jsx-style markup in their components. +/// We aim to keep functional parity with html templates. +#[proc_macro] +pub fn html(s: TokenStream) -> TokenStream { + let html: htm::HtmlRender = match syn::parse(s) { + Ok(s) => s, + Err(e) => return e.to_compile_error().into(), + }; + html.to_token_stream().into() +} + /// Label a function or static closure as a functional component. /// This macro reduces the need to create a separate properties struct. #[proc_macro_attribute] -pub fn fc(attr: proc_macro::TokenStream, item: proc_macro::TokenStream) -> proc_macro::TokenStream { +pub fn fc(attr: TokenStream, item: TokenStream) -> TokenStream { use fc::{function_component_impl, FunctionComponent}; let item = parse_macro_input!(item as FunctionComponent); @@ -28,7 +41,7 @@ pub fn fc(attr: proc_macro::TokenStream, item: proc_macro::TokenStream) -> proc_ } #[proc_macro] -pub fn format_args_f(input: proc_macro::TokenStream) -> proc_macro::TokenStream { +pub fn format_args_f(input: TokenStream) -> TokenStream { use ifmt::*; let item = parse_macro_input!(input as IfmtInput); diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index cde24f9ae..48ebb42ef 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -12,7 +12,7 @@ description = "Core functionality for Dioxus - a concurrent renderer-agnostic Vi [dependencies] # dodrio-derive = { path = "../html-macro-2", version = "0.1.0" } # dioxus-html-macro = { path = "../html-macro", version = "0.1.0" } -dioxus-html-2 = { path = "../html-macro-2", version = "0.1.0" } +# dioxus-html-2 = { path = "../html-macro-2", version = "0.1.0" } dioxus-core-macro = { path = "../core-macro", version = "0.1.0" } # Backs some static data once_cell = "1.5.2" diff --git a/packages/core/src/lib.rs b/packages/core/src/lib.rs index 479ceb0d4..6016600c8 100644 --- a/packages/core/src/lib.rs +++ b/packages/core/src/lib.rs @@ -116,8 +116,7 @@ pub(crate) mod innerlude { // Re-export the FC macro pub use crate as dioxus; pub use crate::nodebuilder as builder; - pub use dioxus_core_macro::fc; - pub use dioxus_html_2::html; + pub use dioxus_core_macro::{fc, html}; } /// Re-export common types for ease of development use. @@ -145,7 +144,7 @@ pub mod prelude { pub use crate::nodebuilder as builder; // pub use dioxus_core_macro::fc; pub use dioxus_core_macro::format_args_f; - pub use dioxus_html_2::html; + pub use dioxus_core_macro::{fc, html}; // pub use crate::diff::DiffMachine; pub use crate::dodriodiff::DiffMachine; diff --git a/packages/html-macro-2/Cargo.toml b/packages/html-macro-2/Cargo.toml deleted file mode 100644 index 4dddc2d59..000000000 --- a/packages/html-macro-2/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "dioxus-html-2" -version = "0.1.0" -authors = ["Jonathan Kelley "] -edition = "2018" - -[lib] -proc-macro = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -syn = "1.0.18" -quote = "1.0.3" -proc-macro-hack = "0.5.15" -proc-macro2 = "1.0.10" -style-shared = { git = "https://github.com/derekdreery/style" } - - -[dev-dependencies] -bumpalo = "*" diff --git a/packages/html-macro-2/examples/proof.rs b/packages/html-macro-2/examples/proof.rs deleted file mode 100644 index 1219bf67c..000000000 --- a/packages/html-macro-2/examples/proof.rs +++ /dev/null @@ -1,48 +0,0 @@ -use bumpalo::Bump; -use dioxus_html_2::html; - -mod dioxus { - pub use bumpalo; - pub mod builder { - use bumpalo::Bump; - } -} - -fn main() { - /* - Th below code is not meant to compile, but it is meant to expand properly - - - */ - // let l = html! { - //
- //
- //

"asdl"

- //

"asdl"

- //

"asdl"

- //

"asdl"

- //
- //
- // }; - - // let l = move |bump| { - // dioxus::builder::div(bump) - // .children([dioxus::builder::div(bump) - // .children([ - // dioxus::builder::h1(bump) - // .children([dioxus::builder::text("asdl")]) - // .finish(), - // dioxus::builder::h1(bump) - // .children([dioxus::builder::text("asdl")]) - // .finish(), - // dioxus::builder::h1(bump) - // .children([dioxus::builder::text("asdl")]) - // .finish(), - // dioxus::builder::h1(bump) - // .children([dioxus::builder::text("asdl")]) - // .finish(), - // ]) - // .finish()]) - // .finish() - // }; -}