summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/main.rs2
-rw-r--r--src/export/pdf.rs1
-rw-r--r--src/func/macros.rs2
-rw-r--r--src/func/mod.rs2
-rw-r--r--src/layout/actions.rs1
-rw-r--r--src/layout/line.rs3
-rw-r--r--src/layout/mod.rs1
-rw-r--r--src/layout/stack.rs1
-rw-r--r--src/layout/text.rs1
-rw-r--r--src/layout/tree.rs3
-rw-r--r--src/lib.rs3
-rw-r--r--src/library/maps/alignment.rs1
-rw-r--r--src/library/maps/axis.rs1
-rw-r--r--src/library/maps/mod.rs1
-rw-r--r--src/library/maps/padding.rs1
-rw-r--r--src/library/mod.rs6
-rw-r--r--src/macros.rs11
-rw-r--r--src/size.rs1
-rw-r--r--src/syntax/mod.rs1
-rw-r--r--src/syntax/parsing.rs1
-rw-r--r--src/syntax/span.rs1
-rw-r--r--src/syntax/tokens.rs1
22 files changed, 27 insertions, 19 deletions
diff --git a/src/bin/main.rs b/src/bin/main.rs
index f86336bb..231ac487 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -1,13 +1,13 @@
use std::fs::{File, read_to_string};
use std::io::BufWriter;
use std::path::{Path, PathBuf};
-
use futures_executor::block_on;
use typstc::Typesetter;
use typstc::toddle::query::FileSystemFontProvider;
use typstc::export::pdf::PdfExporter;
+
fn main() {
if let Err(err) = run() {
eprintln!("error: {}", err);
diff --git a/src/export/pdf.rs b/src/export/pdf.rs
index c5bc6ee8..c4020e10 100644
--- a/src/export/pdf.rs
+++ b/src/export/pdf.rs
@@ -22,6 +22,7 @@ use toddle::tables::{
use crate::layout::{MultiLayout, Layout, LayoutAction};
use crate::size::Size;
+
/// Exports layouts into _PDFs_.
pub struct PdfExporter {}
diff --git a/src/func/macros.rs b/src/func/macros.rs
index a89156b7..bbe04b98 100644
--- a/src/func/macros.rs
+++ b/src/func/macros.rs
@@ -1,5 +1,6 @@
//! Helper types and macros for creating custom functions.
+
/// Defines function types concisely.
#[macro_export]
macro_rules! function {
@@ -121,6 +122,7 @@ macro_rules! function {
'life1: 'async_trait,
Self: 'async_trait,
{
+ #[allow(unreachable_code)]
Box::pin(async move { Ok($code) })
}
}
diff --git a/src/func/mod.rs b/src/func/mod.rs
index a0875cf9..31f03c55 100644
--- a/src/func/mod.rs
+++ b/src/func/mod.rs
@@ -3,8 +3,8 @@
use std::any::Any;
use std::collections::HashMap;
use std::fmt::{self, Debug, Formatter};
-
use async_trait::async_trait;
+
use self::prelude::*;
#[macro_use]
diff --git a/src/layout/actions.rs b/src/layout/actions.rs
index 4ab9fdb1..1bf5d684 100644
--- a/src/layout/actions.rs
+++ b/src/layout/actions.rs
@@ -6,6 +6,7 @@ use toddle::query::FontIndex;
use super::*;
use LayoutAction::*;
+
/// A layouting action.
#[derive(Clone)]
pub enum LayoutAction {
diff --git a/src/layout/line.rs b/src/layout/line.rs
index 8f487319..c4205e81 100644
--- a/src/layout/line.rs
+++ b/src/layout/line.rs
@@ -1,5 +1,6 @@
use super::*;
+
/// The line layouter arranges boxes next to each other along a primary axis
/// and arranges the resulting lines using an underlying stack layouter.
#[derive(Debug, Clone)]
@@ -181,7 +182,7 @@ impl LineLayouter {
/// Finish the run and add secondary spacing to the underlying stack.
pub fn add_secondary_spacing(
&mut self,
- mut spacing: Size,
+ spacing: Size,
kind: SpacingKind
) -> LayoutResult<()> {
self.finish_line_if_not_empty()?;
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index be1ed43c..49551945 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -39,6 +39,7 @@ pub use self::actions::{LayoutAction, LayoutActions};
pub use self::layouters::*;
pub use self::prelude::*;
+
/// The result type for layouting.
pub type LayoutResult<T> = crate::TypesetResult<T>;
diff --git a/src/layout/stack.rs b/src/layout/stack.rs
index e0562672..80d57424 100644
--- a/src/layout/stack.rs
+++ b/src/layout/stack.rs
@@ -2,6 +2,7 @@ use smallvec::smallvec;
use crate::size::ValueBox;
use super::*;
+
/// The stack layouter stack boxes onto each other along the secondary layouting
/// axis.
#[derive(Debug, Clone)]
diff --git a/src/layout/text.rs b/src/layout/text.rs
index 2fdb3f6d..a66e04a2 100644
--- a/src/layout/text.rs
+++ b/src/layout/text.rs
@@ -5,6 +5,7 @@ use crate::size::{Size, Size2D};
use crate::style::TextStyle;
use super::*;
+
/// The context for text layouting.
///
/// See [`LayoutContext`] for details about the fields.
diff --git a/src/layout/tree.rs b/src/layout/tree.rs
index f645a35d..238c45fc 100644
--- a/src/layout/tree.rs
+++ b/src/layout/tree.rs
@@ -4,7 +4,6 @@ use smallvec::smallvec;
use crate::func::Command;
use crate::syntax::{SyntaxTree, Node, FuncCall};
-use crate::style::TextStyle;
use super::*;
@@ -148,7 +147,7 @@ impl<'a, 'p> TreeLayouter<'a, 'p> {
}
SetAlignment(alignment) => self.ctx.alignment = alignment,
SetAxes(axes) => {
- self.layouter.set_axes(axes);
+ self.layouter.set_axes(axes)?;
self.ctx.axes = axes;
}
}
diff --git a/src/lib.rs b/src/lib.rs
index 7975ff7d..ffd464fe 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -16,7 +16,7 @@
//! format is _PDF_. Alternatively, the layout can be serialized to pass it to
//! a suitable renderer.
-#![allow(unused)]
+// #![allow(unused)]
pub extern crate toddle;
@@ -42,6 +42,7 @@ pub mod syntax;
pub mod size;
pub mod style;
+
/// Transforms source code into typesetted layouts.
///
/// A typesetter can be configured through various methods.
diff --git a/src/library/maps/alignment.rs b/src/library/maps/alignment.rs
index 486c8b2e..8654e280 100644
--- a/src/library/maps/alignment.rs
+++ b/src/library/maps/alignment.rs
@@ -1,6 +1,7 @@
use super::*;
use AlignmentKey::*;
+
/// An argument key which describes a target alignment.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum AlignmentKey {
diff --git a/src/library/maps/axis.rs b/src/library/maps/axis.rs
index ca306eab..238d146a 100644
--- a/src/library/maps/axis.rs
+++ b/src/library/maps/axis.rs
@@ -1,6 +1,7 @@
use super::*;
use AxisKey::*;
+
/// An argument key which identifies a layouting axis.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum AxisKey {
diff --git a/src/library/maps/mod.rs b/src/library/maps/mod.rs
index 5b027824..5e130d53 100644
--- a/src/library/maps/mod.rs
+++ b/src/library/maps/mod.rs
@@ -5,6 +5,7 @@ use std::hash::Hash;
use crate::func::prelude::*;
+
macro_rules! key {
($type:ty, $name:expr, $($patterns:tt)*) => {
impl $type {
diff --git a/src/library/maps/padding.rs b/src/library/maps/padding.rs
index 3da469a7..4bbbb754 100644
--- a/src/library/maps/padding.rs
+++ b/src/library/maps/padding.rs
@@ -3,6 +3,7 @@ use AxisKey::*;
use AlignmentKey::*;
use PaddingKey::*;
+
/// An argument key which identifies a margin or padding target.
///
/// A is the used axis type.
diff --git a/src/library/mod.rs b/src/library/mod.rs
index 513590eb..333ba02a 100644
--- a/src/library/mod.rs
+++ b/src/library/mod.rs
@@ -58,7 +58,7 @@ function! {
list: Vec<String>,
}
- parse(args, body, ctx, meta) {
+ parse(args, body, ctx) {
FontFamilyFunc {
body: parse!(optional: body, ctx),
list: {
@@ -114,7 +114,7 @@ function! {
weight: FontWeight,
}
- parse(args, body, ctx, meta) {
+ parse(args, body, ctx) {
FontWeightFunc {
body: parse!(optional: body, ctx),
weight: match args.get_pos::<Expression>()? {
@@ -195,7 +195,7 @@ function! {
}
}
- layout(self, mut ctx) {
+ layout(self, ctx) {
let mut style = ctx.style.text.clone();
match self.content {
ContentKind::Word => style.word_spacing_scale = self.spacing,
diff --git a/src/macros.rs b/src/macros.rs
index ebe1cad7..5d413870 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -1,5 +1,6 @@
//! Auxiliary macros.
+
/// Create trait implementations for an error type.
macro_rules! error_type {
(
@@ -36,16 +37,6 @@ macro_rules! error_type {
};
}
-/// Shorthand for checking whether an expression matches a pattern.
-macro_rules! matches {
- ($expr:expr, $($pattern:tt)*) => {
- match $expr {
- $($pattern)* => true,
- _ => false,
- }
- };
-}
-
/// Create a `Debug` implementation from a `Display` implementation.
macro_rules! debug_display {
($type:ident) => (
diff --git a/src/size.rs b/src/size.rs
index 04eabf39..5b84c2ad 100644
--- a/src/size.rs
+++ b/src/size.rs
@@ -7,6 +7,7 @@ use std::str::FromStr;
use crate::layout::prelude::*;
+
/// A general spacing type.
#[derive(Default, Copy, Clone, PartialEq, PartialOrd)]
pub struct Size {
diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs
index 193810c0..cb801627 100644
--- a/src/syntax/mod.rs
+++ b/src/syntax/mod.rs
@@ -10,6 +10,7 @@ pub_use_mod!(tokens);
pub_use_mod!(parsing);
pub_use_mod!(span);
+
/// A logical unit of the incoming text stream.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum Token<'s> {
diff --git a/src/syntax/parsing.rs b/src/syntax/parsing.rs
index 6eed2235..2f061372 100644
--- a/src/syntax/parsing.rs
+++ b/src/syntax/parsing.rs
@@ -4,6 +4,7 @@ use crate::func::Scope;
use crate::size::Size;
use super::*;
+
/// The result type for parsing.
pub type ParseResult<T> = crate::TypesetResult<T>;
diff --git a/src/syntax/span.rs b/src/syntax/span.rs
index 9e018437..3f752385 100644
--- a/src/syntax/span.rs
+++ b/src/syntax/span.rs
@@ -2,6 +2,7 @@
use std::fmt::{self, Display, Formatter};
+
/// Annotates a value with the part of the source code it corresponds to.
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Spanned<T> {
diff --git a/src/syntax/tokens.rs b/src/syntax/tokens.rs
index 85e89be4..f5854d8f 100644
--- a/src/syntax/tokens.rs
+++ b/src/syntax/tokens.rs
@@ -5,6 +5,7 @@ use smallvec::SmallVec;
use super::*;
+
/// Builds an iterator over the tokens of the source code.
pub fn tokenize(src: &str) -> Tokens {
Tokens::new(src)