summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-06-01 12:46:01 +0200
committerLaurenz <laurmaedje@gmail.com>2021-06-01 12:55:07 +0200
commit7218892c722ca583297c0ebbda350bdf6f16d3ce (patch)
tree27ebbfaf0662c1e0dd01e7c5e9e360ab288cae4d /src/lib.rs
parent9bdb0bdeffa5e4b6da9e3f6d3c1b79c506005fc5 (diff)
Refactor path handling
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 65e23c79..3c50230f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -59,16 +59,33 @@ use crate::layout::Frame;
use crate::loading::Loader;
/// Process source code directly into a collection of layouted frames.
+///
+/// # Parameters
+/// - The `loader` is used to load fonts, images and other source files.
+/// - The `cache` stores things that are reusable across several compilations
+/// like loaded fonts, decoded images and layouting artifacts.
+/// - The `path` should point to the source file if `src` comes from the file
+/// system and is used to resolve relative paths (for importing and image
+/// loading).
+/// - The `src` is the _Typst_ source code to typeset.
+/// - The `scope` contains definitions that are available everywhere,
+/// typically the standard library.
+/// - The `state` defines initial properties for page size, font selection and
+/// so on.
+///
+/// # Return value
+/// Returns a vector of frames representing individual pages alongside
+/// diagnostic information (errors and warnings).
pub fn typeset(
loader: &mut dyn Loader,
cache: &mut Cache,
- path: &Path,
+ path: Option<&Path>,
src: &str,
- base: &Scope,
+ scope: &Scope,
state: State,
) -> Pass<Vec<Frame>> {
let parsed = parse::parse(src);
- let evaluated = eval::eval(loader, cache, path, Rc::new(parsed.output), base);
+ let evaluated = eval::eval(loader, cache, path, Rc::new(parsed.output), scope);
let executed = exec::exec(&evaluated.output.template, state);
let layouted = layout::layout(loader, cache, &executed.output);