summaryrefslogtreecommitdiff
path: root/library/src/compute
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-05-17 14:41:46 +0200
committerLaurenz <laurmaedje@gmail.com>2023-05-17 14:41:46 +0200
commit551ea99d05166b0be50792f767ddd38b996e32fa (patch)
treeec5e86a087e79e8c181c7d4b904216a775227e2d /library/src/compute
parent46aace78ac4ac1c075b9b1670dbb7372df1a0a82 (diff)
Show default values in documentation
Fixes #169 Fixes #1102
Diffstat (limited to 'library/src/compute')
-rw-r--r--library/src/compute/calc.rs2
-rw-r--r--library/src/compute/construct.rs5
-rw-r--r--library/src/compute/data.rs31
3 files changed, 19 insertions, 19 deletions
diff --git a/library/src/compute/calc.rs b/library/src/compute/calc.rs
index 6008828c..bd673c54 100644
--- a/library/src/compute/calc.rs
+++ b/library/src/compute/calc.rs
@@ -412,7 +412,7 @@ pub fn tanh(
pub fn log(
/// The number whose logarithm to calculate. Must be strictly positive.
value: Spanned<Num>,
- /// The base of the logarithm. Defaults to `{10}` and may not be zero.
+ /// The base of the logarithm. May not be zero.
#[named]
#[default(Spanned::new(10.0, Span::detached()))]
base: Spanned<f64>,
diff --git a/library/src/compute/construct.rs b/library/src/compute/construct.rs
index 1c5775e5..d39b69dd 100644
--- a/library/src/compute/construct.rs
+++ b/library/src/compute/construct.rs
@@ -135,23 +135,18 @@ pub fn rgb(
/// ]
/// ```
#[external]
- #[default]
hex: EcoString,
/// The red component.
#[external]
- #[default]
red: Component,
/// The green component.
#[external]
- #[default]
green: Component,
/// The blue component.
#[external]
- #[default]
blue: Component,
/// The alpha component.
#[external]
- #[default]
alpha: Component,
) -> Value {
Value::Color(if let Some(string) = args.find::<Spanned<EcoString>>()? {
diff --git a/library/src/compute/data.rs b/library/src/compute/data.rs
index d97a3782..90ac03c9 100644
--- a/library/src/compute/data.rs
+++ b/library/src/compute/data.rs
@@ -58,7 +58,6 @@ pub fn csv(
path: Spanned<EcoString>,
/// The delimiter that separates columns in the CSV file.
/// Must be a single ASCII character.
- /// Defaults to a comma.
#[named]
#[default]
delimiter: Delimiter,
@@ -69,7 +68,7 @@ pub fn csv(
let mut builder = csv::ReaderBuilder::new();
builder.has_headers(false);
- builder.delimiter(delimiter.0);
+ builder.delimiter(delimiter.0 as u8);
let mut reader = builder.from_reader(data.as_slice());
let mut array = Array::new();
@@ -87,7 +86,7 @@ pub fn csv(
}
/// The delimiter to use when parsing CSV files.
-struct Delimiter(u8);
+struct Delimiter(char);
cast_from_value! {
Delimiter,
@@ -102,13 +101,17 @@ cast_from_value! {
Err("delimiter must be an ASCII character")?
}
- Self(first as u8)
+ Self(first)
},
}
+cast_to_value! {
+ v: Delimiter => v.0.into()
+}
+
impl Default for Delimiter {
fn default() -> Self {
- Self(b',')
+ Self(',')
}
}
@@ -313,7 +316,9 @@ fn format_toml_error(error: toml::de::Error) -> EcoString {
/// }
/// }
///
-/// #bookshelf(yaml("scifi-authors.yaml"))
+/// #bookshelf(
+/// yaml("scifi-authors.yaml")
+/// )
/// ```
///
/// Display: YAML
@@ -386,15 +391,15 @@ fn format_yaml_error(error: serde_yaml::Error) -> EcoString {
///
/// ## Example { #example }
/// ```example
-/// #let findChild(elem, tag) = {
+/// #let find-child(elem, tag) = {
/// elem.children
/// .find(e => "tag" in e and e.tag == tag)
/// }
///
/// #let article(elem) = {
-/// let title = findChild(elem, "title")
-/// let author = findChild(elem, "author")
-/// let pars = findChild(elem, "content")
+/// let title = find-child(elem, "title")
+/// let author = find-child(elem, "author")
+/// let pars = find-child(elem, "content")
///
/// heading(title.children.first())
/// text(10pt, weight: "medium")[
@@ -411,9 +416,9 @@ fn format_yaml_error(error: serde_yaml::Error) -> EcoString {
/// }
///
/// #let data = xml("example.xml")
-/// #for child in data.first().children {
-/// if (type(child) == "dictionary") {
-/// article(child)
+/// #for elem in data.first().children {
+/// if (type(elem) == "dictionary") {
+/// article(elem)
/// }
/// }
/// ```