From 0b0c4cdb5f42b68807ca33ee2426fa1f2ca37969 Mon Sep 17 00:00:00 2001 From: "Y.D.X." <73375426+YDX-2147483647@users.noreply.github.com> Date: Sat, 23 Aug 2025 00:40:58 +0800 Subject: [PATCH] Make links to `$grid` in `table` docs more specific (#6776) Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com> --- crates/typst-library/src/layout/grid/mod.rs | 15 ++++++++++++--- crates/typst-library/src/model/table.rs | 18 +++++++++--------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/crates/typst-library/src/layout/grid/mod.rs b/crates/typst-library/src/layout/grid/mod.rs index 03e9a3114..b6495a2c9 100644 --- a/crates/typst-library/src/layout/grid/mod.rs +++ b/crates/typst-library/src/layout/grid/mod.rs @@ -36,7 +36,11 @@ use crate::visualize::{Paint, Stroke}; /// in the document flow. Set and show rules on one of these elements do not /// affect the other. /// +/// # Sizing the tracks { #track-size } +/// /// A grid's sizing is determined by the track sizes specified in the arguments. +/// There are multiple sizing parameters: [`columns`]($grid.columns), +/// [`rows`]($grid.rows) and [`gutter`]($grid.gutter). /// Because each of the sizing parameters accepts the same values, we will /// explain them just once, here. Each sizing argument accepts an array of /// individual track sizes. A track size is either: @@ -143,21 +147,26 @@ pub struct GridElem { /// with that many `{auto}`-sized columns. Note that opposed to rows and /// gutters, providing a single track size will only ever create a single /// column. + /// + /// See the [track size section](#track-size) above for more details. pub columns: TrackSizings, /// The row sizes. /// /// If there are more cells than fit the defined rows, the last row is /// repeated until there are no more cells. + /// + /// See the [track size section](#track-size) above for more details. pub rows: TrackSizings, - /// The gaps between rows and columns. + /// The gaps between rows and columns. This is a shorthand to set + /// [`column-gutter`]($grid.column-gutter) and [`row-gutter`]($grid.row-gutter) + /// to the same value. /// /// If there are more gutters than defined sizes, the last gutter is /// repeated. /// - /// This is a shorthand to set `column-gutter` and `row-gutter` to the same - /// value. + /// See the [track size section](#track-size) above for more details. #[external] pub gutter: TrackSizings, diff --git a/crates/typst-library/src/model/table.rs b/crates/typst-library/src/model/table.rs index 2a85ce01c..54f304b48 100644 --- a/crates/typst-library/src/model/table.rs +++ b/crates/typst-library/src/model/table.rs @@ -22,8 +22,8 @@ use crate::visualize::{Paint, Stroke}; /// /// Because tables are just grids with different defaults for some cell /// properties (notably `stroke` and `inset`), refer to the [grid -/// documentation]($grid) for more information on how to size the table tracks -/// and specify the cell appearance properties. +/// documentation]($grid/#track-size) for more information on how to size the +/// table tracks and specify the cell appearance properties. /// /// If you are unsure whether you should be using a table or a grid, consider /// whether the content you are arranging semantically belongs together as a set @@ -115,22 +115,22 @@ use crate::visualize::{Paint, Stroke}; /// ``` #[elem(scope, LocalName, Figurable)] pub struct TableElem { - /// The column sizes. See the [grid documentation]($grid) for more - /// information on track sizing. + /// The column sizes. See the [grid documentation]($grid/#track-size) for + /// more information on track sizing. pub columns: TrackSizings, - /// The row sizes. See the [grid documentation]($grid) for more information - /// on track sizing. + /// The row sizes. See the [grid documentation]($grid/#track-size) for more + /// information on track sizing. pub rows: TrackSizings, /// The gaps between rows and columns. This is a shorthand for setting /// `column-gutter` and `row-gutter` to the same value. See the [grid - /// documentation]($grid) for more information on gutters. + /// documentation]($grid.gutter) for more information on gutters. #[external] pub gutter: TrackSizings, /// The gaps between columns. Takes precedence over `gutter`. See the - /// [grid documentation]($grid) for more information on gutters. + /// [grid documentation]($grid.gutter) for more information on gutters. #[parse( let gutter = args.named("gutter")?; args.named("column-gutter")?.or_else(|| gutter.clone()) @@ -138,7 +138,7 @@ pub struct TableElem { pub column_gutter: TrackSizings, /// The gaps between rows. Takes precedence over `gutter`. See the - /// [grid documentation]($grid) for more information on gutters. + /// [grid documentation]($grid.gutter) for more information on gutters. #[parse(args.named("row-gutter")?.or_else(|| gutter.clone()))] pub row_gutter: TrackSizings,