From 7218892c722ca583297c0ebbda350bdf6f16d3ce Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 1 Jun 2021 12:46:01 +0200 Subject: Refactor path handling --- src/lib.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/lib.rs') 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> { 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); -- cgit v1.2.3