From a7b403fd742941f6b163f06876aec96729db707f Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 2 Feb 2022 16:02:23 +0100 Subject: Rename `Node` to `Template` --- src/eval/class.rs | 20 +- src/eval/mod.rs | 94 +++++----- src/eval/node.rs | 507 --------------------------------------------------- src/eval/ops.rs | 22 +-- src/eval/styles.rs | 32 ++-- src/eval/template.rs | 506 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/eval/value.rs | 34 ++-- 7 files changed, 606 insertions(+), 609 deletions(-) delete mode 100644 src/eval/node.rs create mode 100644 src/eval/template.rs (limited to 'src/eval') diff --git a/src/eval/class.rs b/src/eval/class.rs index 91a9daef..4307eecb 100644 --- a/src/eval/class.rs +++ b/src/eval/class.rs @@ -1,15 +1,15 @@ use std::fmt::{self, Debug, Formatter, Write}; -use super::{Args, EvalContext, Func, Node, StyleMap, Value}; +use super::{Args, EvalContext, Func, StyleMap, Template, Value}; use crate::diag::TypResult; -/// A class of [nodes](Node). +/// A class of nodes. /// /// You can [construct] an instance of a class in Typst code by invoking the -/// class as a callable. This always produces some node, but not necessarily one -/// of fixed type. For example, the `text` constructor does not actually create -/// a [`TextNode`]. Instead it applies styling to whatever node you pass in and -/// returns it structurally unchanged. +/// class as a callable. This always produces a template, but not necessarily a +/// simple inline or block node. For example, the `text` constructor does not +/// actually create a [`TextNode`]. Instead it applies styling to whatever node +/// you pass in and returns it structurally unchanged. /// /// The arguments you can pass to a class constructor fall into two categories: /// Data that is inherent to the instance (e.g. the text of a heading) and style @@ -50,8 +50,8 @@ impl Class { construct: |ctx, args| { let mut styles = StyleMap::new(); T::set(args, &mut styles)?; - let node = T::construct(ctx, args)?; - Ok(Value::Node(node.styled_with_map(styles.scoped()))) + let template = T::construct(ctx, args)?; + Ok(Value::Template(template.styled_with_map(styles.scoped()))) }, set: T::set, } @@ -65,7 +65,7 @@ impl Class { /// Construct an instance of the class. /// /// This parses both property and data arguments (in this order) and styles - /// the node constructed from the data with the style properties. + /// the template constructed from the data with the style properties. pub fn construct(&self, ctx: &mut EvalContext, args: &mut Args) -> TypResult { (self.construct)(ctx, args) } @@ -104,7 +104,7 @@ pub trait Construct { /// /// This is passed only the arguments that remain after execution of the /// class's set rule. - fn construct(ctx: &mut EvalContext, args: &mut Args) -> TypResult; + fn construct(ctx: &mut EvalContext, args: &mut Args) -> TypResult