From 6d995f698f580aba9e67b847432899ce841e6e7d Mon Sep 17 00:00:00 2001 From: Philipp A Date: Mon, 10 Dec 2018 09:38:31 +0100 Subject: document conversion --- src/document_tree/attribute_types.rs | 14 +++++++------- src/document_tree/element_categories.rs | 3 +-- src/document_tree/elements.rs | 6 +++--- src/document_tree/extra_attributes.rs | 4 ++-- 4 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src/document_tree') diff --git a/src/document_tree/attribute_types.rs b/src/document_tree/attribute_types.rs index ba631d9..400c59e 100644 --- a/src/document_tree/attribute_types.rs +++ b/src/document_tree/attribute_types.rs @@ -4,7 +4,7 @@ use failure::{Error,bail,format_err}; use serde_derive::Serialize; use regex::Regex; -#[derive(Debug,Serialize)] +#[derive(Debug,PartialEq,Serialize)] pub enum EnumeratedListType { Arabic, LowerAlpha, @@ -13,17 +13,17 @@ pub enum EnumeratedListType { UpperRoman, } -#[derive(Debug,Serialize)] +#[derive(Debug,PartialEq,Serialize)] pub enum FixedSpace { Default, Preserve } // yes, default really is not “Default” impl Default for FixedSpace { fn default() -> FixedSpace { FixedSpace::Preserve } } -#[derive(Debug,Serialize)] pub enum AlignH { Left, Center, Right} -#[derive(Debug,Serialize)] pub enum AlignHV { Top, Middle, Bottom, Left, Center, Right } +#[derive(Debug,PartialEq,Serialize)] pub enum AlignH { Left, Center, Right} +#[derive(Debug,PartialEq,Serialize)] pub enum AlignHV { Top, Middle, Bottom, Left, Center, Right } -#[derive(Debug,Serialize)] pub struct ID(pub String); -#[derive(Debug,Serialize)] pub struct NameToken(pub String); +#[derive(Debug,PartialEq,Serialize)] pub struct ID(pub String); +#[derive(Debug,PartialEq,Serialize)] pub struct NameToken(pub String); -#[derive(Debug,Serialize)] +#[derive(Debug,PartialEq,Serialize)] pub enum Measure { // http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#length-units Em(f64), Ex(f64), diff --git a/src/document_tree/element_categories.rs b/src/document_tree/element_categories.rs index ec53f09..f3ac884 100644 --- a/src/document_tree/element_categories.rs +++ b/src/document_tree/element_categories.rs @@ -43,7 +43,7 @@ macro_rules! synonymous_enum { cartesian!(impl_into, [ $( ($subcat::$entry) ),+ ], [ $($supcat),+ ]); }; ( $name:ident { $( $entry:ident ),+ $(,)* } ) => { - #[derive(Serialize)] + #[derive(PartialEq,Serialize)] pub enum $name { $( $entry(Box<$entry>), )* } @@ -87,7 +87,6 @@ synonymous_enum!(TextOrInlineElement { //Content Models\\ //--------------\\ -synonymous_enum!(SubSection { Title, Subtitle, Docinfo, Decoration, SubStructure }); synonymous_enum!(AuthorInfo { Author, Organization, Address, Contact }); synonymous_enum!(DecorationElement { Header, Footer }); synonymous_enum!(SubTopic { Title, BodyElement }); diff --git a/src/document_tree/elements.rs b/src/document_tree/elements.rs index 72f10e8..52b1f5b 100644 --- a/src/document_tree/elements.rs +++ b/src/document_tree/elements.rs @@ -26,7 +26,7 @@ pub trait Element { fn classes_mut(&mut self) -> &mut Vec; } -#[derive(Debug,Default,Serialize)] +#[derive(Debug,Default,PartialEq,Serialize)] pub struct CommonAttributes { ids: Vec, names: Vec, @@ -78,7 +78,7 @@ macro_rules! impl_new {( ),* $(,)* } ) => ( $(#[$attr])* - #[derive(Debug,Serialize)] + #[derive(Debug,PartialEq,Serialize)] pub struct $name { $( $(#[$fattr])* $field: $typ, )* } @@ -136,7 +136,7 @@ impl_children!(Document, StructuralSubElement); impl_elems!( //structual elements - (Section, SubSection) + (Section, StructuralSubElement) (Topic, SubTopic) (Sidebar, SubSidebar) diff --git a/src/document_tree/extra_attributes.rs b/src/document_tree/extra_attributes.rs index 58a1e94..0708080 100644 --- a/src/document_tree/extra_attributes.rs +++ b/src/document_tree/extra_attributes.rs @@ -20,7 +20,7 @@ macro_rules! skip { macro_rules! impl_extra { ( $name:ident { $( $(#[$pattr:meta])* $param:ident : $type:ty ),* $(,)* } ) => ( impl_extra!( - #[derive(Default,Debug,Serialize)] + #[derive(Default,Debug,PartialEq,Serialize)] $name { $( $(#[$pattr])* $param : $type, )* } ); ); @@ -49,7 +49,7 @@ impl_extra!(Target { anonymous: bool, }); impl_extra!(Raw { space: FixedSpace, format: Vec }); -impl_extra!(#[derive(Debug,Serialize)] Image { +impl_extra!(#[derive(Debug,PartialEq,Serialize)] Image { uri: target::Target, align: Option, alt: Option, -- cgit v1.2.3