diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-19 22:28:49 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-19 22:39:19 +0100 |
| commit | ab43bd802eafe33977a91893907e67553e099569 (patch) | |
| tree | af4dead92b143348f52e2e8f869df3f7dfd7322a /docs | |
| parent | d6aaae0cea1e79eecd85dc94ab85b9ad8eff48e8 (diff) | |
Renaming and refactoring
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/src/lib.rs | 14 | ||||
| -rw-r--r-- | docs/src/reference/scripting.md | 2 | ||||
| -rw-r--r-- | docs/src/reference/types.md | 58 | ||||
| -rw-r--r-- | docs/src/tutorial/4-template.md | 7 |
4 files changed, 41 insertions, 40 deletions
diff --git a/docs/src/lib.rs b/docs/src/lib.rs index 563d565c..97535b1a 100644 --- a/docs/src/lib.rs +++ b/docs/src/lib.rs @@ -18,7 +18,7 @@ use typst::doc::Frame; use typst::eval::{CastInfo, Func, FuncInfo, Library, Module, ParamInfo, Value}; use typst::font::{Font, FontBook}; use typst::geom::{Abs, Sides, Smart}; -use typst_library::layout::PageNode; +use typst_library::layout::PageElem; use unscanny::Scanner; static SRC: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/src"); @@ -40,9 +40,9 @@ static FONTS: Lazy<(Prehashed<FontBook>, Vec<Font>)> = Lazy::new(|| { static LIBRARY: Lazy<Prehashed<Library>> = Lazy::new(|| { let mut lib = typst_library::build(); lib.styles - .set(PageNode::set_width(Smart::Custom(Abs::pt(240.0).into()))); - lib.styles.set(PageNode::set_height(Smart::Auto)); - lib.styles.set(PageNode::set_margin(Sides::splat(Some(Smart::Custom( + .set(PageElem::set_width(Smart::Custom(Abs::pt(240.0).into()))); + lib.styles.set(PageElem::set_height(Smart::Auto)); + lib.styles.set(PageElem::set_margin(Sides::splat(Some(Smart::Custom( Abs::pt(15.0).into(), ))))); typst::eval::set_lang_items(lib.items.clone()); @@ -299,8 +299,8 @@ pub struct FuncModel { pub name: &'static str, pub display: &'static str, pub oneliner: &'static str, - pub details: Html, pub showable: bool, + pub details: Html, pub params: Vec<ParamModel>, pub returns: Vec<&'static str>, } @@ -336,8 +336,8 @@ fn func_model(resolver: &dyn Resolver, func: &Func, info: &FuncInfo) -> FuncMode name: info.name.into(), display: info.display, oneliner: oneliner(info.docs), + showable: func.element().is_some(), details: Html::markdown(resolver, info.docs), - showable: func.select(None).is_ok() && info.category != "math", params: info.params.iter().map(|param| param_model(resolver, param)).collect(), returns: info.returns.clone(), } @@ -632,7 +632,7 @@ fn symbol_page(resolver: &dyn Resolver, parent: &str, name: &str) -> PageModel { .find(|&(_, x)| x == c) .map(|(s, _)| s), codepoint: c as u32, - accent: typst::eval::combining_accent(c).is_some(), + accent: typst::eval::Symbol::combining_accent(c).is_some(), unicode_name: unicode_names2::name(c) .map(|s| s.to_string().to_title_case()), alternates: symbol diff --git a/docs/src/reference/scripting.md b/docs/src/reference/scripting.md index 68e73c62..1aa399d1 100644 --- a/docs/src/reference/scripting.md +++ b/docs/src/reference/scripting.md @@ -138,7 +138,7 @@ For loops can iterate over a variety of collections: - `{for value in array {..}}` \ `{for index, value in array {..}}`\ Iterates over the items in the [array]($type/array). Can also provide the - index of each element. + index of each item. - `{for value in dict {..}}` \ `{for key, value in dict {..}}` \ diff --git a/docs/src/reference/types.md b/docs/src/reference/types.md index 355027f5..a64f4eb3 100644 --- a/docs/src/reference/types.md +++ b/docs/src/reference/types.md @@ -420,7 +420,7 @@ A sequence of values. You can construct an array by enclosing a comma-separated sequence of values in parentheses. The values do not have to be of the same type. -You can access and update array elements with the `.at()` method. Indices are +You can access and update array items with the `.at()` method. Indices are zero-based and negative indices wrap around to the end of the array. You can iterate over an array using a [for loop]($scripting/#loops). Arrays can be added together with the `+` operator, @@ -453,26 +453,26 @@ The number of values in the array. - returns: integer ### first() -Returns the first element in the array. +Returns the first item in the array. May be used on the left-hand side of an assignment. Fails with an error if the array is empty. - returns: any ### last() -Returns the last element in the array. +Returns the last item in the array. May be used on the left-hand side of an assignment. Fails with an error if the array is empty. - returns: any ### at() -Returns the element at the specified index in the array. +Returns the item at the specified index in the array. May be used on the left-hand side of an assignment. Fails with an error if the index is out of bounds. - index: integer (positional, required) - The index at which to retrieve the element. + The index at which to retrieve the item. - returns: any ### push() @@ -482,7 +482,7 @@ Add a value to the end of the array. The value to insert at the end of the array. ### pop() -Remove the last element from the array and return it. +Remove the last item from the array and return it. Fails with an error if the array is empty. - returns: any @@ -493,7 +493,7 @@ Insert a value into the array at the specified index. Fails with an error if the index is out of bounds. - index: integer (positional, required) - The index at which to insert the element. + The index at which to insert the item. - value: any (positional, required) The value to insert into the array. @@ -501,7 +501,7 @@ Fails with an error if the index is out of bounds. Remove the value at the specified index from the array and return it. - index: integer (positional, required) - The index at which to remove the element. + The index at which to remove the item. - returns: any ### slice() @@ -514,7 +514,7 @@ Fails with an error if the start or index is out of bounds. The end index (exclusive). If omitted, the whole slice until the end of the array is extracted. - count: integer (named) - The number of elements to extract. This is equivalent to passing `start + + The number of items to extract. This is equivalent to passing `start + count` as the `end` position. Mutually exclusive with `end`. - returns: array @@ -529,59 +529,59 @@ of `{(1, 2, 3).contains(2)}`. - returns: boolean ### find() -Searches for an element for which the given function returns `{true}` and +Searches for an item for which the given function returns `{true}` and returns the first match or `{none}` if there is no match. - searcher: function (positional, required) - The function to apply to each element. Must return a boolean. + The function to apply to each item. Must return a boolean. - returns: any or none ### position() -Searches for an element for which the given function returns `{true}` and +Searches for an item for which the given function returns `{true}` and returns the index of the first match or `{none}` if there is no match. - searcher: function (positional, required) - The function to apply to each element. Must return a boolean. + The function to apply to each item. Must return a boolean. - returns: integer or none ### filter() -Produces a new array with only the elements from the original one for which the +Produces a new array with only the items from the original one for which the given function returns true. - test: function (positional, required) - The function to apply to each element. Must return a boolean. + The function to apply to each item. Must return a boolean. - returns: array ### map() -Produces a new array in which all elements from the original one were +Produces a new array in which all items from the original one were transformed with the given function. - mapper: function (positional, required) - The function to apply to each element. + The function to apply to each item. - returns: array ### fold() -Folds all elements into a single value using an accumulator function. +Folds all items into a single value using an accumulator function. - init: any (positional, required) The initial value to start with. - folder: function (positional, required) The folding function. Must have two parameters: One for the accumulated value - and one for an element. + and one for an item. - returns: any ### any() -Whether the given function returns `{true}` for any element in the array. +Whether the given function returns `{true}` for any item in the array. - test: function (positional, required) - The function to apply to each element. Must return a boolean. + The function to apply to each item. Must return a boolean. - returns: boolean ### all() -Whether the given function returns `{true}` for all elements in the array. +Whether the given function returns `{true}` for all items in the array. - test: function (positional, required) - The function to apply to each element. Must return a boolean. + The function to apply to each item. Must return a boolean. - returns: boolean ### flatten() @@ -590,21 +590,21 @@ Combine all nested arrays into a single flat one. - returns: array ### rev() -Return a new array with the same elements, but in reverse order. +Return a new array with the same items, but in reverse order. - returns: array ### join() -Combine all elements in the array into one. +Combine all items in the array into one. - separator: any (positional) - A value to insert between each element of the array. + A value to insert between each item of the array. - last: any (named) - An alternative separator between the last two elements + An alternative separator between the last two items - returns: any ### sorted() -Return a new array with the same elements, but sorted. +Return a new array with the same items, but sorted. - returns: array @@ -658,7 +658,7 @@ present in the dictionary. Fails with an error if the key is not part of the dictionary. - index: integer (positional, required) - The index at which to retrieve the element. + The index at which to retrieve the item. - returns: any ### insert() diff --git a/docs/src/tutorial/4-template.md b/docs/src/tutorial/4-template.md index d49ee6a1..3208f012 100644 --- a/docs/src/tutorial/4-template.md +++ b/docs/src/tutorial/4-template.md @@ -206,11 +206,12 @@ from the dictionary, we use the [field access syntax]($scripting/#fields). We still have to provide an argument to the grid for each author: Here is where the array's [`map` method]($type/array.map) comes in handy. It takes a function -as an argument that gets called with each element of the array. We pass it a +as an argument that gets called with each item of the array. We pass it a function that formats the details for each author and returns a new array containing content values. We've now got one array of values that we'd like to -use as multiple arguments for the grid. We can do that by using the -[`spread` operator]($type/arguments). It takes an array and applies each of its elements as a separate argument to the function. +use as multiple arguments for the grid. We can do that by using the [`spread` +operator]($type/arguments). It takes an array and applies each of its items as a +separate argument to the function. The resulting template function looks like this: |
