summaryrefslogtreecommitdiff
path: root/library/src/compute
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-12-22 00:34:03 +0100
committerLaurenz <laurmaedje@gmail.com>2022-12-22 00:34:03 +0100
commit990224c0f8bcf885d3bca58f3f1a87b54c180f52 (patch)
tree595d79acc43bc25c1854424a9a14b756413858a2 /library/src/compute
parent4c92ab4ace41a20ccea59bbdf6917b5dfa29121f (diff)
Annotate return values
Diffstat (limited to 'library/src/compute')
-rw-r--r--library/src/compute/calc.rs10
-rw-r--r--library/src/compute/construct.rs18
-rw-r--r--library/src/compute/data.rs7
-rw-r--r--library/src/compute/foundations.rs8
-rw-r--r--library/src/compute/utility.rs10
5 files changed, 47 insertions, 6 deletions
diff --git a/library/src/compute/calc.rs b/library/src/compute/calc.rs
index b5bc0fea..830f5033 100644
--- a/library/src/compute/calc.rs
+++ b/library/src/compute/calc.rs
@@ -51,6 +51,8 @@ castable! {
/// The sequence of values from which to extract the minimum.
/// Must not be empty.
///
+/// - returns: any
+///
/// ## Category
/// calculate
#[func]
@@ -72,6 +74,8 @@ pub fn min(args: &mut Args) -> SourceResult<Value> {
/// The sequence of values from which to extract the maximum.
/// Must not be empty.
///
+/// - returns: any
+///
/// ## Category
/// calculate
#[func]
@@ -114,6 +118,8 @@ fn minmax(args: &mut Args, goal: Ordering) -> SourceResult<Value> {
/// - value: i64 (positional, required)
/// The number to check for evenness.
///
+/// - returns: boolean
+///
/// ## Category
/// calculate
#[func]
@@ -136,6 +142,8 @@ pub fn even(args: &mut Args) -> SourceResult<Value> {
/// - value: i64 (positional, required)
/// The number to check for oddness.
///
+/// - returns: boolean
+///
/// ## Category
/// calculate
#[func]
@@ -159,6 +167,8 @@ pub fn odd(args: &mut Args) -> SourceResult<Value> {
/// - divisor: ToMod (positional, required)
/// The divisor of the modulus.
///
+/// - returns: integer or float
+///
/// ## Category
/// calculate
#[func]
diff --git a/library/src/compute/construct.rs b/library/src/compute/construct.rs
index bfe42cbe..81a8b990 100644
--- a/library/src/compute/construct.rs
+++ b/library/src/compute/construct.rs
@@ -23,6 +23,8 @@ use crate::prelude::*;
/// - value: ToInt (positional, required)
/// The value that should be converted to an integer.
///
+/// - returns: integer
+///
/// ## Category
/// construct
#[func]
@@ -62,6 +64,8 @@ castable! {
/// - value: ToFloat (positional, required)
/// The value that should be converted to a float.
///
+/// - returns: float
+///
/// ## Category
/// construct
#[func]
@@ -94,6 +98,8 @@ castable! {
/// - gray: Component (positional, required)
/// The gray component.
///
+/// - returns: color
+///
/// ## Category
/// construct
#[func]
@@ -146,6 +152,8 @@ pub fn luma(args: &mut Args) -> SourceResult<Value> {
/// - alpha: Component (positional)
/// The alpha component.
///
+/// - returns: color
+///
/// ## Category
/// construct
#[func]
@@ -207,6 +215,8 @@ castable! {
/// - key: RatioComponent (positional, required)
/// The key component.
///
+/// - returns: color
+///
/// ## Category
/// construct
#[func]
@@ -249,6 +259,8 @@ castable! {
/// - value: ToStr (positional, required)
/// The value that should be converted to a string.
///
+/// - returns: string
+///
/// ## Category
/// construct
#[func]
@@ -291,6 +303,8 @@ castable! {
/// - name: EcoString (positional, required)
/// The name of the label.
///
+/// - returns: label
+///
/// ## Category
/// construct
#[func]
@@ -330,6 +344,8 @@ pub fn label(args: &mut Args) -> SourceResult<Value> {
/// Typst (e.g. `[\\]`), you need to escape twice. Thus, to match a verbatim
/// backslash, you would need to write `{regex("\\\\")}`.
///
+/// - returns: regex
+///
/// ## Category
/// construct
#[func]
@@ -364,6 +380,8 @@ pub fn regex(args: &mut Args) -> SourceResult<Value> {
/// - step: i64 (named)
/// The distance between the generated numbers.
///
+/// - returns: array
+///
/// ## Category
/// construct
#[func]
diff --git a/library/src/compute/data.rs b/library/src/compute/data.rs
index 43d06753..ee209074 100644
--- a/library/src/compute/data.rs
+++ b/library/src/compute/data.rs
@@ -26,11 +26,14 @@ use crate::prelude::*;
/// ## Parameters
/// - path: EcoString (positional, required)
/// Path to a CSV file.
+///
/// - delimiter: Delimiter (named)
/// The delimiter that separates columns in the CSV file.
/// Must be a single ASCII character.
/// Defaults to a comma.
///
+/// - returns: array
+///
/// ## Category
/// data-loading
#[func]
@@ -140,6 +143,8 @@ fn format_csv_error(error: csv::Error) -> String {
/// - path: EcoString (positional, required)
/// Path to a JSON file.
///
+/// - returns: dictionary or array
+///
/// ## Category
/// data-loading
#[func]
@@ -236,6 +241,8 @@ fn format_json_error(error: serde_json::Error) -> String {
/// - path: EcoString (positional, required)
/// Path to an XML file.
///
+/// - returns: array
+///
/// ## Category
/// data-loading
#[func]
diff --git a/library/src/compute/foundations.rs b/library/src/compute/foundations.rs
index 06795887..4e8b9d82 100644
--- a/library/src/compute/foundations.rs
+++ b/library/src/compute/foundations.rs
@@ -7,7 +7,7 @@ use typst::syntax::Source;
/// # Type
/// Determine a value's type.
///
-/// Returns the name of the value's type as a string.
+/// Returns the name of the value's type.
///
/// ## Example
/// ```
@@ -23,6 +23,8 @@ use typst::syntax::Source;
/// - value: Value (positional, required)
/// The value whose type's to determine.
///
+/// - returns: string
+///
/// ## Category
/// foundations
#[func]
@@ -49,6 +51,8 @@ pub fn type_(args: &mut Args) -> SourceResult<Value> {
/// - value: Value (positional, required)
/// The value whose string representation to produce.
///
+/// - returns: string
+///
/// ## Category
/// foundations
#[func]
@@ -99,6 +103,8 @@ pub fn assert(args: &mut Args) -> SourceResult<Value> {
///
/// The markup and code in the string cannot interact with the file system.
///
+/// - returns: content
+///
/// ## Category
/// foundations
#[func]
diff --git a/library/src/compute/utility.rs b/library/src/compute/utility.rs
index be260a5f..78cf3953 100644
--- a/library/src/compute/utility.rs
+++ b/library/src/compute/utility.rs
@@ -24,6 +24,8 @@ use crate::text::Case;
/// - words: usize (positional, required)
/// The length of the blind text in words.
///
+/// - returns: string
+///
/// ## Category
/// utility
#[func]
@@ -71,6 +73,8 @@ pub fn lorem(args: &mut Args) -> SourceResult<Value> {
/// If more numbers than counting symbols are given, the last counting symbol
/// with its prefix is repeated.
///
+/// - returns: string
+///
/// ## Category
/// utility
#[func]
@@ -139,11 +143,7 @@ impl FromStr for NumberingPattern {
};
let prefix = pattern[handled..i].into();
- let case = if c.is_uppercase() {
- Case::Upper
- } else {
- Case::Lower
- };
+ let case = if c.is_uppercase() { Case::Upper } else { Case::Lower };
pieces.push((prefix, kind, case));
handled = i + 1;
}