summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 8742aeb8..c435c2dd 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,9 +6,8 @@
//! tree]. The structures describing the tree can be found in the [syntax]
//! module.
//! - **Evaluation:** The next step is to [evaluate] the syntax tree. This
-//! computes the value of each node in document and stores them in a map from
-//! node-pointers to values.
-//! - **Execution:** Now, we can [execute] the parsed and evaluated "script".
+//! computes the value of each node in the document and produces a [module].
+//! - **Execution:** Now, we can [execute] the parsed and evaluated module.
//! This produces a [layout tree], a high-level, fully styled representation
//! of the document. The nodes of this tree are self-contained and
//! order-independent and thus much better suited for layouting than the
@@ -23,10 +22,11 @@
//! [parsed]: parse::parse
//! [syntax tree]: syntax::Tree
//! [evaluate]: eval::eval
+//! [module]: eval::Module
//! [execute]: exec::exec
//! [layout tree]: layout::Tree
//! [layouted]: layout::layout
-//! [PDF]: pdf
+//! [PDF]: export::pdf
#[macro_use]
pub mod diag;
@@ -34,42 +34,45 @@ pub mod diag;
pub mod eval;
pub mod cache;
pub mod color;
-pub mod env;
pub mod exec;
+pub mod export;
pub mod font;
pub mod geom;
+pub mod image;
pub mod layout;
pub mod library;
+pub mod loading;
pub mod paper;
pub mod parse;
-pub mod pdf;
pub mod pretty;
pub mod syntax;
pub mod util;
+use std::rc::Rc;
+
use crate::cache::Cache;
use crate::diag::Pass;
-use crate::env::Env;
use crate::eval::Scope;
use crate::exec::State;
use crate::layout::Frame;
+use crate::loading::Loader;
-/// Process source code directly into a collection of frames.
+/// Process source code directly into a collection of layouted frames.
pub fn typeset(
- env: &mut Env,
+ loader: &mut dyn Loader,
cache: &mut Cache,
src: &str,
- scope: &Scope,
+ base: &Scope,
state: State,
) -> Pass<Vec<Frame>> {
let parsed = parse::parse(src);
- let evaluated = eval::eval(env, &parsed.output, scope);
- let executed = exec::exec(env, &parsed.output, &evaluated.output, state);
- let frames = layout::layout(env, cache, &executed.output);
+ let evaluated = eval::eval(loader, cache, Rc::new(parsed.output), base);
+ let executed = exec::exec(&evaluated.output.template, state);
+ let layouted = layout::layout(loader, cache, &executed.output);
let mut diags = parsed.diags;
diags.extend(evaluated.diags);
diags.extend(executed.diags);
- Pass::new(frames, diags)
+ Pass::new(layouted, diags)
}