diff --git a/src/doc.rs b/src/doc.rs index 08fd30d85..dcc4ae25e 100644 --- a/src/doc.rs +++ b/src/doc.rs @@ -1,5 +1,7 @@ //! Generation of abstract documents from syntax trees. +#![allow(dead_code)] + use std::fmt; use crate::parsing::{SyntaxTree, Node}; @@ -39,7 +41,7 @@ pub struct Text(pub String); #[derive(Debug, Copy, Clone, PartialEq)] pub struct Size { /// The size in typographic points (1/72 inches). - pub points: f32, + points: f32, } impl Size { @@ -112,7 +114,7 @@ type GenResult = std::result::Result; #[derive(Debug, Clone, Eq, PartialEq)] pub struct GenerationError { /// A message describing the error. - pub message: String, + message: String, } impl fmt::Display for GenerationError { diff --git a/src/lib.rs b/src/lib.rs index d50c19f96..924d75e42 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,13 @@ -//! Typeset is a library for compiling _plain-text_ strings written in the -//! corresponding typesetting language into a typesetted document in a -//! file format like _PDF_. - -#![allow(unused)] +//! Typeset is a library for compiling documents written in the +//! corresponding typesetting language into a typesetted document in an +//! output format like _PDF_. +mod pdf; +mod utility; pub mod parsing; pub mod doc; -pub mod pdf; -pub mod utility; + +/// Writing of documents into supported formats. +pub mod export { + pub use crate::pdf::WritePdf; +} diff --git a/src/parsing.rs b/src/parsing.rs index 5efa69e5e..1ed1ed9d5 100644 --- a/src/parsing.rs +++ b/src/parsing.rs @@ -322,7 +322,7 @@ type ParseResult = std::result::Result; #[derive(Debug, Clone, Eq, PartialEq)] pub struct ParseError { /// A message describing the error. - pub message: String, + message: String, } impl fmt::Display for ParseError { @@ -590,7 +590,7 @@ mod token_tests { #[cfg(test)] mod parse_tests { use super::*; - use Node::{Space as S, Newline as N, Word as W, Func as F}; + use Node::{Space as S, Word as W, Func as F}; /// Test if the source code parses into the syntax tree. fn test(src: &str, tree: SyntaxTree) { diff --git a/src/pdf.rs b/src/pdf.rs index 09a4b7d83..4395cb7a2 100644 --- a/src/pdf.rs +++ b/src/pdf.rs @@ -45,22 +45,22 @@ impl WritePdf for W { kids: (pages_start .. pages_end).collect(), data: PageData { resources: Some(vec![Resource::Font(1, font_start)]), - .. PageData::default() + .. PageData::none() }, })?; // The page objects let mut id = pages_start; for page in &doc.pages { - let width = page.size[0].points; - let height = page.size[1].points; + let width = page.size[0].to_points(); + let height = page.size[1].to_points(); writer.write_obj(id, &Page { parent: page_tree_id, data: PageData { media_box: Some(Rect::new(0.0, 0.0, width, height)), contents: Some((content_start .. content_end).collect()), - .. PageData::default() + .. PageData::none() }, })?; @@ -78,12 +78,12 @@ impl WritePdf for W { for content in &page.contents { let string = &content.0; - let mut text = Text::new(); - text.set_font(1, 13.0) + writer.write_obj(id, &Text::new() + .set_font(1, 13.0) .move_pos(108.0, 734.0) - .write_str(&string); - - writer.write_obj(id, &text.as_stream())?; + .write_str(&string) + .to_stream() + )?; id += 1; } } diff --git a/src/utility.rs b/src/utility.rs index 8304025d0..a0e6a2958 100644 --- a/src/utility.rs +++ b/src/utility.rs @@ -12,8 +12,7 @@ pub trait Splinor { /// /// # Example /// - /// ``` - /// # use typeset::utility::*; + /// ```ignore /// #[derive(Debug, Copy, Clone, PartialEq)] /// struct Space; ///