mirror of
https://github.com/typst/typst
synced 2025-08-24 19:54:14 +08:00
Add docs for std
module
This commit is contained in:
parent
494e6a6422
commit
bd66907040
@ -148,7 +148,7 @@ pub struct Library {
|
||||
/// The default style properties (for page size, font selection, and
|
||||
/// everything else configurable via set and show rules).
|
||||
pub styles: Styles,
|
||||
/// The standard library as a value. Used to provide the `std` variable.
|
||||
/// The standard library as a value. Used to provide the `std` module.
|
||||
pub std: Binding,
|
||||
/// In-development features that were enabled.
|
||||
pub features: Features,
|
||||
|
@ -130,6 +130,42 @@
|
||||
In addition to the functions listed below, the `calc` module also defines
|
||||
the constants `pi`, `tau`, `e`, and `inf`.
|
||||
|
||||
- name: std
|
||||
title: Standard library
|
||||
category: foundations
|
||||
path: ["std"]
|
||||
details: |
|
||||
# Collection of globally accessible items under `std` variable.
|
||||
# Collection of globally accessible items under `std.` prefix.
|
||||
# Module consisting of globally accessible items.
|
||||
# The standard library as a value.
|
||||
An alias for globally accessible items comprsing the standard library.
|
||||
|
||||
This is useful whenever you override a name from the global scope, e.g.,
|
||||
the [`text`] element. To access the element simply write `std.text`.
|
||||
Since `std` is not a keyword, you can override it if necessary.
|
||||
# Note that element items from `std` variable work exactly the same way,
|
||||
Note that element items from `std` module work exactly like normal ones,
|
||||
meaning they can be used as constructors, in set rules, etc.
|
||||
|
||||
# Example
|
||||
```example
|
||||
#let par = [My special paragraph.]
|
||||
#let special(text) = {
|
||||
set std.text(style: "italic", weight: "bold")
|
||||
set std.par.line(numbering: "1")
|
||||
parbreak()
|
||||
text
|
||||
parbreak()
|
||||
}
|
||||
|
||||
#lorem(10)
|
||||
#special[
|
||||
#par
|
||||
]
|
||||
#lorem(10)
|
||||
```
|
||||
|
||||
- name: sys
|
||||
title: System
|
||||
category: foundations
|
||||
|
@ -37,7 +37,7 @@ static GROUPS: LazyLock<Vec<GroupData>> = LazyLock::new(|| {
|
||||
let mut groups: Vec<GroupData> =
|
||||
yaml::from_str(load!("reference/groups.yml")).unwrap();
|
||||
for group in &mut groups {
|
||||
if group.filter.is_empty() {
|
||||
if group.filter.is_empty() && group.name != "std" {
|
||||
group.filter = group
|
||||
.module()
|
||||
.scope()
|
||||
|
Loading…
x
Reference in New Issue
Block a user