diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-12-02 13:37:33 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2024-12-04 10:12:07 +0100 |
| commit | f8f2ba6a5f8c8ca7dbb85cf17b73332a0c301c60 (patch) | |
| tree | b3bc754509fb3ab4c74493848fe96f116b7907ed /crates/typst-library/src | |
| parent | 76c24ee6e35715cd14bb892d7b6b8d775c680bf7 (diff) | |
Rename `Document` to `PagedDocument`
Diffstat (limited to 'crates/typst-library/src')
| -rw-r--r-- | crates/typst-library/src/layout/page.rs | 25 | ||||
| -rw-r--r-- | crates/typst-library/src/model/document.rs | 24 | ||||
| -rw-r--r-- | crates/typst-library/src/routines.rs | 7 |
3 files changed, 28 insertions, 28 deletions
diff --git a/crates/typst-library/src/layout/page.rs b/crates/typst-library/src/layout/page.rs index 09aafa7f..68fd8974 100644 --- a/crates/typst-library/src/layout/page.rs +++ b/crates/typst-library/src/layout/page.rs @@ -12,11 +12,12 @@ use crate::foundations::{ cast, elem, Args, AutoValue, Cast, Construct, Content, Context, Dict, Fold, Func, NativeElement, Set, Smart, StyleChain, Value, }; +use crate::introspection::Introspector; use crate::layout::{ Abs, Alignment, FlushElem, Frame, HAlignment, Length, OuterVAlignment, Ratio, Rel, Sides, SpecificAlignment, }; -use crate::model::Numbering; +use crate::model::{DocumentInfo, Numbering}; use crate::text::LocalName; use crate::visualize::{Color, Paint}; @@ -451,6 +452,17 @@ impl PagebreakElem { } } +/// A finished document with metadata and page frames. +#[derive(Debug, Default, Clone)] +pub struct PagedDocument { + /// The document's finished pages. + pub pages: Vec<Page>, + /// Details about the document. + pub info: DocumentInfo, + /// Provides the ability to execute queries on the document. + pub introspector: Introspector, +} + /// A finished page. #[derive(Debug, Clone)] pub struct Page { @@ -942,3 +954,14 @@ papers! { (PRESENTATION_16_9: 297.0, 167.0625, "presentation-16-9") (PRESENTATION_4_3: 280.0, 210.0, "presentation-4-3") } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_paged_document_is_send_and_sync() { + fn ensure_send_and_sync<T: Send + Sync>() {} + ensure_send_and_sync::<PagedDocument>(); + } +} diff --git a/crates/typst-library/src/model/document.rs b/crates/typst-library/src/model/document.rs index b693d785..c333dff3 100644 --- a/crates/typst-library/src/model/document.rs +++ b/crates/typst-library/src/model/document.rs @@ -6,8 +6,6 @@ use crate::foundations::{ cast, elem, Args, Array, Construct, Content, Datetime, Fields, Smart, StyleChain, Styles, Value, }; -use crate::introspection::Introspector; -use crate::layout::Page; /// The root element of a document and its metadata. /// @@ -86,17 +84,6 @@ cast! { v: Array => Self(v.into_iter().map(Value::cast).collect::<HintedStrResult<_>>()?), } -/// A finished document with metadata and page frames. -#[derive(Debug, Default, Clone)] -pub struct Document { - /// The document's finished pages. - pub pages: Vec<Page>, - /// Details about the document. - pub info: DocumentInfo, - /// Provides the ability to execute queries on the document. - pub introspector: Introspector, -} - /// Details about the document. #[derive(Debug, Default, Clone, PartialEq, Hash)] pub struct DocumentInfo { @@ -132,14 +119,3 @@ impl DocumentInfo { } } } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_document_is_send_and_sync() { - fn ensure_send_and_sync<T: Send + Sync>() {} - ensure_send_and_sync::<Document>(); - } -} diff --git a/crates/typst-library/src/routines.rs b/crates/typst-library/src/routines.rs index 6b78b7fb..000b3bba 100644 --- a/crates/typst-library/src/routines.rs +++ b/crates/typst-library/src/routines.rs @@ -16,10 +16,11 @@ use crate::foundations::{ use crate::introspection::{Introspector, Locator, SplitLocator}; use crate::layout::{ Abs, BoxElem, ColumnsElem, Fragment, Frame, GridElem, InlineItem, MoveElem, PadElem, - Region, Regions, Rel, RepeatElem, RotateElem, ScaleElem, Size, SkewElem, StackElem, + PagedDocument, Region, Regions, Rel, RepeatElem, RotateElem, ScaleElem, Size, + SkewElem, StackElem, }; use crate::math::EquationElem; -use crate::model::{Document, DocumentInfo, EnumElem, ListElem, TableElem}; +use crate::model::{DocumentInfo, EnumElem, ListElem, TableElem}; use crate::visualize::{ CircleElem, EllipseElem, ImageElem, LineElem, PathElem, PolygonElem, RectElem, SquareElem, @@ -90,7 +91,7 @@ routines! { engine: &mut Engine, content: &Content, styles: StyleChain, - ) -> SourceResult<Document> + ) -> SourceResult<PagedDocument> /// Lays out content into multiple regions. fn layout_fragment( |
