소스 검색

Chore: remove html crate

Jonathan Kelley 4 년 전
부모
커밋
9dcee01b33

+ 2 - 2
Cargo.toml

@@ -18,8 +18,8 @@ members = [
     # "packages/hooks",
     # "packages/hooks",
     "packages/cli",
     "packages/cli",
     "examples",
     "examples",
-    "packages/html-macro",
-    "packages/html-macro-2",
+    # "packages/html-macro",
+    # "packages/html-macro-2",
     #
     #
     #
     #
     #
     #

+ 1 - 0
packages/core-macro/Cargo.toml

@@ -16,6 +16,7 @@ proc-macro-hack = "0.5.19"
 proc-macro2 = "1.0.6"
 proc-macro2 = "1.0.6"
 quote = "1.0"
 quote = "1.0"
 syn = { version = "1.0.11", features = ["full"] }
 syn = { version = "1.0.11", features = ["full"] }
+style-shared = { git = "https://github.com/derekdreery/style" }
 
 
 # testing
 # testing
 [dev-dependencies]
 [dev-dependencies]

+ 4 - 13
packages/html-macro-2/src/lib.rs → packages/core-macro/src/htm.rs

@@ -13,7 +13,7 @@
 //!
 //!
 //!
 //!
 
 
-use ::{
+use {
     proc_macro::TokenStream,
     proc_macro::TokenStream,
     proc_macro2::{Span, TokenStream as TokenStream2},
     proc_macro2::{Span, TokenStream as TokenStream2},
     quote::{quote, ToTokens, TokenStreamExt},
     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
 // Parse any stream coming from the html! macro
 // ==============================================
 // ==============================================
-struct HtmlRender {
+pub struct HtmlRender {
     kind: NodeOrList,
     kind: NodeOrList,
 }
 }
 
 
@@ -402,6 +391,8 @@ impl ToTokens for ToToksCtx<&LitStr> {
     }
     }
 }
 }
 
 
+mod styles {}
+
 #[cfg(test)]
 #[cfg(test)]
 mod test {
 mod test {
     fn parse(input: &str) -> super::Result<super::HtmlRender> {
     fn parse(input: &str) -> super::Result<super::HtmlRender> {

+ 15 - 2
packages/core-macro/src/lib.rs

@@ -1,3 +1,4 @@
+use proc_macro::TokenStream;
 use quote::{quote, quote_spanned, ToTokens};
 use quote::{quote, quote_spanned, ToTokens};
 use syn::spanned::Spanned;
 use syn::spanned::Spanned;
 use syn::{
 use syn::{
@@ -9,12 +10,24 @@ use syn::{
 };
 };
 
 
 mod fc;
 mod fc;
+mod htm;
 mod ifmt;
 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.
 /// Label a function or static closure as a functional component.
 /// This macro reduces the need to create a separate properties struct.
 /// This macro reduces the need to create a separate properties struct.
 #[proc_macro_attribute]
 #[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};
     use fc::{function_component_impl, FunctionComponent};
 
 
     let item = parse_macro_input!(item as 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]
 #[proc_macro]
-pub fn format_args_f(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
+pub fn format_args_f(input: TokenStream) -> TokenStream {
     use ifmt::*;
     use ifmt::*;
 
 
     let item = parse_macro_input!(input as IfmtInput);
     let item = parse_macro_input!(input as IfmtInput);

+ 1 - 1
packages/core/Cargo.toml

@@ -12,7 +12,7 @@ description = "Core functionality for Dioxus - a concurrent renderer-agnostic Vi
 [dependencies]
 [dependencies]
 # dodrio-derive = { path = "../html-macro-2", version = "0.1.0" }
 # dodrio-derive = { path = "../html-macro-2", version = "0.1.0" }
 # dioxus-html-macro = { path = "../html-macro", 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" }
 dioxus-core-macro = { path = "../core-macro", version = "0.1.0" }
 # Backs some static data
 # Backs some static data
 once_cell = "1.5.2"
 once_cell = "1.5.2"

+ 2 - 3
packages/core/src/lib.rs

@@ -116,8 +116,7 @@ pub(crate) mod innerlude {
     // Re-export the FC macro
     // Re-export the FC macro
     pub use crate as dioxus;
     pub use crate as dioxus;
     pub use crate::nodebuilder as builder;
     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.
 /// Re-export common types for ease of development use.
@@ -145,7 +144,7 @@ pub mod prelude {
     pub use crate::nodebuilder as builder;
     pub use crate::nodebuilder as builder;
     // pub use dioxus_core_macro::fc;
     // pub use dioxus_core_macro::fc;
     pub use dioxus_core_macro::format_args_f;
     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::diff::DiffMachine;
     pub use crate::dodriodiff::DiffMachine;
     pub use crate::dodriodiff::DiffMachine;

+ 0 - 21
packages/html-macro-2/Cargo.toml

@@ -1,21 +0,0 @@
-[package]
-name = "dioxus-html-2"
-version = "0.1.0"
-authors = ["Jonathan Kelley <jkelleyrtp@gmail.com>"]
-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 = "*"

+ 0 - 48
packages/html-macro-2/examples/proof.rs

@@ -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! {
-    //     <div>
-    //         <div>
-    //             <h1>"asdl"</h1>
-    //             <h1>"asdl"</h1>
-    //             <h1>"asdl"</h1>
-    //             <h1>"asdl"</h1>
-    //         </div>
-    //     </div>
-    // };
-
-    // 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()
-    // };
-}