Docs fixes

This commit is contained in:
Laurenz 2023-10-29 19:35:44 +01:00
parent 987e97cc2c
commit 9c29dbf84f
3 changed files with 26 additions and 12 deletions

View File

@ -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));

View File

@ -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,

View File

@ -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.