diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-10-15 14:54:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-15 12:54:16 +0000 |
| commit | 240b917399148f8aa2f28ea37a03c1fd7e23832e (patch) | |
| tree | a32833d223c00c693ba05cb438609bfb0093be88 /crates | |
| parent | 89cecb188d3905ecf98f2a6be93cbd7cf6bf8a64 (diff) | |
Docs and changelog improvements (#5147)
Co-authored-by: Malo <57839069+MDLC01@users.noreply.github.com>
Co-authored-by: Andrew Voynov <37143421+Andrew15-5@users.noreply.github.com>
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com>
Co-authored-by: Jeremie Knuesel <knuesel@gmail.com>
Co-authored-by: +merlan #flirora <2975203+bluebear94@users.noreply.github.com>
Co-authored-by: Anselm Schüler <mail@anselmschueler.com>
Diffstat (limited to 'crates')
23 files changed, 173 insertions, 78 deletions
diff --git a/crates/typst-cli/src/args.rs b/crates/typst-cli/src/args.rs index 7436d25c..a4ac4bd9 100644 --- a/crates/typst-cli/src/args.rs +++ b/crates/typst-cli/src/args.rs @@ -209,7 +209,9 @@ pub struct QueryCommand { #[clap(long = "format", default_value = "json")] pub format: SerializationFormat, - /// Whether to pretty-print the serialized output + /// Whether to pretty-print the serialized output. + /// + /// Only applies to JSON format. #[clap(long)] pub pretty: bool, } diff --git a/crates/typst/src/foundations/array.rs b/crates/typst/src/foundations/array.rs index 6631af21..77d8829d 100644 --- a/crates/typst/src/foundations/array.rs +++ b/crates/typst/src/foundations/array.rs @@ -486,7 +486,8 @@ impl Array { /// function is a bit involved, so we parse the positional arguments manually). args: &mut Args, /// Whether all arrays have to have the same length. - /// For example, `(1, 2).zip((1, 2, 3), exact: true)` produces an error. + /// For example, `{(1, 2).zip((1, 2, 3), exact: true)}` produces an + /// error. #[named] #[default(false)] exact: bool, diff --git a/crates/typst/src/foundations/calc.rs b/crates/typst/src/foundations/calc.rs index 5c818368..a4dbab88 100644 --- a/crates/typst/src/foundations/calc.rs +++ b/crates/typst/src/foundations/calc.rs @@ -92,7 +92,7 @@ cast! { /// Raises a value to some exponent. /// /// ```example -/// #calc.pow(2, 3) +/// #calc.pow(2, 3) \ /// #calc.pow(decimal("2.5"), 2) /// ``` #[func(title = "Power")] @@ -236,7 +236,6 @@ pub fn root( /// radians. /// /// ```example -/// #assert(calc.sin(90deg) == calc.sin(-270deg)) /// #calc.sin(1.5) \ /// #calc.sin(90deg) /// ``` @@ -258,7 +257,6 @@ pub fn sin( /// radians. /// /// ```example -/// #calc.cos(90deg) \ /// #calc.cos(1.5) \ /// #calc.cos(90deg) /// ``` @@ -621,10 +619,10 @@ pub fn lcm( /// 64-bit signed integer or smaller than the minimum for that type. /// /// ```example +/// #calc.floor(500.1) /// #assert(calc.floor(3) == 3) /// #assert(calc.floor(3.14) == 3) /// #assert(calc.floor(decimal("-3.14")) == -4) -/// #calc.floor(500.1) /// ``` #[func] pub fn floor( @@ -648,10 +646,10 @@ pub fn floor( /// 64-bit signed integer or smaller than the minimum for that type. /// /// ```example +/// #calc.ceil(500.1) /// #assert(calc.ceil(3) == 3) /// #assert(calc.ceil(3.14) == 4) /// #assert(calc.ceil(decimal("-3.14")) == -3) -/// #calc.ceil(500.1) /// ``` #[func] pub fn ceil( @@ -675,10 +673,10 @@ pub fn ceil( /// 64-bit signed integer or smaller than the minimum for that type. /// /// ```example +/// #calc.trunc(15.9) /// #assert(calc.trunc(3) == 3) /// #assert(calc.trunc(-3.7) == -3) /// #assert(calc.trunc(decimal("8493.12949582390")) == 8493) -/// #calc.trunc(15.9) /// ``` #[func(title = "Truncate")] pub fn trunc( @@ -698,9 +696,9 @@ pub fn trunc( /// If the number is an integer, returns `0`. /// /// ```example +/// #calc.fract(-3.1) /// #assert(calc.fract(3) == 0) /// #assert(calc.fract(decimal("234.23949211")) == decimal("0.23949211")) -/// #calc.fract(-3.1) /// ``` #[func(title = "Fractional")] pub fn fract( @@ -734,6 +732,7 @@ pub fn fract( /// for maximum and minimum respectively. /// /// ```example +/// #calc.round(3.1415, digits: 2) /// #assert(calc.round(3) == 3) /// #assert(calc.round(3.14) == 3) /// #assert(calc.round(3.5) == 4.0) @@ -745,7 +744,6 @@ pub fn fract( /// #assert(calc.round(decimal("7.123456789"), digits: 6) == decimal("7.123457")) /// #assert(calc.round(decimal("3333.45"), digits: -2) == decimal("3300")) /// #assert(calc.round(decimal("-48953.45"), digits: -3) == decimal("-49000")) -/// #calc.round(3.1415, digits: 2) /// ``` #[func] pub fn round( @@ -776,11 +774,11 @@ pub fn round( /// Clamps a number between a minimum and maximum value. /// /// ```example +/// #calc.clamp(5, 0, 4) /// #assert(calc.clamp(5, 0, 10) == 5) /// #assert(calc.clamp(5, 6, 10) == 6) /// #assert(calc.clamp(decimal("5.45"), 2, decimal("45.9")) == decimal("5.45")) /// #assert(calc.clamp(decimal("5.45"), decimal("6.75"), 12) == decimal("6.75")) -/// #calc.clamp(5, 0, 4) /// ``` #[func] pub fn clamp( @@ -991,7 +989,7 @@ pub fn div_euclid( /// #calc.rem-euclid(7, -3) \ /// #calc.rem-euclid(-7, 3) \ /// #calc.rem-euclid(-7, -3) \ -/// #calc.rem-euclid(1.75, 0.5) +/// #calc.rem-euclid(1.75, 0.5) \ /// #calc.rem-euclid(decimal("1.75"), decimal("0.5")) /// ``` #[func(title = "Euclidean Remainder")] diff --git a/crates/typst/src/foundations/decimal.rs b/crates/typst/src/foundations/decimal.rs index 6ba4c1a6..809b298a 100644 --- a/crates/typst/src/foundations/decimal.rs +++ b/crates/typst/src/foundations/decimal.rs @@ -34,9 +34,10 @@ use crate::World; /// constructing a decimal from a [floating-point number]($float), while /// supported, **is an imprecise conversion and therefore discouraged.** A /// warning will be raised if Typst detects that there was an accidental `float` -/// to `decimal` cast through its constructor (e.g. if writing `{decimal(3.14)}` -/// - note the lack of double quotes, indicating this is an accidental `float` -/// cast and therefore imprecise). +/// to `decimal` cast through its constructor, e.g. if writing `{decimal(3.14)}` +/// (note the lack of double quotes, indicating this is an accidental `float` +/// cast and therefore imprecise). It is recommended to use strings for +/// constant decimal values instead (e.g. `{decimal("3.14")}`). /// /// The precision of a `float` to `decimal` cast can be slightly improved by /// rounding the result to 15 digits with [`calc.round`]($calc.round), but there @@ -81,11 +82,11 @@ use crate::World; /// multiplication, and [power]($calc.pow) to an integer, will be highly precise /// due to their fixed-point representation. Note, however, that multiplication /// and division may not preserve all digits in some edge cases: while they are -/// considered precise, digits past the limits specified below are rounded off +/// considered precise, digits past the limits specified above are rounded off /// and lost, so some loss of precision beyond the maximum representable digits /// is possible. Note that this behavior can be observed not only when dividing, /// but also when multiplying by numbers between 0 and 1, as both operations can -/// push a number's fractional digits beyond the limits described below, leading +/// push a number's fractional digits beyond the limits described above, leading /// to rounding. When those two operations do not surpass the digit limits, they /// are fully precise. #[ty(scope, cast)] @@ -287,7 +288,7 @@ impl Decimal { /// writing `{decimal(1.234)}` (note the lack of double quotes), which is /// why Typst will emit a warning in that case. Please write /// `{decimal("1.234")}` instead for that particular case (initialization of - /// a constant decimal). Also note that floats equal to NaN and infinity + /// a constant decimal). Also note that floats that are NaN or infinite /// cannot be cast to decimals and will raise an error. /// /// ```example @@ -296,6 +297,7 @@ impl Decimal { #[func(constructor)] pub fn construct( engine: &mut Engine, + /// The value that should be converted to a decimal. value: Spanned<ToDecimal>, ) -> SourceResult<Decimal> { match value.v { diff --git a/crates/typst/src/foundations/float.rs b/crates/typst/src/foundations/float.rs index 8318641a..752b01d6 100644 --- a/crates/typst/src/foundations/float.rs +++ b/crates/typst/src/foundations/float.rs @@ -97,7 +97,7 @@ impl f64 { /// /// - If the number is positive (including `{+0.0}`), returns `{1.0}`. /// - If the number is negative (including `{-0.0}`), returns `{-1.0}`. - /// - If the number is `{float.nan}`, returns `{float.nan}`. + /// - If the number is NaN, returns `{float.nan}`. /// /// ```example /// #(5.0).signum() \ diff --git a/crates/typst/src/introspection/location.rs b/crates/typst/src/introspection/location.rs index 8a7063fc..5c520d25 100644 --- a/crates/typst/src/introspection/location.rs +++ b/crates/typst/src/introspection/location.rs @@ -85,8 +85,8 @@ impl Location { /// local numbering. This is useful if you are building custom indices or /// outlines. /// - /// If the page numbering is set to `none` at that location, this function - /// returns `none`. + /// If the page numbering is set to `{none}` at that location, this function + /// returns `{none}`. #[func] pub fn page_numbering(self, engine: &mut Engine) -> Option<Numbering> { engine.introspector.page_numbering(self).cloned() diff --git a/crates/typst/src/layout/align.rs b/crates/typst/src/layout/align.rs index 9d3fe26c..e8ba4d7c 100644 --- a/crates/typst/src/layout/align.rs +++ b/crates/typst/src/layout/align.rs @@ -64,6 +64,15 @@ use crate::text::TextElem; /// left. /// ]) /// ``` +/// +/// # Alignment within the same line +/// The `align` function performs block-level alignment and thus always +/// interrupts the current paragraph. To have different alignment for parts +/// of the same line, you should use [fractional spacing]($h) instead: +/// +/// ```example +/// Start #h(1fr) End +/// ``` #[elem(Show)] pub struct AlignElem { /// The [alignment] along both axes. diff --git a/crates/typst/src/layout/measure.rs b/crates/typst/src/layout/measure.rs index 92d4c5c3..ad68b948 100644 --- a/crates/typst/src/layout/measure.rs +++ b/crates/typst/src/layout/measure.rs @@ -19,8 +19,8 @@ use crate::syntax::Span; /// /// # Example /// The same content can have a different size depending on the [context] that -/// it is placed into. For example, in the example below `[#content]` is of -/// course bigger when we increase the font size. +/// it is placed into. In the example below, the `[#content]` is of course +/// bigger when we increase the font size. /// /// ```example /// #let content = [Hello!] @@ -53,12 +53,12 @@ pub fn measure( span: Span, /// The width available to layout the content. /// - /// Defaults to `{auto}`, which denotes an infinite width. + /// Setting this to `{auto}` indicates infinite available width. /// - /// Using the `width` and `height` parameters of this function is - /// different from measuring a [`box`] containing the content; - /// the former will get the dimensions of the inner content - /// instead of the dimensions of the box: + /// Note that using the `width` and `height` parameters of this function is + /// different from measuring a sized [`block`] containing the content. In + /// the following example, the former will get the dimensions of the inner + /// content instead of the dimensions of the block. /// /// ```example /// #context measure(lorem(100), width: 400pt) @@ -70,7 +70,7 @@ pub fn measure( width: Smart<Length>, /// The height available to layout the content. /// - /// Defaults to `{auto}`, which denotes an infinite height. + /// Setting this to `{auto}` indicates infinite available height. #[named] #[default(Smart::Auto)] height: Smart<Length>, diff --git a/crates/typst/src/layout/page.rs b/crates/typst/src/layout/page.rs index 66c2c076..95b3cd1b 100644 --- a/crates/typst/src/layout/page.rs +++ b/crates/typst/src/layout/page.rs @@ -189,8 +189,8 @@ pub struct PageElem { /// /// When set to `{none}`, the background becomes transparent. Note that PDF /// pages will still appear with a (usually white) background in viewers, - /// but they are conceptually transparent. (If you print them, no color is - /// used for the background.) + /// but they are actually transparent. (If you print them, no color is used + /// for the background.) /// /// The default of `{auto}` results in `{none}` for PDF output, and /// `{white}` for PNG and SVG. diff --git a/crates/typst/src/layout/place.rs b/crates/typst/src/layout/place.rs index 6e34f4e2..bedeb507 100644 --- a/crates/typst/src/layout/place.rs +++ b/crates/typst/src/layout/place.rs @@ -24,7 +24,7 @@ use crate::layout::{Alignment, Em, Length, Rel}; /// /// # Examples /// ```example -/// #set page(height: 60pt) +/// #set page(height: 120pt) /// Hello, world! /// /// #rect( diff --git a/crates/typst/src/layout/spacing.rs b/crates/typst/src/layout/spacing.rs index af0b1e64..c7c0823c 100644 --- a/crates/typst/src/layout/spacing.rs +++ b/crates/typst/src/layout/spacing.rs @@ -11,13 +11,23 @@ use crate::utils::Numeric; /// # Example /// ```example /// First #h(1cm) Second \ -/// First #h(30%) Second \ +/// First #h(30%) Second +/// ``` +/// +/// # Fractional spacing +/// With fractional spacing, you can align things within a line without forcing +/// a paragraph break (like [`align`] would). Each fractionally sized element +/// gets space based on the ratio of its fraction to the sum of all fractions. +/// +/// ```example +/// First #h(1fr) Second \ +/// First #h(1fr) Second #h(1fr) Third \ /// First #h(2fr) Second #h(1fr) Third /// ``` /// /// # Mathematical Spacing { #math-spacing } /// In [mathematical formulas]($category/math), you can additionally use these -/// constants to add spacing between elements: `thin` (1/6 em), `med`(2/9 em), +/// constants to add spacing between elements: `thin` (1/6 em), `med` (2/9 em), /// `thick` (5/18 em), `quad` (1 em), `wide` (2 em). #[elem(title = "Spacing (H)")] pub struct HElem { diff --git a/crates/typst/src/math/equation.rs b/crates/typst/src/math/equation.rs index 6f0290d4..19e3ce57 100644 --- a/crates/typst/src/math/equation.rs +++ b/crates/typst/src/math/equation.rs @@ -43,6 +43,9 @@ use crate::World; /// $ sum_(k=1)^n k = (n(n+1)) / 2 $ /// ``` /// +/// By default, block-level equations will not break across pages. This can be +/// changed through `{show math.equation: set block(breakable: true)}`. +/// /// # Syntax /// This function also has dedicated syntax: Write mathematical markup within /// dollar signs to create an equation. Starting and ending the equation with at diff --git a/crates/typst/src/math/matrix.rs b/crates/typst/src/math/matrix.rs index 15ada1f3..66b83e20 100644 --- a/crates/typst/src/math/matrix.rs +++ b/crates/typst/src/math/matrix.rs @@ -40,6 +40,10 @@ const DEFAULT_STROKE_THICKNESS: Em = Em::new(0.05); pub struct VecElem { /// The delimiter to use. /// + /// Can be a single character specifying the left delimiter, in which case + /// the right delimiter is inferred. Otherwise, can be an array containing a + /// left and a right delimiter. + /// /// ```example /// #set math.vec(delim: "[") /// $ vec(1, 2) $ @@ -113,6 +117,10 @@ impl LayoutMath for Packed<VecElem> { pub struct MatElem { /// The delimiter to use. /// + /// Can be a single character specifying the left delimiter, in which case + /// the right delimiter is inferred. Otherwise, can be an array containing a + /// left and a right delimiter. + /// /// ```example /// #set math.mat(delim: "[") /// $ mat(1, 2; 3, 4) $ @@ -300,6 +308,10 @@ impl LayoutMath for Packed<MatElem> { pub struct CasesElem { /// The delimiter to use. /// + /// Can be a single character specifying the left delimiter, in which case + /// the right delimiter is inferred. Otherwise, can be an array containing a + /// left and a right delimiter. + /// /// ```example /// #set math.cases(delim: "[") /// $ x = cases(1, 2) $ diff --git a/crates/typst/src/model/document.rs b/crates/typst/src/model/document.rs index d37f6c8f..b693d785 100644 --- a/crates/typst/src/model/document.rs +++ b/crates/typst/src/model/document.rs @@ -14,7 +14,7 @@ use crate::layout::Page; /// All documents are automatically wrapped in a `document` element. You cannot /// create a document element yourself. This function is only used with /// [set rules]($styling/#set-rules) to specify document metadata. Such a set -/// rule must appear before any of the document's contents. +/// rule must not occur inside of any layout container. /// /// ```example /// #set document(title: [Hello]) diff --git a/crates/typst/src/model/enum.rs b/crates/typst/src/model/enum.rs index 2f1a110a..fcb62f89 100644 --- a/crates/typst/src/model/enum.rs +++ b/crates/typst/src/model/enum.rs @@ -75,9 +75,10 @@ use crate::text::TextElem; /// part of that item. #[elem(scope, title = "Numbered List", Show)] pub struct EnumElem { - /// If this is `{false}`, the items are spaced apart with - /// [enum spacing]($enum.spacing). If it is `{true}`, they use normal - /// [leading]($par.leading) instead. This makes the enumeration more + /// Defines the default [spacing]($enum.spacing) of the enumeration. If it + /// is `{false}`, the items are spaced apart with + /// [paragraph spacing]($par.spacing). If it is `{true}`, they use + /// [paragraph leading]($par.leading) instead. This makes the list more /// compact, which can look better if the items are short. /// /// In markup mode, the value of this parameter is determined based on diff --git a/crates/typst/src/model/footnote.rs b/crates/typst/src/model/footnote.rs index 813990a9..5468b4f5 100644 --- a/crates/typst/src/model/footnote.rs +++ b/crates/typst/src/model/footnote.rs @@ -176,8 +176,8 @@ cast! { /// An entry in a footnote list. /// -/// This function is not intended to be called directly. Instead, it is used -/// in set and show rules to customize footnote listings. +/// This function is not intended to be called directly. Instead, it is used in +/// set and show rules to customize footnote listings. /// /// ```example /// #show footnote.entry: set text(red) @@ -187,11 +187,10 @@ cast! { /// has red text! /// ``` /// -/// _Note:_ Set and show rules for `footnote.entry` must be defined at the -/// beginning of the document in order to work correctly. See [here][issue] for -/// more information. -/// -/// [issue]: https://github.com/typst/typst/issues/1467#issuecomment-1588799440 +/// _Note:_ Footnote entry properties must be uniform across each page run (a +/// page run is a sequence of pages without an explicit pagebreak in between). +/// For this reason, set and show rules for footnote entries should be defined +/// before any page content, typically at the very start of the document. #[elem(name = "entry", title = "Footnote Entry", Show, ShowSet)] pub struct FootnoteEntry { /// The footnote for this entry. It's location can be used to determine diff --git a/crates/typst/src/model/list.rs b/crates/typst/src/model/list.rs index 617c54c9..3a2bd651 100644 --- a/crates/typst/src/model/list.rs +++ b/crates/typst/src/model/list.rs @@ -47,10 +47,11 @@ use crate::text::TextElem; /// more than an item's marker becomes part of that item. #[elem(scope, title = "Bullet List", Show)] pub struct ListElem { - /// If this is `{false}`, the items are spaced apart with - /// [list spacing]($list.spacing). If it is `{true}`, they use normal - /// [leading]($par.leading) instead. This makes the list more compact, which - /// can look better if the items are short. + /// Defines the default [spacing]($list.spacing) of the list. If it is + /// `{false}`, the items are spaced apart with + /// [paragraph spacing]($par.spacing). If it is `{true}`, they use + /// [paragraph leading]($par.leading) instead. This makes the list more + /// compact, which can look better if the items are short. /// /// In markup mode, the value of this parameter is determined based on /// whether items are separated with a blank line. If items directly follow diff --git a/crates/typst/src/model/outline.rs b/crates/typst/src/model/outline.rs index 5bf2407b..b89a1524 100644 --- a/crates/typst/src/model/outline.rs +++ b/crates/typst/src/model/outline.rs @@ -172,7 +172,7 @@ pub struct OutlineElem { pub indent: Option<Smart<OutlineIndent>>, /// Content to fill the space between the title and the page number. Can be - /// set to `none` to disable filling. + /// set to `{none}` to disable filling. /// /// ```example /// #outline(fill: line(length: 100%)) diff --git a/crates/typst/src/model/par.rs b/crates/typst/src/model/par.rs index 371ee4b3..32fc926f 100644 --- a/crates/typst/src/model/par.rs +++ b/crates/typst/src/model/par.rs @@ -217,8 +217,11 @@ impl Unlabellable for Packed<ParbreakElem> {} /// A paragraph line. /// -/// This element is exclusively used for line number configuration and cannot -/// be placed. +/// This element is exclusively used for line number configuration through set +/// rules and cannot be placed. +/// +/// The [`numbering`]($par.line.numbering) option is used to enable line +/// numbers by specifying a numbering format. /// /// ```example /// >>> #set page(margin: (left: 3em)) @@ -228,6 +231,43 @@ impl Unlabellable for Packed<ParbreakElem> {} /// Violets are blue. \ /// Typst is there for you. /// ``` +/// +/// The `numbering` option takes either a predefined +/// [numbering pattern]($numbering) or a function returning styled content. You +/// can disable line numbers for text inside certain elements by setting the +/// numbering to `{none}` using show-set rules. +/// +/// ```example +/// >>> #set page(margin: (left: 3em)) +/// // Styled red line numbers. +/// #set par.line( +/// numbering: n => text(red)[#n] +/// ) +/// +/// // Disable numbers inside figures. +/// #show figure: set par.line( +/// numbering: none +/// ) +/// +/// Roses are red. \ +/// Violets are blue. +/// +/// #figure( +/// caption: [Without line numbers.] +/// )[ +/// Lorem ipsum \ +/// dolor sit amet +/// ] +/// +/// The text above is a sample \ +/// originating from distant times. +/// ``` +/// +/// This element exposes further options which may be used to control other +/// aspects of line numbering, such as its [alignment]($par.line.number-align) +/// or [margin]($par.line.number-margin). In addition, you can control whether +/// the numbering is reset on each page through the +/// [`numbering-scope`]($par.line.numbering-scope) option. #[elem(name = "line", title = "Paragraph Line", keywords = ["line numbering"], Construct, Locatable)] pub struct ParLine { /// How to number each line. Accepts a @@ -246,13 +286,16 @@ pub struct ParLine { /// The alignment of line numbers associated with each line. /// - /// The default of `auto` will provide a smart default where numbers grow + /// The default of `{auto}` indicates a smart default where numbers grow /// horizontally away from the text, considering the margin they're in and /// the current text direction. /// /// ```example /// >>> #set page(margin: (left: 3em)) - /// #set par.line(numbering: "I", number-align: left) + /// #set par.line( + /// numbering: "I", + /// number-align: left, + /// ) /// /// Hello world! \ /// Today is a beautiful day \ @@ -263,9 +306,18 @@ pub struct ParLine { /// The margin at which line numbers appear. /// + /// _Note:_ In a multi-column document, the line numbers for paragraphs + /// inside the last column will always appear on the `{end}` margin (right + /// margin for left-to-right text and left margin for right-to-left), + /// regardless of this configuration. That behavior cannot be changed at + /// this moment. + /// /// ```example /// >>> #set page(margin: (right: 3em)) - /// #set par.line(numbering: "1", number-margin: right) + /// #set par.line( + /// numbering: "1", + /// number-margin: right, + /// ) /// /// = Report /// - Brightness: Dark, yet darker @@ -284,7 +336,7 @@ pub struct ParLine { /// >>> #set page(margin: (left: 3em)) /// #set par.line( /// numbering: "1", - /// number-clearance: 4pt + /// number-clearance: 4pt, /// ) /// /// Typesetting \ @@ -297,14 +349,16 @@ pub struct ParLine { /// Controls when to reset line numbering. /// - /// Possible options are `"document"`, indicating the line number counter - /// is never reset, or `"page"`, indicating it is reset on every page. + /// _Note:_ The line numbering scope must be uniform across each page run (a + /// page run is a sequence of pages without an explicit pagebreak in + /// between). For this reason, set rules for it should be defined before any + /// page content, typically at the very start of the document. /// /// ```example /// >>> #set page(margin: (left: 3em)) /// #set par.line( /// numbering: "1", - /// numbering-scope: "page" + /// numbering-scope: "page", /// ) /// /// First line \ diff --git a/crates/typst/src/model/terms.rs b/crates/typst/src/model/terms.rs index dead9c66..557895f7 100644 --- a/crates/typst/src/model/terms.rs +++ b/crates/typst/src/model/terms.rs @@ -27,10 +27,11 @@ use crate::utils::Numeric; /// followed by a term, a colon and a description creates a term list item. #[elem(scope, title = "Term List", Show)] pub struct TermsElem { - /// If this is `{false}`, the items are spaced apart with - /// [term list spacing]($terms.spacing). If it is `{true}`, they use normal - /// [leading]($par.leading) instead. This makes the term list more compact, - /// which can look better if the items are short. + /// Defines the default [spacing]($terms.spacing) of the term list. If it is + /// `{false}`, the items are spaced apart with + /// [paragraph spacing]($par.spacing). If it is `{true}`, they use + /// [paragraph leading]($par.leading) instead. This makes the list more + /// compact, which can look better if the items are short. /// /// In markup mode, the value of this parameter is determined based on /// whether items are separated with a blank line. If items directly follow diff --git a/crates/typst/src/text/mod.rs b/crates/typst/src/text/mod.rs index 5b35d60c..6f3f741a 100644 --- a/crates/typst/src/text/mod.rs +++ b/crates/typst/src/text/mod.rs @@ -445,9 +445,10 @@ pub struct TextElem { /// the other way around in `rtl` text. /// /// If you set this to `rtl` and experience bugs or in some way bad looking - /// output, please do get in touch with us through the - /// [contact form](https://typst.app/contact) or our - /// [Discord server](https://discord.gg/2uDybryKPe)! + /// output, please get in touch with us through the + /// [Forum](https://forum.typst.app/), + /// [Discord server](https://discord.gg/2uDybryKPe), + /// or our [contact form](https://typst.app/contact). /// /// ```example /// #set text(dir: rtl) @@ -482,8 +483,9 @@ pub struct TextElem { /// The "cost" of various choices when laying out text. A higher cost means /// the layout engine will make the choice less often. Costs are specified - /// as a ratio of the default cost, so `50%` will make text layout twice as - /// eager to make a given choice, while `200%` will make it half as eager. + /// as a ratio of the default cost, so `{50%}` will make text layout twice + /// as eager to make a given choice, while `{200%}` will make it half as + /// eager. /// /// Currently, the following costs can be customized: /// - `hyphenation`: splitting a word across multiple lines @@ -501,10 +503,10 @@ pub struct TextElem { /// Text layout prevents widows and orphans by default because they are /// generally discouraged by style guides. However, in some contexts they /// are allowed because the prevention method, which moves a line to the - /// next page, can result in an uneven number of lines between pages. - /// The `widow` and `orphan` costs allow disabling these modifications. - /// (Currently, 0% allows widows/orphans; anything else, including the - /// default of `auto`, prevents them. More nuanced cost specification for + /// next page, can result in an uneven number of lines between pages. The + /// `widow` and `orphan` costs allow disabling these modifications. + /// (Currently, `{0%}` allows widows/orphans; anything else, including the + /// default of `{100%}`, prevents them. More nuanced cost specification for /// these modifications is planned for the future.) /// /// ```example @@ -568,9 +570,9 @@ pub struct TextElem { /// This can be set to an integer or an array of integers, all /// of which must be between `{1}` and `{20}`, enabling the /// corresponding OpenType feature(s) from `ss01` to `ss20`. - /// Setting this to `none` will disable all stylistic sets. + /// Setting this to `{none}` will disable all stylistic sets. /// - /// ``` + /// ```example /// #set text(font: "IBM Plex Serif") /// ß vs #text(stylistic-set: 5)[ß] \ /// 10 years ago vs #text(stylistic-set: (1, 2, 3))[10 years ago] diff --git a/crates/typst/src/text/raw.rs b/crates/typst/src/text/raw.rs index 21b6bc00..e669be38 100644 --- a/crates/typst/src/text/raw.rs +++ b/crates/typst/src/text/raw.rs @@ -215,7 +215,7 @@ pub struct RawElem { pub syntaxes_data: Vec<Bytes>, /// The theme to use for syntax highlighting. Theme files should be in the - /// in the [`tmTheme` file format](https://www.sublimetext.com/docs/color_schemes_tmtheme.html). + /// [`tmTheme` file format](https://www.sublimetext.com/docs/color_schemes_tmtheme.html). /// /// Applying a theme only affects the color of specifically highlighted /// text. It does not consider the theme's foreground and background @@ -224,7 +224,7 @@ pub struct RawElem { /// the background with a [filled block]($block.fill). You could also use /// the [`xml`] function to extract these properties from the theme. /// - /// Additionally, you can set the theme to `none` to disable highlighting. + /// Additionally, you can set the theme to `{none}` to disable highlighting. /// /// ````example /// #set raw(theme: "halcyon.tmTheme") diff --git a/crates/typst/src/visualize/line.rs b/crates/typst/src/visualize/line.rs index f25fc58d..e00bf220 100644 --- a/crates/typst/src/visualize/line.rs +++ b/crates/typst/src/visualize/line.rs @@ -33,13 +33,13 @@ pub struct LineElem { #[resolve] pub end: Option<Axes<Rel<Length>>>, - /// The line's length. This is only respected if `end` is `none`. + /// The line's length. This is only respected if `end` is `{none}`. #[resolve] #[default(Abs::pt(30.0).into())] pub length: Rel<Length>, /// The angle at which the line points away from the origin. This is only - /// respected if `end` is `none`. + /// respected if `end` is `{none}`. pub angle: Angle, /// How to [stroke] the line. |
