diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-05-17 14:38:03 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-05-17 14:38:03 +0200 |
| commit | 42afa410ae561eb5b267080d088bca529a5d0b54 (patch) | |
| tree | bdea7348daef7409490ba542f9bdec5d52732d03 /library/src/compute | |
| parent | 8971588486b6ffa9269344b4bda71de86af9d908 (diff) | |
Better documentation outlines
Diffstat (limited to 'library/src/compute')
| -rw-r--r-- | library/src/compute/calc.rs | 62 | ||||
| -rw-r--r-- | library/src/compute/construct.rs | 22 | ||||
| -rw-r--r-- | library/src/compute/data.rs | 12 | ||||
| -rw-r--r-- | library/src/compute/foundations.rs | 18 |
4 files changed, 57 insertions, 57 deletions
diff --git a/library/src/compute/calc.rs b/library/src/compute/calc.rs index 708d795d..6008828c 100644 --- a/library/src/compute/calc.rs +++ b/library/src/compute/calc.rs @@ -52,7 +52,7 @@ pub fn module() -> Module { /// Calculate the absolute value of a numeric value. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.abs(-5) \ /// #calc.abs(5pt - 2cm) \ @@ -86,7 +86,7 @@ cast_from_value! { /// Raise a value to some exponent. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.pow(2, 3) /// ``` @@ -133,7 +133,7 @@ pub fn pow( /// Calculate the square root of a number. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.sqrt(16) \ /// #calc.sqrt(2.5) @@ -158,7 +158,7 @@ pub fn sqrt( /// When called with an integer or a float, they will be interpreted as /// radians. /// -/// ## Example +/// ## Example { #example } /// ```example /// #assert(calc.sin(90deg) == calc.sin(-270deg)) /// #calc.sin(1.5) \ @@ -185,7 +185,7 @@ pub fn sin( /// When called with an integer or a float, they will be interpreted as /// radians. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.cos(90deg) \ /// #calc.cos(1.5) \ @@ -212,7 +212,7 @@ pub fn cos( /// When called with an integer or a float, they will be interpreted as /// radians. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.tan(1.5) \ /// #calc.tan(90deg) @@ -235,7 +235,7 @@ pub fn tan( /// Calculate the arcsine of a number. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.asin(0) \ /// #calc.asin(1) @@ -258,7 +258,7 @@ pub fn asin( /// Calculate the arccosine of a number. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.acos(0) \ /// #calc.acos(1) @@ -281,7 +281,7 @@ pub fn acos( /// Calculate the arctangent of a number. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.atan(0) \ /// #calc.atan(1) @@ -302,7 +302,7 @@ pub fn atan( /// /// The arguments are `(x, y)`, not `(y, x)`. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.atan2(1, 1) \ /// #calc.atan2(-2, -3) @@ -325,7 +325,7 @@ pub fn atan2( /// /// When called with an integer or a float, they will be interpreted as radians. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.sinh(0) \ /// #calc.sinh(45deg) @@ -350,7 +350,7 @@ pub fn sinh( /// /// When called with an integer or a float, they will be interpreted as radians. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.cosh(0) \ /// #calc.cosh(45deg) @@ -375,7 +375,7 @@ pub fn cosh( /// /// When called with an integer or a float, they will be interpreted as radians. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.tanh(0) \ /// #calc.tanh(45deg) @@ -400,7 +400,7 @@ pub fn tanh( /// /// If the base is not specified, the logarithm is calculated in base 10. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.log(100) /// ``` @@ -443,7 +443,7 @@ pub fn log( /// Calculate the factorial of a number. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.fact(5) /// ``` @@ -481,7 +481,7 @@ fn factorial_range(start: u64, end: u64) -> Option<i64> { /// Calculate a permutation. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.perm(10, 5) /// ``` @@ -509,7 +509,7 @@ pub fn perm( /// Calculate a binomial coefficient. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.binom(10, 5) /// ``` @@ -554,7 +554,7 @@ fn binomial(n: u64, k: u64) -> Option<i64> { /// Calculate the greatest common divisor of two integers. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.gcd(7, 42) /// ``` @@ -586,7 +586,7 @@ fn calculate_gcd(mut a: i64, mut b: i64) -> i64 { /// Calculate the least common multiple of two integers. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.lcm(96, 13) /// ``` @@ -622,7 +622,7 @@ fn calculate_lcm(a: i64, b: i64) -> Option<i64> { /// /// If the number is already an integer, it is returned unchanged. /// -/// ## Example +/// ## Example { #example } /// ```example /// #assert(calc.floor(3.14) == 3) /// #assert(calc.floor(3) == 3) @@ -647,7 +647,7 @@ pub fn floor( /// /// If the number is already an integer, it is returned unchanged. /// -/// ## Example +/// ## Example { #example } /// ```example /// #assert(calc.ceil(3.14) == 4) /// #assert(calc.ceil(3) == 3) @@ -672,7 +672,7 @@ pub fn ceil( /// /// If the number is already an integer, it is returned unchanged. /// -/// ## Example +/// ## Example { #example } /// ```example /// #assert(calc.trunc(3) == 3) /// #assert(calc.trunc(-3.7) == -3) @@ -697,7 +697,7 @@ pub fn trunc( /// /// If the number is an integer, it returns `0`. /// -/// ## Example +/// ## Example { #example } /// ```example /// #assert(calc.fract(3) == 0) /// #calc.fract(-3.1) @@ -721,7 +721,7 @@ pub fn fract( /// /// Optionally, a number of decimal places can be specified. /// -/// ## Example +/// ## Example { #example } /// ```example /// #assert(calc.round(3.14) == 3) /// #assert(calc.round(3.5) == 4) @@ -752,7 +752,7 @@ pub fn round( /// Clamp a number between a minimum and maximum value. /// -/// ## Example +/// ## Example { #example } /// ```example /// #assert(calc.clamp(5, 0, 10) == 5) /// #assert(calc.clamp(5, 6, 10) == 6) @@ -779,7 +779,7 @@ pub fn clamp( /// Determine the minimum of a sequence of values. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.min(1, -3, -5, 20, 3, 6) \ /// #calc.min("typst", "in", "beta") @@ -800,7 +800,7 @@ pub fn min( /// Determine the maximum of a sequence of values. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.max(1, -3, -5, 20, 3, 6) \ /// #calc.max("typst", "in", "beta") @@ -851,7 +851,7 @@ fn minmax( /// Determine whether an integer is even. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.even(4) \ /// #calc.even(5) \ @@ -871,7 +871,7 @@ pub fn even( /// Determine whether an integer is odd. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.odd(4) \ /// #calc.odd(5) \ @@ -891,7 +891,7 @@ pub fn odd( /// Calculate the remainder of two numbers. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.rem(20, 6) \ /// #calc.rem(1.75, 0.5) @@ -936,7 +936,7 @@ pub fn mod_( /// Calculate the quotient of two numbers. /// -/// ## Example +/// ## Example { #example } /// ```example /// #calc.quo(14, 5) \ /// #calc.quo(3.46, 0.5) diff --git a/library/src/compute/construct.rs b/library/src/compute/construct.rs index 4ba73a73..1c5775e5 100644 --- a/library/src/compute/construct.rs +++ b/library/src/compute/construct.rs @@ -11,7 +11,7 @@ use crate::prelude::*; /// - Floats are floored to the next 64-bit integer. /// - Strings are parsed in base 10. /// -/// ## Example +/// ## Example { #example } /// ```example /// #int(false) \ /// #int(true) \ @@ -49,7 +49,7 @@ cast_from_value! { /// - Strings are parsed in base 10 to the closest 64-bit float. /// Exponential notation is supported. /// -/// ## Example +/// ## Example { #example } /// ```example /// #float(false) \ /// #float(true) \ @@ -84,7 +84,7 @@ cast_from_value! { /// Create a grayscale color. /// -/// ## Example +/// ## Example { #example } /// ```example /// #for x in range(250, step: 50) { /// box(square(fill: luma(x))) @@ -110,7 +110,7 @@ pub fn luma( /// render them correctly, the PDF export does not handle them properly at the /// moment. This will be fixed in the future. /// -/// ## Example +/// ## Example { #example } /// ```example /// #square(fill: rgb("#b1f2eb")) /// #square(fill: rgb(87, 127, 230)) @@ -190,7 +190,7 @@ cast_from_value! { /// to RGB for display preview might differ from how your printer reproduces /// the color. /// -/// ## Example +/// ## Example { #example } /// ```example /// #square( /// fill: cmyk(27%, 0%, 3%, 5%) @@ -228,7 +228,7 @@ cast_from_value! { /// Create a custom symbol with modifiers. /// -/// ## Example +/// ## Example { #example } /// ```example /// #let envelope = symbol( /// "🖂", @@ -294,7 +294,7 @@ cast_from_value! { /// - Floats are formatted in base 10 and never in exponential notation. /// - From labels the name is extracted. /// -/// ## Example +/// ## Example { #example } /// ```example /// #str(10) \ /// #str(2.7) \ @@ -330,7 +330,7 @@ cast_from_value! { /// that is not a space. Then, the element can be [referenced]($func/ref) and /// styled through the label. /// -/// ## Example +/// ## Example { #example } /// ```example /// #show <a>: set text(blue) /// #show label("b"): set text(red) @@ -339,7 +339,7 @@ cast_from_value! { /// *Strong* #label("b") /// ``` /// -/// ## Syntax +/// ## Syntax { #syntax } /// This function also has dedicated syntax: You can create a label by enclosing /// its name in angle brackets. This works both in markup and code. /// @@ -363,7 +363,7 @@ pub fn label( /// [See here](https://docs.rs/regex/latest/regex/#syntax) for a specification /// of the supported syntax. /// -/// ## Example +/// ## Example { #example } /// ```example /// // Works with show rules. /// #show regex("\d+"): set text(red) @@ -401,7 +401,7 @@ pub fn regex( /// the range. If you pass two, they describe the `start` and `end` of the /// range. /// -/// ## Example +/// ## Example { #example } /// ```example /// #range(5) \ /// #range(2, 5) \ diff --git a/library/src/compute/data.rs b/library/src/compute/data.rs index d104cf27..d97a3782 100644 --- a/library/src/compute/data.rs +++ b/library/src/compute/data.rs @@ -6,7 +6,7 @@ use crate::prelude::*; /// /// The file will be read and returned as a string. /// -/// ## Example +/// ## Example { #example } /// ```example /// #let text = read("data.html") /// @@ -38,7 +38,7 @@ pub fn read( /// rows will be collected into a single array. Header rows will not be /// stripped. /// -/// ## Example +/// ## Example { #example } /// ```example /// #let results = csv("data.csv") /// @@ -138,7 +138,7 @@ fn format_csv_error(error: csv::Error, line: usize) -> EcoString { /// The JSON files in the example contain objects with the keys `temperature`, /// `unit`, and `weather`. /// -/// ## Example +/// ## Example { #example } /// ```example /// #let forecast(day) = block[ /// #box(square( @@ -218,7 +218,7 @@ fn format_json_error(error: serde_json::Error) -> EcoString { /// The TOML file in the example consists of a table with the keys `title`, /// `version`, and `authors`. /// -/// ## Example +/// ## Example { #example } /// ```example /// #let details = toml("details.toml") /// @@ -302,7 +302,7 @@ fn format_toml_error(error: toml::de::Error) -> EcoString { /// each with a sequence of their own submapping with the keys /// "title" and "published" /// -/// ## Example +/// ## Example { #example } /// ```example /// #let bookshelf(contents) = { /// for (author, works) in contents { @@ -384,7 +384,7 @@ fn format_yaml_error(error: serde_yaml::Error) -> EcoString { /// `content` tag contains one or more paragraphs, which are represented as `p` /// tags. /// -/// ## Example +/// ## Example { #example } /// ```example /// #let findChild(elem, tag) = { /// elem.children diff --git a/library/src/compute/foundations.rs b/library/src/compute/foundations.rs index 5127fca3..6a92c2a8 100644 --- a/library/src/compute/foundations.rs +++ b/library/src/compute/foundations.rs @@ -4,7 +4,7 @@ use crate::prelude::*; /// /// Returns the name of the value's type. /// -/// ## Example +/// ## Example { #example } /// ```example /// #type(12) \ /// #type(14.7) \ @@ -34,7 +34,7 @@ pub fn type_( /// **Note:** This function is for debugging purposes. Its output should not be /// considered stable and may change at any time! /// -/// ## Example +/// ## Example { #example } /// ```example /// #none vs #repr(none) \ /// #"hello" vs #repr("hello") \ @@ -55,7 +55,7 @@ pub fn repr( /// Fail with an error. /// -/// ## Example +/// ## Example { #example } /// The code below produces the error `panicked with: "this is wrong"`. /// ```typ /// #panic("this is wrong") @@ -91,7 +91,7 @@ pub fn panic( /// If you wish to test equality between two values, see /// [`assert.eq`]($func/assert.eq) and [`assert.ne`]($func/assert.ne). /// -/// ## Example +/// ## Example { #example } /// ```typ /// #assert(1 < 2, message: "math broke") /// ``` @@ -128,8 +128,8 @@ pub fn assert( /// Fails with an error if the first value is not equal to the second. Does not /// produce any output in the document. /// -/// ## Example -/// ```example +/// ## Example { #example } +/// ```typ /// #assert.eq(10, 10) /// ``` /// @@ -170,8 +170,8 @@ pub fn assert_eq( /// Fails with an error if the first value is equal to the second. Does not /// produce any output in the document. /// -/// ## Example -/// ```example +/// ## Example { #example } +/// ```typ /// #assert.ne(3, 4) /// ``` /// @@ -211,7 +211,7 @@ pub fn assert_ne( /// /// This function should only be used as a last resort. /// -/// ## Example +/// ## Example { #example } /// ```example /// #eval("1 + 1") \ /// #eval("(1, 2, 3, 4)").len() \ |
