From a7b403fd742941f6b163f06876aec96729db707f Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 2 Feb 2022 16:02:23 +0100 Subject: [PATCH] Rename `Node` to `Template` --- macros/src/lib.rs | 2 +- src/eval/class.rs | 20 +++--- src/eval/mod.rs | 94 +++++++++++++------------- src/eval/ops.rs | 22 +++--- src/eval/styles.rs | 32 ++++----- src/eval/{node.rs => template.rs} | 109 +++++++++++++++--------------- src/eval/value.rs | 34 +++++----- src/layout/mod.rs | 2 +- src/lib.rs | 19 +++--- src/library/align.rs | 4 +- src/library/columns.rs | 10 +-- src/library/container.rs | 8 +-- src/library/deco.rs | 4 +- src/library/flow.rs | 4 +- src/library/grid.rs | 6 +- src/library/heading.rs | 4 +- src/library/hide.rs | 6 +- src/library/image.rs | 6 +- src/library/link.rs | 4 +- src/library/list.rs | 6 +- src/library/mod.rs | 6 +- src/library/pad.rs | 6 +- src/library/page.rs | 8 +-- src/library/par.rs | 20 +++--- src/library/place.rs | 6 +- src/library/shape.rs | 6 +- src/library/spacing.rs | 8 +-- src/library/stack.rs | 14 ++-- src/library/table.rs | 4 +- src/library/text.rs | 10 +-- src/library/transform.rs | 6 +- 31 files changed, 244 insertions(+), 246 deletions(-) rename src/eval/{node.rs => template.rs} (84%) diff --git a/macros/src/lib.rs b/macros/src/lib.rs index b667d2e26..b2dee7c91 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -179,7 +179,7 @@ fn process_const( const NAME: &'static str = #name; - fn node_id() -> TypeId { + fn class_id() -> TypeId { TypeId::of::<#self_ty>() } diff --git a/src/eval/class.rs b/src/eval/class.rs index 91a9daefe..4307eecbd 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