From 46a2794a878db9d39b96e02c61faedf13ff3c979 Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Tue, 14 Mar 2023 13:28:47 +0100 Subject: [PATCH 1/5] Rename more typed-html references This also fixes the documentation links from axohtml_macros to axohtml. --- macros/Cargo.toml | 4 ++-- macros/src/lib.rs | 10 +++++----- tests/Cargo.toml | 2 +- typed-html/src/dom.rs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/macros/Cargo.toml b/macros/Cargo.toml index 67fa6d1..ad04e2c 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -6,8 +6,8 @@ authors = ["Axo Developer Co ", "Bodil Stokke "] build = "build.rs" license = "MPL-2.0+" description = "Type checked JSX for Rust (proc_macro crate)" -repository = "https://github.com/bodil/typed-html" -documentation = "http://docs.rs/typed-html/" +repository = "https://github.com/axodotdev/axohtml" +documentation = "http://docs.rs/axohtml/" readme = "../README.md" categories = ["template-engine", "web-programming"] keywords = ["jsx", "html"] diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 73f735b..298758c 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -17,9 +17,9 @@ mod span; /// Construct a DOM tree. /// -/// See the crate documentation for [`typed_html`][typed_html]. +/// See the crate documentation for [`axohtml`][axohtml]. /// -/// [typed_html]: ../typed_html/index.html +/// [axohtml]: https://docs.rs/axohtml/ #[proc_macro] pub fn html(input: TokenStream) -> TokenStream { let stream = lexer::unroll_stream(input.into(), false); @@ -35,9 +35,9 @@ pub fn html(input: TokenStream) -> TokenStream { /// Construct a Dodrio node. /// -/// See the crate documentation for [`typed_html`][typed_html]. +/// See the crate documentation for [`axohtml`][axohtml]. /// -/// [typed_html]: ../typed_html/index.html +/// [axohtml]: https://docs.rs/axohtml/ #[cfg(feature = "dodrio")] #[proc_macro] pub fn dodrio(input: TokenStream) -> TokenStream { @@ -53,7 +53,7 @@ pub fn dodrio(input: TokenStream) -> TokenStream { }) } -/// This macro is used by `typed_html` internally to generate types and +/// This macro is used by `axohtml` internally to generate types and /// implementations for HTML elements. #[proc_macro] pub fn declare_elements(input: TokenStream) -> TokenStream { diff --git a/tests/Cargo.toml b/tests/Cargo.toml index eb0a72c..9d89e5b 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -6,7 +6,7 @@ authors = ["Bodil Stokke "] publish = false [[bin]] -name = "typed-html-tests" +name = "axohtml-tests" path = "main.rs" [dev-dependencies] diff --git a/typed-html/src/dom.rs b/typed-html/src/dom.rs index 42bfe20..fcccbd1 100644 --- a/typed-html/src/dom.rs +++ b/typed-html/src/dom.rs @@ -154,7 +154,7 @@ pub struct UnsafeTextNode(String, PhantomData); /// /// This macro is useful for creating text macros inside code blocks that contain HTML /// that you do not want to be escaped. For example, if some other process renders Markdown -/// to an HTML string and you want embed that HTML string in a typed-html template, +/// to an HTML string and you want embed that HTML string in an axohtml template, /// you may want to avoid escaping the tags in that HTML string. /// /// # Examples From 643ab4622054bb6fbb26679fa494ebcbc22ebdc2 Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Tue, 14 Mar 2023 13:46:39 +0100 Subject: [PATCH 2/5] Fix links in README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bc5cb08..7dcd965 100644 --- a/README.md +++ b/README.md @@ -168,10 +168,10 @@ Copyright 2018 Bodil Stokke, 2022 Axo Developer Co. [Display]: https://doc.rust-lang.org/std/fmt/trait.Display.html [String]: https://doc.rust-lang.org/std/string/struct.String.html [to_string]: https://doc.rust-lang.org/std/string/trait.ToString.html#tymethod.to_string -[Node]: dom/trait.Node.html +[Node]: https://docs.rs/axohtml/latest/axohtml/dom/trait.Node.html [FromStr]: https://doc.rust-lang.org/std/str/trait.FromStr.html -[SpacedSet]: types/struct.SpacedSet.html +[SpacedSet]: https://docs.rs/axohtml/latest/axohtml/types/struct.SpacedSet.html [IntoIterator]: https://doc.rust-lang.org/std/iter/trait.IntoIterator.html [Into]: https://doc.rust-lang.org/std/convert/trait.Into.html [Into::into]: https://doc.rust-lang.org/std/convert/trait.Into.html#method.into -[DOMTree]: dom/type.DOMTree.html +[DOMTree]: https://docs.rs/axohtml/latest/axohtml/dom/type.DOMTree.html From f15ed2d080327d05c639495dcb6e5ebab384396a Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Tue, 14 Mar 2023 16:20:58 +0100 Subject: [PATCH 3/5] Sync README with crate doc 5334d783f247ca4d217dc7bed40d2fd1b2e98a2f and c036b7c7c584cfb13cbee31a13060295d39aa7c9 were only applied to the crate documentation but not to the copy in README.md. Might make sense to use https://github.com/livioribeiro/cargo-readme or https://github.com/orium/cargo-rdme ;) --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7dcd965..4f9c577 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ let mut doc: DOMTree = html!(

)) }

- "Every company should be a developer experience company" + "Every company should be a developer experience company."

@@ -95,14 +95,14 @@ conversion will panic at runtime if the string is invalid. ### Example ```rust -let classList: SpacedSet = ["foo", "bar", "baz"].into(); +let classList: SpacedSet = ["foo", "bar", "baz"].try_into()?; html!(
// parses a string literal
// uses From<[&str, &str, &str]>
// uses a variable in scope
) @@ -151,7 +151,7 @@ assert_eq!("

Hello Axo

", doc_str); ### Render to a virtual DOM The DOM tree structure also implements a method called `vnode()`, which renders -the tree to a tree of [`Node`][Node]s, which is a mirror of the generated tree +the tree to a tree of [`VNode`][VNode]s, which is a mirror of the generated tree with every attribute value rendered into `String`s. You can walk this virtual DOM tree and pass it on to your favourite virtual DOM system. @@ -168,7 +168,7 @@ Copyright 2018 Bodil Stokke, 2022 Axo Developer Co. [Display]: https://doc.rust-lang.org/std/fmt/trait.Display.html [String]: https://doc.rust-lang.org/std/string/struct.String.html [to_string]: https://doc.rust-lang.org/std/string/trait.ToString.html#tymethod.to_string -[Node]: https://docs.rs/axohtml/latest/axohtml/dom/trait.Node.html +[VNode]: https://docs.rs/axohtml/latest/axohtml/dom/enum.VNode.html [FromStr]: https://doc.rust-lang.org/std/str/trait.FromStr.html [SpacedSet]: https://docs.rs/axohtml/latest/axohtml/types/struct.SpacedSet.html [IntoIterator]: https://doc.rust-lang.org/std/iter/trait.IntoIterator.html From a5584737953d355227d01fde7aa0fd170f480dc5 Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Sun, 26 Mar 2023 01:08:43 +0100 Subject: [PATCH 4/5] Use intra-doc links instead of manual links --- typed-html/src/dom.rs | 33 ++++++++---------------------- typed-html/src/lib.rs | 27 ++++++++---------------- typed-html/src/types/class.rs | 4 +--- typed-html/src/types/id.rs | 4 +--- typed-html/src/types/spacedlist.rs | 4 +--- 5 files changed, 20 insertions(+), 52 deletions(-) diff --git a/typed-html/src/dom.rs b/typed-html/src/dom.rs index fcccbd1..c16d134 100644 --- a/typed-html/src/dom.rs +++ b/typed-html/src/dom.rs @@ -29,7 +29,7 @@ pub type DOMTree = Box>; /// /// This structure is designed to be easily walked in order to render a DOM tree /// or diff against an existing tree. It's the stringly typed version of -/// [`Node`][Node]. +/// [`Node`]. /// /// It can be constructed from any ['Node'][Node]: /// @@ -38,8 +38,6 @@ pub type DOMTree = Box>; ///

"But how does she ""eat?"

/// ).vnode() /// ``` -/// -/// [Node]: trait.Node.html pub enum VNode<'a, T: OutputType + 'a> { Text(&'a str), UnsafeText(&'a str), @@ -56,20 +54,13 @@ pub struct VElement<'a, T: OutputType + 'a> { /// Trait for rendering a typed HTML node. /// -/// All [HTML elements][elements] implement this, in addition to -/// [`TextNode`][TextNode]. +/// All [HTML elements][crate::elements] implement this, in addition to +/// [`TextNode`]. /// -/// It implements [`Display`][Display] for rendering to strings, and the -/// [`vnode()`][vnode] method can be used to render a virtual DOM structure. -/// -/// [Display]: https://doc.rust-lang.org/std/fmt/trait.Display.html -/// [TextNode]: struct.TextNode.html -/// [elements]: ../elements/index.html -/// [vnode]: #tymethod.vnode +/// It implements [`Display`] for rendering to strings, and the +/// [`vnode()`][Self::vnode] method can be used to render a virtual DOM structure. pub trait Node: Display + Send { - /// Render the node into a [`VNode`][VNode] tree. - /// - /// [VNode]: enum.VNode.html + /// Render the node into a [`VNode`] tree. fn vnode(&mut self) -> VNode; } @@ -87,9 +78,7 @@ where /// Trait for querying a typed HTML element. /// -/// All [HTML elements][elements] implement this. -/// -/// [elements]: ../elements/index.html +/// All [HTML elements][crate::elements] implement this. pub trait Element: Node { /// Get the name of the element. fn name() -> &'static str; @@ -189,10 +178,8 @@ macro_rules! unsafe_text { impl TextNode { /// Construct a text node. /// - /// The preferred way to construct a text node is with the [`text!()`][text] + /// The preferred way to construct a text node is with the [`text!()`][crate::text] /// macro. - /// - /// [text]: ../macro.text.html pub fn new>(s: S) -> Self { TextNode(s.into(), PhantomData) } @@ -234,10 +221,8 @@ impl PhrasingContent for TextNode {} impl UnsafeTextNode { /// Construct a unsafe text node. /// - /// The preferred way to construct a unsafe text node is with the [`unsafe_text!()`][unsafe_text] + /// The preferred way to construct a unsafe text node is with the [`unsafe_text!()`][crate::unsafe_text] /// macro. - /// - /// [unsafe_text]: ../macro.unsafe_text.html pub fn new>(s: S) -> Self { UnsafeTextNode(s.into(), PhantomData) } diff --git a/typed-html/src/lib.rs b/typed-html/src/lib.rs index e108f12..b4d7648 100644 --- a/typed-html/src/lib.rs +++ b/typed-html/src/lib.rs @@ -75,14 +75,14 @@ //! (see the Syntax section above). //! //! The `html!` macro will add an [`.into()`][Into::into] call to the value -//! expression, so that you can use any type that has an [`Into`][Into] trait +//! expression, so that you can use any type that has an [`Into`] trait //! defined for the actual attribute type `A`. //! //! As a special case, if you use a string literal, the macro will instead use the -//! [`FromStr`][FromStr] trait to try and parse the string literal into the +//! [`FromStr`][std::str::FromStr] trait to try and parse the string literal into the //! expected type. This is extremely useful for eg. CSS classes, letting you type //! `class="css-class-1 css-class-2"` instead of going to the trouble of -//! constructing a [`SpacedSet`][SpacedSet]. The big caveat for this: +//! constructing a [`SpacedSet`][types::SpacedSet]. The big caveat for this: //! currently, the macro is not able to validate the string at compile time, and the //! conversion will panic at runtime if the string is invalid. //! @@ -112,7 +112,7 @@ //! # Generated Nodes //! //! Brace blocks in the child node position are expected to return an -//! [`IntoIterator`][IntoIterator] of [`DOMTree`][DOMTree]s. You can return single +//! [`IntoIterator`] of [`DOMTree`][dom::DOMTree]s. You can return single //! elements or text nodes, as they both implement `IntoIterator` for themselves. //! The macro will consume this iterator at runtime and insert the generated nodes //! as children in the expected position. @@ -141,9 +141,9 @@ //! //! ## Render to a string //! -//! The DOM tree data structure implements [`Display`][Display], so you can call -//! [`to_string()`][to_string] on it to render it to a [`String`][String]. If you -//! plan to do this, the type of the tree should be [`DOMTree`][DOMTree] to +//! The DOM tree data structure implements [`Display`], so you can call +//! [`to_string()`][std::string::ToString::to_string] on it to render it to a [`String`]. If you +//! plan to do this, the type of the tree should be [`DOMTree`][dom::DOMTree] to //! ensure you're not using any event handlers that can't be printed. //! //! ``` @@ -161,7 +161,7 @@ //! ## Render to a virtual DOM //! //! The DOM tree structure also implements a method called `vnode()`, which renders -//! the tree to a tree of [`VNode`][VNode]s, which is a mirror of the generated tree +//! the tree to a tree of [`VNode`][dom::VNode]s, which is a mirror of the generated tree //! with every attribute value rendered into `String`s. You can walk this virtual //! DOM tree and pass it on to your favourite virtual DOM system. //! @@ -174,17 +174,6 @@ //! . //! //! [JSX]: https://reactjs.org/docs/introducing-jsx.html -//! [Display]: https://doc.rust-lang.org/std/fmt/trait.Display.html -//! [String]: https://doc.rust-lang.org/std/string/struct.String.html -//! [to_string]: https://doc.rust-lang.org/std/string/trait.ToString.html#tymethod.to_string -//! [Node]: dom/trait.Node.html -//! [VNode]: dom/enum.VNode.html -//! [FromStr]: https://doc.rust-lang.org/std/str/trait.FromStr.html -//! [SpacedSet]: types/struct.SpacedSet.html -//! [IntoIterator]: https://doc.rust-lang.org/std/iter/trait.IntoIterator.html -//! [Into]: https://doc.rust-lang.org/std/convert/trait.Into.html -//! [Into::into]: https://doc.rust-lang.org/std/convert/trait.Into.html#method.into -//! [DOMTree]: dom/type.DOMTree.html pub extern crate htmlescape; diff --git a/typed-html/src/types/class.rs b/typed-html/src/types/class.rs index dd5833b..6209120 100644 --- a/typed-html/src/types/class.rs +++ b/typed-html/src/types/class.rs @@ -12,9 +12,7 @@ use super::Id; /// and is followed by any number of alphanumeric characters and the /// `_`, `-` and `.` characters. /// -/// See also [`Id`][Id]. -/// -/// [Id]: struct.Id.html +/// See also [`Id`]. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] pub struct Class(String); diff --git a/typed-html/src/types/id.rs b/typed-html/src/types/id.rs index a4294a0..262e98c 100644 --- a/typed-html/src/types/id.rs +++ b/typed-html/src/types/id.rs @@ -12,9 +12,7 @@ use super::Class; /// and is followed by any number of alphanumeric characters and the /// `_`, `-` and `.` characters. /// -/// See also [`Class`][Class]. -/// -/// [Class]: struct.Class.html +/// See also [`Class`]. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] pub struct Id(String); diff --git a/typed-html/src/types/spacedlist.rs b/typed-html/src/types/spacedlist.rs index 8859c44..09cf787 100644 --- a/typed-html/src/types/spacedlist.rs +++ b/typed-html/src/types/spacedlist.rs @@ -8,9 +8,7 @@ use std::str::FromStr; /// /// This type represents a list of non-unique values represented as a string of /// values separated by spaces in HTML attributes. This is rarely used; a -/// [`SpacedSet`][SpacedSet] of unique values is much more common. -/// -/// [SpacedSet]: struct.SpacedSet.html +/// [`SpacedSet`][super::SpacedSet] of unique values is much more common. #[derive(Clone, PartialEq, Eq, Hash)] pub struct SpacedList(Vec); From 2c417a0a5b54f58359f62b57fb150812d8fe249a Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Sun, 26 Mar 2023 01:09:55 +0100 Subject: [PATCH 5/5] Sync crate doc with README --- typed-html/src/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/typed-html/src/lib.rs b/typed-html/src/lib.rs index b4d7648..83e9d1d 100644 --- a/typed-html/src/lib.rs +++ b/typed-html/src/lib.rs @@ -1,6 +1,13 @@ #![recursion_limit = "128"] -//! This crate provides the `html!` macro for building HTML documents inside your -//! Rust code using roughly [JSX] compatible syntax. +//! This crate provides the `html!` macro for building fully type checked HTML +//! documents inside your Rust code using roughly [JSX] compatible syntax. +//! +//! This crate is a fork of the great [Bodil Stokke's] [typed-html] crate. Opted +//! for a fork instead of maintainership because not currently intending to use or +//! maintain the Wasm compatibility (for now). +//! +//! [Bodil Stokke's]: https://github.com/bodil +//! [typed-html]: https://github.com/bodil/typed-html //! //! # Quick Preview //!