2018 edition.

This commit is contained in:
Bodil Stokke 2019-03-15 23:06:20 +00:00
parent 10ad3b2abc
commit dbb4ba8738
18 changed files with 48 additions and 53 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
/target target/
**/*.rs.bk **/*.rs.bk
Cargo.lock Cargo.lock

View File

@ -1,6 +1,7 @@
[package] [package]
name = "typed-html-rocket-test" name = "typed-html-rocket-test"
version = "0.1.0" version = "0.1.0"
edition = "2018"
authors = ["Bodil Stokke <bodil@bodil.org>"] authors = ["Bodil Stokke <bodil@bodil.org>"]
[dependencies] [dependencies]

View File

@ -1,6 +1,7 @@
[package] [package]
name = "typed-html-stdweb-test" name = "typed-html-stdweb-test"
version = "0.1.0" version = "0.1.0"
edition = "2018"
authors = ["Bodil Stokke <bodil@bodil.org>"] authors = ["Bodil Stokke <bodil@bodil.org>"]
[dependencies] [dependencies]

View File

@ -1,6 +1,7 @@
[package] [package]
name = "typed-html-macros" name = "typed-html-macros"
version = "0.1.1" version = "0.1.1"
edition = "2018"
authors = ["Bodil Stokke <bodil@bodil.org>"] authors = ["Bodil Stokke <bodil@bodil.org>"]
build = "build.rs" build = "build.rs"
license = "MPL-2.0+" license = "MPL-2.0+"

View File

@ -1,6 +1,6 @@
use proc_macro2::{Ident, Span, TokenStream}; use proc_macro2::{Ident, Span, TokenStream};
use map::StringyMap; use crate::map::StringyMap;
pub fn required_children(element: &str) -> &[&str] { pub fn required_children(element: &str) -> &[&str] {
match element { match element {

View File

@ -1,12 +1,12 @@
use proc_macro2::{Ident, Literal, TokenStream, TokenTree}; use proc_macro2::{Ident, Literal, TokenStream, TokenTree};
use quote::quote; use quote::quote;
use config::{global_attrs, SELF_CLOSING}; use crate::config::{global_attrs, SELF_CLOSING};
use error::ParseError; use crate::error::ParseError;
use ident; use crate::ident;
use lexer::{Lexer, Token}; use crate::lexer::{Lexer, Token};
use map::StringyMap; use crate::map::StringyMap;
use parser; use crate::parser;
// State // State
@ -103,7 +103,7 @@ impl Declare {
} }
quote!( quote!(
pub struct #elem_name<T> where T: ::OutputType { pub struct #elem_name<T> where T: crate::OutputType {
pub attrs: #attr_type_name, pub attrs: #attr_type_name,
pub data_attributes: Vec<(&'static str, String)>, pub data_attributes: Vec<(&'static str, String)>,
pub events: T::Events, pub events: T::Events,
@ -140,7 +140,7 @@ impl Declare {
} }
quote!( quote!(
impl<T> #elem_name<T> where T: ::OutputType { impl<T> #elem_name<T> where T: crate::OutputType {
pub fn new(#args) -> Self { pub fn new(#args) -> Self {
#elem_name { #elem_name {
events: T::Events::default(), events: T::Events::default(),
@ -184,7 +184,7 @@ impl Declare {
#req_children #req_children
#opt_children #opt_children
::dom::VNode::Element(::dom::VElement { crate::dom::VNode::Element(crate::dom::VElement {
name: #elem_name, name: #elem_name,
attributes, attributes,
events: &mut self.events, events: &mut self.events,
@ -197,8 +197,8 @@ impl Declare {
let elem_name = self.elem_name(); let elem_name = self.elem_name();
let vnode = self.impl_vnode(); let vnode = self.impl_vnode();
quote!( quote!(
impl<T> ::dom::Node<T> for #elem_name<T> where T: ::OutputType { impl<T> crate::dom::Node<T> for #elem_name<T> where T: crate::OutputType {
fn vnode(&'_ mut self) -> ::dom::VNode<'_, T> { fn vnode(&'_ mut self) -> crate::dom::VNode<'_, T> {
#vnode #vnode
} }
} }
@ -225,7 +225,7 @@ impl Declare {
} }
quote!( quote!(
impl<T> ::dom::Element<T> for #elem_name<T> where T: ::OutputType { impl<T> crate::dom::Element<T> for #elem_name<T> where T: crate::OutputType {
fn name() -> &'static str { fn name() -> &'static str {
#name #name
} }
@ -256,7 +256,7 @@ impl Declare {
for t in &self.traits { for t in &self.traits {
let name = t.clone(); let name = t.clone();
body.extend(quote!( body.extend(quote!(
impl<T> #name<T> for #elem_name<T> where T: ::OutputType {} impl<T> #name<T> for #elem_name<T> where T: crate::OutputType {}
)); ));
} }
body body
@ -265,7 +265,7 @@ impl Declare {
fn impl_into_iter(&self) -> TokenStream { fn impl_into_iter(&self) -> TokenStream {
let elem_name = self.elem_name(); let elem_name = self.elem_name();
quote!( quote!(
impl<T> IntoIterator for #elem_name<T> where T: ::OutputType { impl<T> IntoIterator for #elem_name<T> where T: crate::OutputType {
type Item = #elem_name<T>; type Item = #elem_name<T>;
type IntoIter = std::vec::IntoIter<#elem_name<T>>; type IntoIter = std::vec::IntoIter<#elem_name<T>>;
fn into_iter(self) -> Self::IntoIter { fn into_iter(self) -> Self::IntoIter {
@ -273,7 +273,7 @@ impl Declare {
} }
} }
impl<T> IntoIterator for Box<#elem_name<T>> where T: ::OutputType { impl<T> IntoIterator for Box<#elem_name<T>> where T: crate::OutputType {
type Item = Box<#elem_name<T>>; type Item = Box<#elem_name<T>>;
type IntoIter = std::vec::IntoIter<Box<#elem_name<T>>>; type IntoIter = std::vec::IntoIter<Box<#elem_name<T>>>;
fn into_iter(self) -> Self::IntoIter { fn into_iter(self) -> Self::IntoIter {
@ -346,7 +346,7 @@ impl Declare {
quote!( quote!(
impl<T> std::fmt::Display for #elem_name<T> impl<T> std::fmt::Display for #elem_name<T>
where where
T: ::OutputType, T: crate::OutputType,
{ {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
write!(f, "<{}", #name)?; write!(f, "<{}", #name)?;

View File

@ -1,6 +1,6 @@
use ansi_term::Style; use ansi_term::Style;
use lalrpop_util::ParseError::*; use lalrpop_util::ParseError::*;
use lexer::Token; use crate::lexer::Token;
use proc_macro2::{Ident, TokenStream}; use proc_macro2::{Ident, TokenStream};
use quote::{quote, quote_spanned}; use quote::{quote, quote_spanned};

View File

@ -1,11 +1,11 @@
use lexer::{self, Token, to_stream}; use crate::lexer::{self, Token, to_stream};
use error::HtmlParseError; use crate::error::HtmlParseError;
use html::{Node, Element}; use crate::html::{Node, Element};
use declare::Declare; use crate::declare::Declare;
use map::StringyMap; use crate::map::StringyMap;
use proc_macro2::{Delimiter, Ident, Literal, Group, TokenTree}; use proc_macro2::{Delimiter, Ident, Literal, Group, TokenTree};
use lalrpop_util::ParseError; use lalrpop_util::ParseError;
use span; use crate::span;
grammar; grammar;

View File

@ -1,12 +1,12 @@
use proc_macro2::{Delimiter, Group, Ident, Literal, Span, TokenStream, TokenTree}; use proc_macro2::{Delimiter, Group, Ident, Literal, Span, TokenStream, TokenTree};
use quote::{quote, quote_spanned}; use quote::{quote, quote_spanned};
use config::required_children; use crate::config::required_children;
use error::ParseError; use crate::error::ParseError;
use ident; use crate::ident;
use lexer::{to_stream, Lexer, Token}; use crate::lexer::{to_stream, Lexer, Token};
use map::StringyMap; use crate::map::StringyMap;
use parser::grammar; use crate::parser::grammar;
use std::iter::FromIterator; use std::iter::FromIterator;

View File

@ -1,4 +1,4 @@
use error::HtmlParseError; use crate::error::HtmlParseError;
use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, Span, TokenStream, TokenTree}; use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, Span, TokenStream, TokenTree};
use std::iter::FromIterator; use std::iter::FromIterator;

View File

@ -1,6 +1,7 @@
[package] [package]
name = "typed-html" name = "typed-html"
version = "0.1.1" version = "0.1.1"
edition = "2018"
authors = ["Bodil Stokke <bodil@bodil.org>"] authors = ["Bodil Stokke <bodil@bodil.org>"]
license = "MPL-2.0+" license = "MPL-2.0+"
description = "Type checked JSX for Rust" description = "Type checked JSX for Rust"

View File

@ -3,8 +3,8 @@
use std::fmt::Display; use std::fmt::Display;
use std::marker::PhantomData; use std::marker::PhantomData;
use super::OutputType; use crate::OutputType;
use elements::{FlowContent, PhrasingContent}; use crate::elements::{FlowContent, PhrasingContent};
use htmlescape::encode_minimal; use htmlescape::encode_minimal;
/// A boxed DOM tree, as returned from the `html!` macro. /// A boxed DOM tree, as returned from the `html!` macro.

View File

@ -4,9 +4,9 @@
use typed_html_macros::declare_elements; use typed_html_macros::declare_elements;
use super::OutputType; use crate::OutputType;
use dom::{Node, TextNode}; use crate::dom::{Node, TextNode};
use types::*; use crate::types::*;
// Marker traits for element content groups // Marker traits for element content groups

View File

@ -1,6 +1,6 @@
//! Event handlers. //! Event handlers.
use super::OutputType; use crate::OutputType;
use htmlescape::encode_attribute; use htmlescape::encode_attribute;
use std::fmt::{Display, Error, Formatter}; use std::fmt::{Display, Error, Formatter};

View File

@ -191,19 +191,7 @@
//! [Into::into]: https://doc.rust-lang.org/std/convert/trait.Into.html#method.into //! [Into::into]: https://doc.rust-lang.org/std/convert/trait.Into.html#method.into
//! [DOMTree]: dom/type.DOMTree.html //! [DOMTree]: dom/type.DOMTree.html
#[macro_use]
extern crate strum_macros;
pub extern crate htmlescape; pub extern crate htmlescape;
extern crate language_tags;
extern crate mime;
extern crate proc_macro_hack;
extern crate proc_macro_nested;
extern crate strum;
extern crate typed_html_macros;
#[cfg(feature = "stdweb")]
extern crate stdweb;
use proc_macro_hack::proc_macro_hack; use proc_macro_hack::proc_macro_hack;
use std::fmt::Display; use std::fmt::Display;

View File

@ -4,9 +4,9 @@ use std::marker::PhantomData;
use stdweb::web::event::*; use stdweb::web::event::*;
use stdweb::web::{self, Element, EventListenerHandle, IElement, IEventTarget, INode}; use stdweb::web::{self, Element, EventListenerHandle, IElement, IEventTarget, INode};
use super::super::OutputType; use crate::OutputType;
use dom::VNode; use crate::dom::VNode;
use events::{EventHandler, IntoEventHandler}; use crate::events::{EventHandler, IntoEventHandler};
/// DOM output using the stdweb crate /// DOM output using the stdweb crate
pub struct Stdweb; pub struct Stdweb;

View File

@ -1,5 +1,7 @@
//! Types for attribute values. //! Types for attribute values.
use strum_macros::*;
mod class; mod class;
pub use self::class::Class; pub use self::class::Class;

View File

@ -1,6 +1,7 @@
[package] [package]
name = "typed-html-tests" name = "typed-html-tests"
version = "0.0.0" version = "0.0.0"
edition = "2018"
authors = ["Bodil Stokke <bodil@bodil.org>"] authors = ["Bodil Stokke <bodil@bodil.org>"]
publish = false publish = false