From 9c29dbf84f7d58d3dd85dfa2c336a72562ff6814 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 29 Oct 2023 19:35:44 +0100 Subject: [PATCH] Docs fixes --- crates/typst-docs/src/lib.rs | 8 ++++---- crates/typst/src/eval/version.rs | 15 +++++++++------ docs/reference/groups.yml | 15 +++++++++++++-- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/crates/typst-docs/src/lib.rs b/crates/typst-docs/src/lib.rs index d32b5d66f..9aa49139a 100644 --- a/crates/typst-docs/src/lib.rs +++ b/crates/typst-docs/src/lib.rs @@ -180,8 +180,8 @@ fn category_page(resolver: &dyn Resolver, category: &str) -> PageModel { // Add groups. for mut group in GROUPS.iter().filter(|g| g.category == category).cloned() { let mut focus = module; - if group.name == "calc" { - focus = get_module(focus, "calc").unwrap(); + if matches!(group.name.as_str(), "calc" | "sys") { + focus = get_module(focus, &group.name).unwrap(); group.functions = focus .scope() .iter() @@ -369,8 +369,8 @@ fn param_model(resolver: &dyn Resolver, info: &ParamInfo) -> ParamModel { let mut types = vec![]; let mut strings = vec![]; casts(resolver, &mut types, &mut strings, &info.input); - if !strings.is_empty() && !types.contains(&"string") { - types.push("string"); + if !strings.is_empty() && !types.contains(&"str") { + types.push("str"); } types.sort_by_key(|ty| type_index(ty)); diff --git a/crates/typst/src/eval/version.rs b/crates/typst/src/eval/version.rs index e2b4ac520..bf4887920 100644 --- a/crates/typst/src/eval/version.rs +++ b/crates/typst/src/eval/version.rs @@ -9,15 +9,18 @@ use super::{cast, func, scope, ty, Repr}; use crate::diag::{bail, error, StrResult}; use crate::util::pretty_array_like; -/// A version, with any number of components. +/// A version with an arbitrary number of components. +/// +/// The first three components have names that can be used as fields: `major`, +/// `minor`, `patch`. All following components do not have names. /// /// The list of components is semantically extended by an infinite list of /// zeros. This means that, for example, `0.8` is the same as `0.8.0`. As a /// special case, the empty version (that has no components at all) is the same /// as `0`, `0.0`, `0.0.0`, and so on. /// -/// The first three components have names: `major`, `minor`, `patch`. All -/// components after that do not have names. +/// You can convert a version to an array of explicitly given components using +/// the [`array`]($array) constructor. #[ty(scope)] #[derive(Debug, Default, Clone, Hash)] #[allow(clippy::derived_hash_with_manual_eq)] @@ -88,10 +91,10 @@ impl Version { version } - /// Get a component of a version. + /// Retrieves a component of a version. /// - /// Always non-negative. Returns `0` if the version isn't specified to the - /// necessary length. + /// The returned integer is always non-negative. Returns `0` if the version + /// isn't specified to the necessary length. #[func] pub fn at( &self, diff --git a/docs/reference/groups.yml b/docs/reference/groups.yml index cbf9cfec9..c6ec45333 100644 --- a/docs/reference/groups.yml +++ b/docs/reference/groups.yml @@ -109,8 +109,19 @@ category: foundations path: ["calc"] description: | - Calculations and processing of numeric values. + Module for calculations and processing of numeric values. - These functions are part of the `calc` module and not imported by default. + These definitions are part of the `calc` module and not imported by default. In addition to the functions listed below, the `calc` module also defines the constants `pi`, `tau`, `e`, `inf`, and `nan`. + +- name: sys + display: System + category: foundations + path: ["sys"] + description: | + Module for system interactions. + + Currently, this module defines a single item: The `sys.version` constant + (of type [`version`]($version)), that specifies the currently active + Typst compiler version.