diff options
| author | Laurenz <laurmaedje@gmail.com> | 2025-02-04 11:08:43 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-04 10:08:43 +0000 |
| commit | 0ea668077d6a47f64ee3875dbed31f9e8d832ae3 (patch) | |
| tree | c1ee1d9c0467e021079d866257996f07272004ea /crates | |
| parent | 73ffbdef2b3498307328da355b1d933b1ccf206a (diff) | |
Bump codex to 0.1.0 (#5805)
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/typst-library/src/symbols.rs | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/crates/typst-library/src/symbols.rs b/crates/typst-library/src/symbols.rs index aee7fb83..777f8172 100644 --- a/crates/typst-library/src/symbols.rs +++ b/crates/typst-library/src/symbols.rs @@ -10,6 +10,31 @@ use crate::foundations::{category, Category, Module, Scope, Symbol, Value}; #[category] pub static SYMBOLS: Category; +/// Hook up all `symbol` definitions. +pub(super) fn define(global: &mut Scope) { + global.start_category(SYMBOLS); + extend_scope_from_codex_module(global, codex::ROOT); +} + +/// Hook up all math `symbol` definitions, i.e., elements of the `sym` module. +pub(super) fn define_math(math: &mut Scope) { + extend_scope_from_codex_module(math, codex::SYM); +} + +fn extend_scope_from_codex_module(scope: &mut Scope, module: codex::Module) { + for (name, binding) in module.iter() { + let value = match binding.def { + codex::Def::Symbol(s) => Value::Symbol(s.into()), + codex::Def::Module(m) => Value::Module(Module::new(name, m.into())), + }; + + let scope_binding = scope.define(name, value); + if let Some(message) = binding.deprecation { + scope_binding.deprecated(message); + } + } +} + impl From<codex::Module> for Scope { fn from(module: codex::Module) -> Scope { let mut scope = Self::new(); @@ -26,24 +51,3 @@ impl From<codex::Symbol> for Symbol { } } } - -fn extend_scope_from_codex_module(scope: &mut Scope, module: codex::Module) { - for (name, definition) in module.iter() { - let value = match definition { - codex::Def::Symbol(s) => Value::Symbol(s.into()), - codex::Def::Module(m) => Value::Module(Module::new(name, m.into())), - }; - scope.define(name, value); - } -} - -/// Hook up all `symbol` definitions. -pub(super) fn define(global: &mut Scope) { - global.start_category(SYMBOLS); - extend_scope_from_codex_module(global, codex::ROOT); -} - -/// Hook up all math `symbol` definitions, i.e., elements of the `sym` module. -pub(super) fn define_math(math: &mut Scope) { - extend_scope_from_codex_module(math, codex::SYM); -} |
