Touch up docs a little
This commit is contained in:
parent
5df550f8e8
commit
6aa9dbfbe6
@ -37,16 +37,16 @@ fn split_link(link: &str) -> StrResult<(&str, &str)> {
|
||||
/// Resolve a `$` link head to a known destination.
|
||||
fn resolve_known(head: &str) -> Option<&'static str> {
|
||||
Some(match head {
|
||||
"$tutorial" => "/docs/tutorial/",
|
||||
"$reference" => "/docs/reference/",
|
||||
"$category" => "/docs/reference/",
|
||||
"$syntax" => "/docs/reference/syntax/",
|
||||
"$styling" => "/docs/reference/styling/",
|
||||
"$scripting" => "/docs/reference/scripting/",
|
||||
"$guides" => "/docs/guides/",
|
||||
"$packages" => "/docs/packages/",
|
||||
"$changelog" => "/docs/changelog/",
|
||||
"$community" => "/docs/community/",
|
||||
"$tutorial" => "/docs/tutorial",
|
||||
"$reference" => "/docs/reference",
|
||||
"$category" => "/docs/reference",
|
||||
"$syntax" => "/docs/reference/syntax",
|
||||
"$styling" => "/docs/reference/styling",
|
||||
"$scripting" => "/docs/reference/scripting",
|
||||
"$guides" => "/docs/guides",
|
||||
"$packages" => "/docs/packages",
|
||||
"$changelog" => "/docs/changelog",
|
||||
"$community" => "/docs/community",
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
@ -648,7 +648,7 @@ impl Array {
|
||||
/// A value to insert between each item of the array.
|
||||
#[default]
|
||||
separator: Option<Value>,
|
||||
/// An alternative separator between the last two items
|
||||
/// An alternative separator between the last two items.
|
||||
#[named]
|
||||
last: Option<Value>,
|
||||
) -> StrResult<Value> {
|
||||
@ -675,7 +675,11 @@ impl Array {
|
||||
/// Returns an array with a copy of the separator value placed between
|
||||
/// adjacent elements.
|
||||
#[func]
|
||||
pub fn intersperse(&self, sep: Value) -> Array {
|
||||
pub fn intersperse(
|
||||
&self,
|
||||
/// The value that will be placed between each adjacent element.
|
||||
separator: Value,
|
||||
) -> Array {
|
||||
// TODO: Use once stabilized:
|
||||
// https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.intersperse
|
||||
let size = match self.len() {
|
||||
@ -690,7 +694,7 @@ impl Array {
|
||||
}
|
||||
|
||||
for value in iter {
|
||||
vec.push(sep.clone());
|
||||
vec.push(separator.clone());
|
||||
vec.push(value);
|
||||
}
|
||||
|
||||
|
@ -18,11 +18,40 @@ pub use typst_macros::{scope, ty};
|
||||
/// shapes, and more. Typst categorizes these into clearly defined _types_ and
|
||||
/// tells you where it expects which type of value.
|
||||
///
|
||||
/// Apart from very basic types for numeric values and [typical]($int)
|
||||
/// Apart from basic types for numeric values and [typical]($int)
|
||||
/// [types]($float) [known]($str) [from]($array) [programming]($dictionary)
|
||||
/// languages, Typst provides a special type for [_content._]($content) A value
|
||||
/// of this type can hold anything that you can enter into your document: Text,
|
||||
/// elements like headings and shapes, and style information.
|
||||
///
|
||||
/// # Example
|
||||
/// ```example
|
||||
/// #let x = 10
|
||||
/// #if type(x) == int [
|
||||
/// #x is an integer!
|
||||
/// ] else [
|
||||
/// #x is another value...
|
||||
/// ]
|
||||
///
|
||||
/// An image is of type
|
||||
/// #type(image("glacier.jpg")).
|
||||
/// ```
|
||||
///
|
||||
/// The type of `10` is `int`. Now, what is the type of `int` or even `type`?
|
||||
/// ```example
|
||||
/// #type(int) \
|
||||
/// #type(type)
|
||||
/// ```
|
||||
///
|
||||
/// # Compatibility
|
||||
/// In Typst 0.7 and lower, the `type` function returned a string instead of a
|
||||
/// type. Compatibility with the old way will remain for a while to give package
|
||||
/// authors time to upgrade, but it will be removed at some point.
|
||||
///
|
||||
/// - Checks like `{int == "integer"}` evaluate to `{true}`
|
||||
/// - Adding/joining a type and string will yield a string
|
||||
/// - The `{in}` operator on a type and a dictionary will evaluate to `{true}`
|
||||
/// if the dictionary has a string key matching the type's name
|
||||
#[ty(scope)]
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
|
||||
pub struct Type(Static<NativeTypeData>);
|
||||
|
Loading…
x
Reference in New Issue
Block a user