diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-05-17 14:41:46 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-05-17 14:41:46 +0200 |
| commit | 551ea99d05166b0be50792f767ddd38b996e32fa (patch) | |
| tree | ec5e86a087e79e8c181c7d4b904216a775227e2d /library/src/compute/data.rs | |
| parent | 46aace78ac4ac1c075b9b1670dbb7372df1a0a82 (diff) | |
Show default values in documentation
Fixes #169
Fixes #1102
Diffstat (limited to 'library/src/compute/data.rs')
| -rw-r--r-- | library/src/compute/data.rs | 31 |
1 files changed, 18 insertions, 13 deletions
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) /// } /// } /// ``` |
