summaryrefslogtreecommitdiff
path: root/library/src/compute
diff options
context:
space:
mode:
authorMALO <57839069+MDLC01@users.noreply.github.com>2023-06-24 14:33:17 +0200
committerGitHub <noreply@github.com>2023-06-24 14:33:17 +0200
commitb96b7b7ee12a5d1c8e8c24c95b58b7ca03cec44b (patch)
treea8884268565be8540c509e53f0fdbccd5e73b89f /library/src/compute
parent48c25f4da01aa5cbd5e49145f591c85b676e8a54 (diff)
Use third person in documentation (#1560)
Diffstat (limited to 'library/src/compute')
-rw-r--r--library/src/compute/calc.rs64
-rw-r--r--library/src/compute/construct.rs27
-rw-r--r--library/src/compute/data.rs12
-rw-r--r--library/src/compute/foundations.rs14
4 files changed, 58 insertions, 59 deletions
diff --git a/library/src/compute/calc.rs b/library/src/compute/calc.rs
index d8d577ad..81715007 100644
--- a/library/src/compute/calc.rs
+++ b/library/src/compute/calc.rs
@@ -51,7 +51,7 @@ pub fn module() -> Module {
Module::new("calc").with_scope(scope)
}
-/// Calculate the absolute value of a numeric value.
+/// Calculates the absolute value of a numeric value.
///
/// ## Example { #example }
/// ```example
@@ -84,7 +84,7 @@ cast! {
v: Fr => Self(Value::Fraction(v.abs())),
}
-/// Raise a value to some exponent.
+/// Raises a value to some exponent.
///
/// ## Example { #example }
/// ```example
@@ -139,7 +139,7 @@ pub fn pow(
Ok(result)
}
-/// Raise a value to some exponent of e.
+/// Raises a value to some exponent of e.
///
/// ## Example { #example }
/// ```example
@@ -173,7 +173,7 @@ pub fn exp(
Ok(result)
}
-/// Calculate the square root of a number.
+/// Extracts the square root of a number.
///
/// ## Example { #example }
/// ```example
@@ -194,7 +194,7 @@ pub fn sqrt(
Ok(value.v.float().sqrt())
}
-/// Calculate the sine of an angle.
+/// Calculates the sine of an angle.
///
/// When called with an integer or a float, they will be interpreted as
/// radians.
@@ -220,7 +220,7 @@ pub fn sin(
}
}
-/// Calculate the cosine of an angle.
+/// Calculates the cosine of an angle.
///
/// When called with an integer or a float, they will be interpreted as
/// radians.
@@ -246,7 +246,7 @@ pub fn cos(
}
}
-/// Calculate the tangent of an angle.
+/// Calculates the tangent of an angle.
///
/// When called with an integer or a float, they will be interpreted as
/// radians.
@@ -271,7 +271,7 @@ pub fn tan(
}
}
-/// Calculate the arcsine of a number.
+/// Calculates the arcsine of a number.
///
/// ## Example { #example }
/// ```example
@@ -293,7 +293,7 @@ pub fn asin(
Ok(Angle::rad(val.asin()))
}
-/// Calculate the arccosine of a number.
+/// Calculates the arccosine of a number.
///
/// ## Example { #example }
/// ```example
@@ -315,7 +315,7 @@ pub fn acos(
Ok(Angle::rad(val.acos()))
}
-/// Calculate the arctangent of a number.
+/// Calculates the arctangent of a number.
///
/// ## Example { #example }
/// ```example
@@ -333,7 +333,7 @@ pub fn atan(
Angle::rad(value.float().atan())
}
-/// Calculate the four-quadrant arctangent of a coordinate.
+/// Calculates the four-quadrant arctangent of a coordinate.
///
/// The arguments are `(x, y)`, not `(y, x)`.
///
@@ -355,7 +355,7 @@ pub fn atan2(
Angle::rad(f64::atan2(y.float(), x.float()))
}
-/// Calculate the hyperbolic sine of an angle.
+/// Calculates the hyperbolic sine of an angle.
///
/// When called with an integer or a float, they will be interpreted as radians.
///
@@ -379,7 +379,7 @@ pub fn sinh(
}
}
-/// Calculate the hyperbolic cosine of an angle.
+/// Calculates the hyperbolic cosine of an angle.
///
/// When called with an integer or a float, they will be interpreted as radians.
///
@@ -403,7 +403,7 @@ pub fn cosh(
}
}
-/// Calculate the hyperbolic tangent of an angle.
+/// Calculates the hyperbolic tangent of an angle.
///
/// When called with an integer or a float, they will be interpreted as radians.
///
@@ -427,7 +427,7 @@ pub fn tanh(
}
}
-/// Calculate the logarithm of a number.
+/// Calculates the logarithm of a number.
///
/// If the base is not specified, the logarithm is calculated in base 10.
///
@@ -475,7 +475,7 @@ pub fn log(
Ok(result)
}
-/// Calculate the natural logarithm of a number.
+/// Calculates the natural logarithm of a number.
///
/// ## Example { #example }
/// ```example
@@ -504,7 +504,7 @@ pub fn ln(
Ok(result)
}
-/// Calculate the factorial of a number.
+/// Calculates the factorial of a number.
///
/// ## Example { #example }
/// ```example
@@ -521,7 +521,7 @@ pub fn fact(
Ok(fact_impl(1, number).ok_or("the result is too large")?)
}
-/// Calculate a permutation.
+/// Calculates a permutation.
///
/// ## Example { #example }
/// ```example
@@ -562,7 +562,7 @@ fn fact_impl(start: u64, end: u64) -> Option<i64> {
count.try_into().ok()
}
-/// Calculate a binomial coefficient.
+/// Calculates a binomial coefficient.
///
/// ## Example { #example }
/// ```example
@@ -603,7 +603,7 @@ fn binom_impl(n: u64, k: u64) -> Option<i64> {
result.try_into().ok()
}
-/// Calculate the greatest common divisor of two integers.
+/// Calculates the greatest common divisor of two integers.
///
/// ## Example { #example }
/// ```example
@@ -629,7 +629,7 @@ pub fn gcd(
a.abs()
}
-/// Calculate the least common multiple of two integers.
+/// Calculates the least common multiple of two integers.
///
/// ## Example { #example }
/// ```example
@@ -655,7 +655,7 @@ pub fn lcm(
.ok_or("the return value is too large")?)
}
-/// Round a number down to the nearest integer.
+/// Rounds a number down to the nearest integer.
///
/// If the number is already an integer, it is returned unchanged.
///
@@ -679,7 +679,7 @@ pub fn floor(
}
}
-/// Round a number up to the nearest integer.
+/// Rounds a number up to the nearest integer.
///
/// If the number is already an integer, it is returned unchanged.
///
@@ -729,7 +729,7 @@ pub fn trunc(
/// Returns the fractional part of a number.
///
-/// If the number is an integer, it returns `0`.
+/// If the number is an integer, returns `0`.
///
/// ## Example { #example }
/// ```example
@@ -750,7 +750,7 @@ pub fn fract(
}
}
-/// Round a number to the nearest integer.
+/// Rounds a number to the nearest integer.
///
/// Optionally, a number of decimal places can be specified.
///
@@ -782,7 +782,7 @@ pub fn round(
}
}
-/// Clamp a number between a minimum and maximum value.
+/// Clamps a number between a minimum and maximum value.
///
/// ## Example { #example }
/// ```example
@@ -808,7 +808,7 @@ pub fn clamp(
Ok(value.apply3(min, max.v, i64::clamp, f64::clamp))
}
-/// Determine the minimum of a sequence of values.
+/// Determines the minimum of a sequence of values.
///
/// ## Example { #example }
/// ```example
@@ -830,7 +830,7 @@ pub fn min(
minmax(span, values, Ordering::Less)
}
-/// Determine the maximum of a sequence of values.
+/// Determines the maximum of a sequence of values.
///
/// ## Example { #example }
/// ```example
@@ -873,7 +873,7 @@ fn minmax(
Ok(extremum)
}
-/// Determine whether an integer is even.
+/// Determines whether an integer is even.
///
/// ## Example { #example }
/// ```example
@@ -892,7 +892,7 @@ pub fn even(
value % 2 == 0
}
-/// Determine whether an integer is odd.
+/// Determines whether an integer is odd.
///
/// ## Example { #example }
/// ```example
@@ -911,7 +911,7 @@ pub fn odd(
value % 2 != 0
}
-/// Calculate the remainder of two numbers.
+/// Calculates the remainder of two numbers.
///
/// ## Example { #example }
/// ```example
@@ -934,7 +934,7 @@ pub fn rem(
Ok(dividend.apply2(divisor.v, Rem::rem, Rem::rem))
}
-/// Calculate the quotient of two numbers.
+/// Calculates the quotient of two numbers.
///
/// ## Example { #example }
/// ```example
diff --git a/library/src/compute/construct.rs b/library/src/compute/construct.rs
index cbb50fd6..956212ee 100644
--- a/library/src/compute/construct.rs
+++ b/library/src/compute/construct.rs
@@ -7,7 +7,7 @@ use typst::eval::{Datetime, Regex};
use crate::prelude::*;
-/// Convert a value to an integer.
+/// Converts a value to an integer.
///
/// - Booleans are converted to `0` or `1`.
/// - Floats are floored to the next 64-bit integer.
@@ -42,7 +42,7 @@ cast! {
v: EcoString => Self(v.parse().map_err(|_| eco_format!("invalid integer: {}", v))?),
}
-/// Convert a value to a float.
+/// Converts a value to a float.
///
/// - Booleans are converted to `0.0` or `1.0`.
/// - Integers are converted to the closest 64-bit float.
@@ -82,7 +82,7 @@ cast! {
v: EcoString => Self(v.parse().map_err(|_| eco_format!("invalid float: {}", v))?),
}
-/// Create a grayscale color.
+/// Creates a grayscale color.
///
/// ## Example { #example }
/// ```example
@@ -101,7 +101,7 @@ pub fn luma(
LumaColor::new(gray.0).into()
}
-/// Create an RGB(A) color.
+/// Creates an RGB(A) color.
///
/// The color is specified in the sRGB color space.
///
@@ -180,7 +180,7 @@ cast! {
},
}
-/// Create a new datetime.
+/// Creates a new datetime.
///
/// You can specify the [datetime]($type/datetime) using a year, month, day,
/// hour, minute, and second. You can also get the current date with
@@ -338,7 +338,7 @@ pub fn datetime_today(
.ok_or("unable to get the current date")?)
}
-/// Create a CMYK color.
+/// Creates a CMYK color.
///
/// This is useful if you want to target a specific printer. The conversion
/// to RGB for display preview might differ from how your printer reproduces
@@ -379,7 +379,7 @@ cast! {
},
}
-/// Create a custom symbol with modifiers.
+/// Creates a custom symbol with modifiers.
///
/// ## Example { #example }
/// ```example
@@ -442,7 +442,7 @@ cast! {
},
}
-/// Convert a value to a string.
+/// Converts a value to a string.
///
/// - Integers are formatted in base 10. This can be overridden with the
/// optional `base` parameter.
@@ -567,7 +567,7 @@ pub fn str_to_unicode(
value.into()
}
-/// Converts a unicode code point into its corresponding string.
+/// Converts a Unicode code point into its corresponding string.
///
/// ```example
/// #str.from-unicode(97)
@@ -595,7 +595,7 @@ cast! {
},
}
-/// Create a label from a string.
+/// Creates a label from a string.
///
/// Inserting a label into content attaches it to the closest previous element
/// that is not a space. Then, the element can be [referenced]($func/ref) and
@@ -624,14 +624,13 @@ pub fn label(
Label(name)
}
-/// Create a regular expression from a string.
+/// Creates a regular expression from a string.
///
/// The result can be used as a
/// [show rule selector]($styling/#show-rules) and with
/// [string methods]($type/string) like `find`, `split`, and `replace`.
///
-/// [See here](https://docs.rs/regex/latest/regex/#syntax) for a specification
-/// of the supported syntax.
+/// See [the specification of the supported syntax](https://docs.rs/regex/latest/regex/#syntax).
///
/// ## Example { #example }
/// ```example
@@ -664,7 +663,7 @@ pub fn regex(
Regex::new(&regex.v).at(regex.span)
}
-/// Create an array consisting of a sequence of numbers.
+/// Creates an array consisting of consecutive integers.
///
/// If you pass just one positional parameter, it is interpreted as the `end` of
/// the range. If you pass two, they describe the `start` and `end` of the
diff --git a/library/src/compute/data.rs b/library/src/compute/data.rs
index 0d4d4865..1d6bec60 100644
--- a/library/src/compute/data.rs
+++ b/library/src/compute/data.rs
@@ -3,7 +3,7 @@ use typst::eval::Datetime;
use crate::prelude::*;
-/// Read plain text from a file.
+/// Reads plain text from a file.
///
/// The file will be read and returned as a string.
///
@@ -33,7 +33,7 @@ pub fn read(
Ok(text.into())
}
-/// Read structured data from a CSV file.
+/// Reads structured data from a CSV file.
///
/// The CSV file will be read and parsed into a 2-dimensional array of strings:
/// Each row in the CSV file will be represented as an array of strings, and all
@@ -129,7 +129,7 @@ fn format_csv_error(error: csv::Error, line: usize) -> EcoString {
}
}
-/// Read structured data from a JSON file.
+/// Reads structured data from a JSON file.
///
/// The file must contain a valid JSON object or array. JSON objects will be
/// converted into Typst dictionaries, and JSON arrays will be converted into
@@ -211,7 +211,7 @@ fn format_json_error(error: serde_json::Error) -> EcoString {
eco_format!("failed to parse json file: syntax error in line {}", error.line())
}
-/// Read structured data from a TOML file.
+/// Reads structured data from a TOML file.
///
/// The file must contain a valid TOML table. TOML tables will be
/// converted into Typst dictionaries, and TOML arrays will be converted into
@@ -304,7 +304,7 @@ fn format_toml_error(error: toml::de::Error) -> EcoString {
}
}
-/// Read structured data from a YAML file.
+/// Reads structured data from a YAML file.
///
/// The file must contain a valid YAML object or array. YAML mappings will be
/// converted into Typst dictionaries, and YAML sequences will be converted into
@@ -396,7 +396,7 @@ fn format_yaml_error(error: serde_yaml::Error) -> EcoString {
eco_format!("failed to parse yaml file: {}", error.to_string().trim())
}
-/// Read structured data from an XML file.
+/// Reads structured data from an XML file.
///
/// The XML file is parsed into an array of dictionaries and strings. XML nodes
/// can be elements or strings. Elements are represented as dictionaries with
diff --git a/library/src/compute/foundations.rs b/library/src/compute/foundations.rs
index 7964ac45..f83d71a0 100644
--- a/library/src/compute/foundations.rs
+++ b/library/src/compute/foundations.rs
@@ -1,6 +1,6 @@
use crate::prelude::*;
-/// Determine a value's type.
+/// Determines the type of a value.
///
/// Returns the name of the value's type.
///
@@ -24,7 +24,7 @@ pub fn type_(
value.type_name().into()
}
-/// The string representation of a value.
+/// Returns the string representation of a value.
///
/// When inserted into content, most values are displayed as this representation
/// in monospace with syntax-highlighting. The exceptions are `{none}`,
@@ -51,7 +51,7 @@ pub fn repr(
value.repr()
}
-/// Fail with an error.
+/// Fails with an error.
///
/// ## Example { #example }
/// The code below produces the error `panicked with: "this is wrong"`.
@@ -80,7 +80,7 @@ pub fn panic(
Err(msg)
}
-/// Ensure that a condition is fulfilled.
+/// Ensures that a condition is fulfilled.
///
/// Fails with an error if the condition is not fulfilled. Does not
/// produce any output in the document.
@@ -118,7 +118,7 @@ pub fn assert(
Ok(NoneValue)
}
-/// Ensure that two values are equal.
+/// Ensures that two values are equal.
///
/// Fails with an error if the first value is not equal to the second. Does not
/// produce any output in the document.
@@ -153,7 +153,7 @@ pub fn assert_eq(
Ok(NoneValue)
}
-/// Ensure that two values are not equal.
+/// Ensures that two values are not equal.
///
/// Fails with an error if the first value is equal to the second. Does not
/// produce any output in the document.
@@ -188,7 +188,7 @@ pub fn assert_ne(
Ok(NoneValue)
}
-/// Evaluate a string as Typst code.
+/// Evaluates a string as Typst code.
///
/// This function should only be used as a last resort.
///