diff options
Diffstat (limited to 'library/src/layout')
| -rw-r--r-- | library/src/layout/align.rs | 1 | ||||
| -rw-r--r-- | library/src/layout/columns.rs | 1 | ||||
| -rw-r--r-- | library/src/layout/container.rs | 28 | ||||
| -rw-r--r-- | library/src/layout/enum.rs | 1 | ||||
| -rw-r--r-- | library/src/layout/grid.rs | 12 | ||||
| -rw-r--r-- | library/src/layout/hide.rs | 1 | ||||
| -rw-r--r-- | library/src/layout/list.rs | 1 | ||||
| -rw-r--r-- | library/src/layout/pad.rs | 25 | ||||
| -rw-r--r-- | library/src/layout/page.rs | 11 | ||||
| -rw-r--r-- | library/src/layout/par.rs | 8 | ||||
| -rw-r--r-- | library/src/layout/place.rs | 1 | ||||
| -rw-r--r-- | library/src/layout/repeat.rs | 1 | ||||
| -rw-r--r-- | library/src/layout/spacing.rs | 34 | ||||
| -rw-r--r-- | library/src/layout/table.rs | 28 | ||||
| -rw-r--r-- | library/src/layout/terms.rs | 2 | ||||
| -rw-r--r-- | library/src/layout/transform.rs | 3 |
16 files changed, 72 insertions, 86 deletions
diff --git a/library/src/layout/align.rs b/library/src/layout/align.rs index 88815dc9..cf6d08f2 100644 --- a/library/src/layout/align.rs +++ b/library/src/layout/align.rs @@ -53,7 +53,6 @@ pub struct AlignNode { pub alignment: Axes<Option<GenAlign>>, /// The content to align. - #[positional] #[required] pub body: Content, } diff --git a/library/src/layout/columns.rs b/library/src/layout/columns.rs index 58b369c6..7704e9c4 100644 --- a/library/src/layout/columns.rs +++ b/library/src/layout/columns.rs @@ -45,7 +45,6 @@ pub struct ColumnsNode { pub gutter: Rel<Length>, /// The content that should be layouted into the columns. - #[positional] #[required] pub body: Content, } diff --git a/library/src/layout/container.rs b/library/src/layout/container.rs index 31a80aa2..009063f0 100644 --- a/library/src/layout/container.rs +++ b/library/src/layout/container.rs @@ -181,20 +181,6 @@ impl Layout for BoxNode { /// More text. /// ``` /// -/// ## Parameters -/// - spacing: `Spacing` (named, settable) -/// The spacing around this block. This is shorthand to set `above` and -/// `below` to the same value. -/// -/// ```example -/// #set align(center) -/// #show math.formula: set block(above: 8pt, below: 16pt) -/// -/// This sum of $x$ and $y$: -/// $ x + y = z $ -/// A second paragraph. -/// ``` -/// /// Display: Block /// Category: layout #[node(Layout)] @@ -270,6 +256,20 @@ pub struct BlockNode { #[fold] pub outset: Sides<Option<Rel<Length>>>, + /// The spacing around this block. This is shorthand to set `above` and + /// `below` to the same value. + /// + /// ```example + /// #set align(center) + /// #show math.formula: set block(above: 8pt, below: 16pt) + /// + /// This sum of $x$ and $y$: + /// $ x + y = z $ + /// A second paragraph. + /// ``` + #[external] + pub spacing: Spacing, + /// The spacing between this block and its predecessor. Takes precedence /// over `spacing`. Can be used in combination with a show rule to adjust /// the spacing around arbitrary block-level elements. diff --git a/library/src/layout/enum.rs b/library/src/layout/enum.rs index ee09d339..33b297e7 100644 --- a/library/src/layout/enum.rs +++ b/library/src/layout/enum.rs @@ -228,7 +228,6 @@ pub struct EnumItem { pub number: Option<NonZeroUsize>, /// The item's body. - #[positional] #[required] pub body: Content, } diff --git a/library/src/layout/grid.rs b/library/src/layout/grid.rs index 34514eac..b6e86afd 100644 --- a/library/src/layout/grid.rs +++ b/library/src/layout/grid.rs @@ -59,12 +59,6 @@ use super::Sizing; /// ) /// ``` /// -/// ## Parameters -/// - gutter: `TrackSizings` (named, settable) -/// Defines the gaps between rows & columns. -/// -/// If there are more gutters than defined sizes, the last gutter is repeated. -/// /// Display: Grid /// Category: layout #[node(Layout)] @@ -83,6 +77,12 @@ pub struct GridNode { /// repeated until there are no more cells. pub rows: TrackSizings, + /// Defines the gaps between rows & columns. + /// + /// If there are more gutters than defined sizes, the last gutter is repeated. + #[external] + pub gutter: TrackSizings, + /// Defines the gaps between columns. Takes precedence over `gutter`. #[parse( let gutter = args.named("gutter")?; diff --git a/library/src/layout/hide.rs b/library/src/layout/hide.rs index 43d9a2a8..62628445 100644 --- a/library/src/layout/hide.rs +++ b/library/src/layout/hide.rs @@ -18,7 +18,6 @@ use crate::prelude::*; #[node(Show)] pub struct HideNode { /// The content to hide. - #[positional] #[required] pub body: Content, } diff --git a/library/src/layout/list.rs b/library/src/layout/list.rs index 57b653c0..6d605868 100644 --- a/library/src/layout/list.rs +++ b/library/src/layout/list.rs @@ -163,7 +163,6 @@ impl Layout for ListNode { #[node] pub struct ListItem { /// The item's body. - #[positional] #[required] pub body: Content, } diff --git a/library/src/layout/pad.rs b/library/src/layout/pad.rs index 7d0bbe04..e8171560 100644 --- a/library/src/layout/pad.rs +++ b/library/src/layout/pad.rs @@ -15,16 +15,6 @@ use crate::prelude::*; /// measured in words per minute._ /// ``` /// -/// ## Parameters -/// - x: `Rel<Length>` (named, settable) -/// The horizontal padding. Both `left` and `right` take precedence over this. -/// -/// - y: `Rel<Length>` (named, settable) -/// The vertical padding. Both `top` and `bottom` take precedence over this. -/// -/// - rest: `Rel<Length>` (named, settable) -/// The padding for all sides. All other parameters take precedence over this. -/// /// Display: Padding /// Category: layout #[node(Layout)] @@ -50,8 +40,21 @@ pub struct PadNode { #[parse(args.named("bottom")?.or(y))] pub bottom: Rel<Length>, + /// The horizontal padding. Both `left` and `right` take precedence over + /// this. + #[external] + pub x: Rel<Length>, + + /// The vertical padding. Both `top` and `bottom` take precedence over this. + #[external] + pub y: Rel<Length>, + + /// The padding for all sides. All other parameters take precedence over + /// this. + #[external] + pub rest: Rel<Length>, + /// The content to pad at the sides. - #[positional] #[required] pub body: Content, } diff --git a/library/src/layout/page.rs b/library/src/layout/page.rs index 5fe3c90a..e469bf10 100644 --- a/library/src/layout/page.rs +++ b/library/src/layout/page.rs @@ -20,15 +20,15 @@ use crate::prelude::*; /// There you go, US friends! /// ``` /// -/// ## Parameters -/// - paper: `Paper` (positional, named, settable) -/// A standard paper size to set width and height. When this is not specified, -/// Typst defaults to `{"a4"}` paper. -/// /// Display: Page /// Category: layout #[node] pub struct PageNode { + /// A standard paper size to set width and height. When this is not + /// specified, Typst defaults to `{"a4"}` paper. + #[external] + pub paper: Paper, + /// The width of the page. /// /// ```example @@ -232,7 +232,6 @@ pub struct PageNode { /// Multiple pages will be created if the content does not fit on a single /// page. A new page with the page properties prior to the function invocation /// will be created after the body has been typeset. - #[positional] #[required] pub body: Content, } diff --git a/library/src/layout/par.rs b/library/src/layout/par.rs index 93cca452..e5644a2e 100644 --- a/library/src/layout/par.rs +++ b/library/src/layout/par.rs @@ -35,10 +35,6 @@ use crate::text::{ /// three integers. Then, we ... /// ``` /// -/// ## Parameters -/// - body: `Content` (positional, required) -/// The contents of the paragraph. -/// /// Display: Paragraph /// Category: layout #[node(Construct)] @@ -99,6 +95,10 @@ pub struct ParNode { #[default] pub linebreaks: Smart<Linebreaks>, + /// The contents of the paragraph. + #[external] + pub body: Content, + /// The paragraph's children. #[internal] #[variadic] diff --git a/library/src/layout/place.rs b/library/src/layout/place.rs index 8d7aa229..bfabd0f3 100644 --- a/library/src/layout/place.rs +++ b/library/src/layout/place.rs @@ -49,7 +49,6 @@ pub struct PlaceNode { pub dy: Rel<Length>, /// The content to place. - #[positional] #[required] pub body: Content, } diff --git a/library/src/layout/repeat.rs b/library/src/layout/repeat.rs index 0fd9ad83..c8f63ac3 100644 --- a/library/src/layout/repeat.rs +++ b/library/src/layout/repeat.rs @@ -26,7 +26,6 @@ use super::AlignNode; #[node(Layout)] pub struct RepeatNode { /// The content to repeat. - #[positional] #[required] pub body: Content, } diff --git a/library/src/layout/spacing.rs b/library/src/layout/spacing.rs index c11a2f06..dbdf0c11 100644 --- a/library/src/layout/spacing.rs +++ b/library/src/layout/spacing.rs @@ -24,7 +24,6 @@ use crate::prelude::*; #[node(Behave)] pub struct HNode { /// How much spacing to insert. - #[positional] #[required] pub amount: Spacing, @@ -84,31 +83,30 @@ impl Behave for HNode { /// ) /// ``` /// -/// ## Parameters -/// - weak: `bool` (named, settable) -/// If true, the spacing collapses at the start or end of a flow. Moreover, -/// from multiple adjacent weak spacings all but the largest one collapse. -/// Weak spacings will always collapse adjacent paragraph spacing, even if the -/// paragraph spacing is larger. -/// -/// ```example -/// The following theorem is -/// foundational to the field: -/// #v(4pt, weak: true) -/// $ x^2 + y^2 = r^2 $ -/// #v(4pt, weak: true) -/// The proof is simple: -/// ``` -/// /// Display: Spacing (V) /// Category: layout #[node(Behave)] pub struct VNode { /// How much spacing to insert. - #[positional] #[required] pub amount: Spacing, + /// If true, the spacing collapses at the start or end of a flow. Moreover, + /// from multiple adjacent weak spacings all but the largest one collapse. + /// Weak spacings will always collapse adjacent paragraph spacing, even if the + /// paragraph spacing is larger. + /// + /// ```example + /// The following theorem is + /// foundational to the field: + /// #v(4pt, weak: true) + /// $ x^2 + y^2 = r^2 $ + /// #v(4pt, weak: true) + /// The proof is simple: + /// ``` + #[external] + pub weak: bool, + /// The node's weakness level, see also [`Behaviour`]. #[internal] #[parse(args.named("weak")?.map(|v: bool| v as usize))] diff --git a/library/src/layout/table.rs b/library/src/layout/table.rs index 59635119..fabe8c33 100644 --- a/library/src/layout/table.rs +++ b/library/src/layout/table.rs @@ -29,35 +29,33 @@ use crate::prelude::*; /// ) /// ``` /// -/// ## Parameters -/// - gutter: `TrackSizings` (named, settable) -/// Defines the gaps between rows & columns. -/// See the [grid documentation]($func/grid) for more information on gutters. -/// /// Display: Table /// Category: layout #[node(Layout)] pub struct TableNode { - /// Defines the column sizes. - /// See the [grid documentation]($func/grid) for more information on track - /// sizing. + /// Defines the column sizes. See the [grid documentation]($func/grid) for + /// more information on track sizing. pub columns: TrackSizings, - /// Defines the row sizes. - /// See the [grid documentation]($func/grid) for more information on track - /// sizing. + /// Defines the row sizes. See the [grid documentation]($func/grid) for more + /// information on track sizing. pub rows: TrackSizings, - /// Defines the gaps between columns. Takes precedence over `gutter`. - /// See the [grid documentation]($func/grid) for more information on gutters. + /// Defines the gaps between rows & columns. See the [grid + /// documentation]($func/grid) for more information on gutters. + #[external] + pub gutter: TrackSizings, + + /// Defines the gaps between columns. Takes precedence over `gutter`. See + /// the [grid documentation]($func/grid) for more information on gutters. #[parse( let gutter = args.named("gutter")?; args.named("column-gutter")?.or_else(|| gutter.clone()) )] pub column_gutter: TrackSizings, - /// Defines the gaps between rows. Takes precedence over `gutter`. - /// See the [grid documentation]($func/grid) for more information on gutters. + /// Defines the gaps between rows. Takes precedence over `gutter`. See the + /// [grid documentation]($func/grid) for more information on gutters. #[parse(args.named("row-gutter")?.or_else(|| gutter.clone()))] pub row_gutter: TrackSizings, diff --git a/library/src/layout/terms.rs b/library/src/layout/terms.rs index 8ab4edc6..b2f45446 100644 --- a/library/src/layout/terms.rs +++ b/library/src/layout/terms.rs @@ -126,12 +126,10 @@ impl Layout for TermsNode { #[node] pub struct TermItem { /// The term described by the list item. - #[positional] #[required] pub term: Content, /// The description of the term. - #[positional] #[required] pub description: Content, } diff --git a/library/src/layout/transform.rs b/library/src/layout/transform.rs index 4521da32..2afe8201 100644 --- a/library/src/layout/transform.rs +++ b/library/src/layout/transform.rs @@ -32,7 +32,6 @@ pub struct MoveNode { pub dy: Rel<Length>, /// The content to move. - #[positional] #[required] pub body: Content, } @@ -101,7 +100,6 @@ pub struct RotateNode { pub origin: Axes<Option<GenAlign>>, /// The content to rotate. - #[positional] #[required] pub body: Content, } @@ -170,7 +168,6 @@ pub struct ScaleNode { pub origin: Axes<Option<GenAlign>>, /// The content to scale. - #[positional] #[required] pub body: Content, } |
