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
Cargo.lock

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
//! Event handlers.
use super::OutputType;
use crate::OutputType;
use htmlescape::encode_attribute;
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
//! [DOMTree]: dom/type.DOMTree.html
#[macro_use]
extern crate strum_macros;
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 std::fmt::Display;

View File

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

View File

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

View File

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