tinymist_analysis/upstream/
mod.rs

1//! Functions from typst-ide
2
3use std::{collections::HashMap, fmt::Write, sync::LazyLock};
4
5use comemo::Tracked;
6use ecow::{EcoString, eco_format};
7use serde::Deserialize;
8use serde_yaml as yaml;
9use typst::{
10    Category, Library, World,
11    diag::{StrResult, bail},
12    foundations::{Binding, Content, Func, Module, Type, Value},
13    introspection::MetadataElem,
14    syntax::Span,
15    text::{FontInfo, FontStyle},
16};
17
18mod tooltip;
19pub use tooltip::*;
20
21/// Extract the first sentence of plain text of a piece of documentation.
22///
23/// Removes Markdown formatting.
24pub fn plain_docs_sentence(docs: &str) -> EcoString {
25    crate::log_debug_ct!("plain docs {docs:?}");
26    let docs = docs.replace("```example", "```typ");
27    let mut scanner = unscanny::Scanner::new(&docs);
28    let mut output = EcoString::new();
29    let mut link = false;
30    while let Some(ch) = scanner.eat() {
31        match ch {
32            '`' => {
33                let mut raw = scanner.eat_until('`');
34                if (raw.starts_with('{') && raw.ends_with('}'))
35                    || (raw.starts_with('[') && raw.ends_with(']'))
36                {
37                    raw = &raw[1..raw.len() - 1];
38                }
39
40                scanner.eat();
41                output.push('`');
42                output.push_str(raw);
43                output.push('`');
44            }
45            '[' => {
46                link = true;
47                output.push('[');
48            }
49            ']' if link => {
50                output.push(']');
51                let cursor = scanner.cursor();
52                if scanner.eat_if('(') {
53                    scanner.eat_until(')');
54                    let link_content = scanner.from(cursor + 1);
55                    scanner.eat();
56
57                    crate::log_debug_ct!("Intra Link: {link_content}");
58                    let link = resolve(link_content, "https://typst.app/docs/").ok();
59                    let link = link.unwrap_or_else(|| {
60                        log::warn!("Failed to resolve link: {link_content}");
61                        "https://typst.app/docs/404.html".to_string()
62                    });
63
64                    output.push('(');
65                    output.push_str(&link);
66                    output.push(')');
67                } else if scanner.eat_if('[') {
68                    scanner.eat_until(']');
69                    scanner.eat();
70                    output.push_str(scanner.from(cursor));
71                }
72                link = false
73            }
74            // '*' | '_' => {}
75            // '.' => {
76            //     output.push('.');
77            //     break;
78            // }
79            _ => output.push(ch),
80        }
81    }
82
83    output
84}
85
86/// Data about a collection of functions.
87#[derive(Debug, Clone, Deserialize)]
88struct GroupData {
89    name: EcoString,
90    // title: EcoString,
91    category: EcoString,
92    #[serde(default)]
93    path: Vec<EcoString>,
94    #[serde(default)]
95    filter: Vec<EcoString>,
96    // details: EcoString,
97}
98
99impl GroupData {
100    fn module(&self) -> &'static Module {
101        let mut focus = &LIBRARY.global;
102        for path in &self.path {
103            focus = get_module(focus, path).unwrap();
104        }
105        focus
106    }
107}
108
109static GROUPS: LazyLock<Vec<GroupData>> = LazyLock::new(|| {
110    let mut groups: Vec<GroupData> = yaml::from_str(include_str!("groups.yml")).unwrap();
111    for group in &mut groups {
112        if group.filter.is_empty() {
113            group.filter = group
114                .module()
115                .scope()
116                .iter()
117                .filter(|(_, v)| matches!(v.read(), Value::Func(_)))
118                .map(|(k, _)| k.clone())
119                .collect();
120        }
121    }
122    groups
123});
124
125/// Resolve an intra-doc link.
126pub fn resolve(link: &str, base: &str) -> StrResult<String> {
127    if link.starts_with('#') || link.starts_with("http") {
128        return Ok(link.to_string());
129    }
130
131    let (head, tail) = split_link(link)?;
132    let mut route = match resolve_known(head, base) {
133        Some(route) => route,
134        None => resolve_definition(head, base)?,
135    };
136
137    if !tail.is_empty() {
138        route.push('/');
139        route.push_str(tail);
140    }
141
142    if !route.contains(['#', '?']) && !route.ends_with('/') {
143        route.push('/');
144    }
145
146    Ok(route)
147}
148
149/// Split a link at the first slash.
150fn split_link(link: &str) -> StrResult<(&str, &str)> {
151    let first = link.split('/').next().unwrap_or(link);
152    let rest = link[first.len()..].trim_start_matches('/');
153    Ok((first, rest))
154}
155
156/// Resolve a `$` link head to a known destination.
157fn resolve_known(head: &str, base: &str) -> Option<String> {
158    Some(match head {
159        "$tutorial" => format!("{base}tutorial"),
160        "$reference" => format!("{base}reference"),
161        "$category" => format!("{base}reference"),
162        "$syntax" => format!("{base}reference/syntax"),
163        "$styling" => format!("{base}reference/styling"),
164        "$scripting" => format!("{base}reference/scripting"),
165        "$context" => format!("{base}reference/context"),
166        "$guides" => format!("{base}guides"),
167        "$changelog" => format!("{base}changelog"),
168        "$community" => format!("{base}community"),
169        "$universe" => "https://typst.app/universe".into(),
170        _ => return None,
171    })
172}
173
174static LIBRARY: LazyLock<Library> = LazyLock::new(Library::default);
175
176/// Extract a module from another module.
177#[track_caller]
178fn get_module<'a>(parent: &'a Module, name: &str) -> StrResult<&'a Module> {
179    match parent.scope().get(name).map(|x| x.read()) {
180        Some(Value::Module(module)) => Ok(module),
181        _ => bail!("module doesn't contain module `{name}`"),
182    }
183}
184
185/// Resolve a `$` link to a global definition.
186fn resolve_definition(head: &str, base: &str) -> StrResult<String> {
187    let mut parts = head.trim_start_matches('$').split('.').peekable();
188    let mut focus = &LIBRARY.global;
189    let mut category = None;
190
191    while let Some(name) = parts.peek() {
192        if category.is_none() {
193            category = focus.scope().get(name).and_then(Binding::category);
194        }
195        let Ok(module) = get_module(focus, name) else {
196            break;
197        };
198        focus = module;
199        parts.next();
200    }
201
202    let Some(category) = category else {
203        bail!("{head} has no category")
204    };
205
206    let name = parts.next().ok_or("link is missing first part")?;
207    let value = focus.field(name, ())?;
208
209    // Handle grouped functions.
210    if let Some(group) = GROUPS.iter().find(|group| {
211        group.category == category.name() && group.filter.iter().any(|func| func == name)
212    }) {
213        let mut route = format!(
214            "{}reference/{}/{}/#functions-{}",
215            base, group.category, group.name, name
216        );
217        if let Some(param) = parts.next() {
218            route.push('-');
219            route.push_str(param);
220        }
221        return Ok(route);
222    }
223
224    let mut route = format!("{}reference/{}/{name}", base, category.name());
225    if let Some(next) = parts.next() {
226        if let Ok(field) = value.field(next, ()) {
227            route.push_str("/#definitions-");
228            route.push_str(next);
229            if let Some(next) = parts.next()
230                && field
231                    .cast::<Func>()
232                    .is_ok_and(|func| func.param(next).is_some())
233            {
234                route.push('-');
235                route.push_str(next);
236            }
237        } else if value
238            .clone()
239            .cast::<Func>()
240            .is_ok_and(|func| func.param(next).is_some())
241        {
242            route.push_str("/#parameters-");
243            route.push_str(next);
244        } else {
245            bail!("field {next} not found");
246        }
247    }
248
249    Ok(route)
250}
251
252#[allow(clippy::derived_hash_with_manual_eq)]
253#[derive(Debug, Clone, Hash)]
254enum CatKey {
255    Func(Func),
256    Type(Type),
257}
258
259impl PartialEq for CatKey {
260    fn eq(&self, other: &Self) -> bool {
261        use typst::foundations::func::Repr::*;
262        match (self, other) {
263            (CatKey::Func(a), CatKey::Func(b)) => match (a.inner(), b.inner()) {
264                (Native(a), Native(b)) => a == b,
265                (Element(a), Element(b)) => a == b,
266                _ => false,
267            },
268            (CatKey::Type(a), CatKey::Type(b)) => a == b,
269            _ => false,
270        }
271    }
272}
273
274impl Eq for CatKey {}
275
276// todo: category of types
277static ROUTE_MAPS: LazyLock<HashMap<CatKey, String>> = LazyLock::new(|| {
278    // todo: this is a false positive for clippy on LazyHash
279    #[allow(clippy::mutable_key_type)]
280    let mut map = HashMap::new();
281    let mut scope_to_finds = vec![
282        (LIBRARY.global.scope(), None, None),
283        (LIBRARY.math.scope(), None, None),
284    ];
285    while let Some((scope, parent_name, cat)) = scope_to_finds.pop() {
286        for (name, bind) in scope.iter() {
287            let cat = cat.or_else(|| bind.category());
288            let name = urlify(name);
289            match bind.read() {
290                Value::Func(func) => {
291                    if let Some(cat) = cat {
292                        let Some(name) = func.name() else {
293                            continue;
294                        };
295
296                        // Handle grouped functions.
297                        if let Some(group) = GROUPS.iter().find(|group| {
298                            group.category == cat.name()
299                                && group.filter.iter().any(|func| func == name)
300                        }) {
301                            let route = format!(
302                                "reference/{}/{}/#functions-{name}",
303                                group.category, group.name
304                            );
305                            map.insert(CatKey::Func(func.clone()), route);
306                            continue;
307                        }
308
309                        crate::log_debug_ct!("func: {func:?} -> {cat:?}");
310
311                        let route = format_route(parent_name.as_deref(), name, &cat);
312
313                        map.insert(CatKey::Func(func.clone()), route);
314                    }
315                    if let Some(s) = func.scope() {
316                        scope_to_finds.push((s, Some(name), cat));
317                    }
318                }
319                Value::Type(t) => {
320                    if let Some(cat) = cat {
321                        crate::log_debug_ct!("type: {t:?} -> {cat:?}");
322
323                        let route = format_route(parent_name.as_deref(), &name, &cat);
324
325                        // Some types are defined multiple times, and the first one should take precedence.
326                        //
327                        // For example, typst 0.13.0 renamed `pattern` to `tiling`, but keep `pattern` remains as a deprecated alias.
328                        // Therefore, `Tiling` is first defined as `tiling`, then defined as `pattern` with deprecation again.
329                        // https://typst.app/docs/changelog/0.13.0/#visualization
330                        // https://github.com/typst/typst/blob/9a6268050fb769e18c4889fa5f59d4150e8878d6/crates/typst-library/src/visualize/mod.rs#L34
331                        // https://github.com/typst/typst/blob/9a6268050fb769e18c4889fa5f59d4150e8878d6/crates/typst-library/src/visualize/mod.rs#L47-L49
332                        map.entry(CatKey::Type(*t)).or_insert(route);
333                    }
334                    scope_to_finds.push((t.scope(), Some(name), cat));
335                }
336                Value::Module(module) => {
337                    scope_to_finds.push((module.scope(), Some(name), cat));
338                }
339                _ => {}
340            }
341        }
342    }
343    map
344});
345
346fn format_route(parent_name: Option<&str>, name: &str, cat: &Category) -> String {
347    match parent_name {
348        Some(parent_name) if parent_name != cat.name() => {
349            format!("reference/{}/{parent_name}/#definitions-{name}", cat.name())
350        }
351        Some(_) | None => format!("reference/{}/{name}/", cat.name()),
352    }
353}
354
355/// Turn a title into an URL fragment.
356pub(crate) fn urlify(title: &str) -> EcoString {
357    title
358        .chars()
359        .map(|ch| ch.to_ascii_lowercase())
360        .map(|ch| match ch {
361            'a'..='z' | '0'..='9' => ch,
362            _ => '-',
363        })
364        .collect()
365}
366
367/// Get the route of a value.
368pub fn route_of_value(val: &Value) -> Option<&'static String> {
369    // ROUTE_MAPS.get(&CatKey::Func(k.clone()))
370    let key = match val {
371        Value::Func(func) => CatKey::Func(func.clone()),
372        Value::Type(ty) => CatKey::Type(*ty),
373        _ => return None,
374    };
375
376    ROUTE_MAPS.get(&key)
377}
378
379/// Create a short description of a font family.
380pub fn summarize_font_family<'a>(variants: impl Iterator<Item = &'a FontInfo>) -> EcoString {
381    let mut infos: Vec<_> = variants.collect();
382    infos.sort_by_key(|info: &&FontInfo| info.variant);
383
384    let mut has_italic = false;
385    let mut min_weight = u16::MAX;
386    let mut max_weight = 0;
387    for info in &infos {
388        let weight = info.variant.weight.to_number();
389        has_italic |= info.variant.style == FontStyle::Italic;
390        min_weight = min_weight.min(weight);
391        max_weight = min_weight.max(weight);
392    }
393
394    let count = infos.len();
395    let mut detail = eco_format!("{count} variant{}.", if count == 1 { "" } else { "s" });
396
397    if min_weight == max_weight {
398        write!(detail, " Weight {min_weight}.").unwrap();
399    } else {
400        write!(detail, " Weights {min_weight}–{max_weight}.").unwrap();
401    }
402
403    if has_italic {
404        detail.push_str(" Has italics.");
405    }
406
407    detail
408}
409
410/// Get the representation but truncated to a certain size.
411pub fn truncated_repr_<const SZ_LIMIT: usize>(value: &Value) -> EcoString {
412    use typst::foundations::Repr;
413
414    let data: Option<Content> = value.clone().cast().ok();
415    let metadata: Option<MetadataElem> = data.and_then(|content| content.unpack().ok());
416
417    // todo: early truncation
418    let repr = if let Some(metadata) = metadata {
419        metadata.value.repr()
420    } else {
421        value.repr()
422    };
423
424    if repr.len() > SZ_LIMIT {
425        eco_format!("[truncated-repr: {} bytes]", repr.len())
426    } else {
427        repr
428    }
429}
430
431/// Get the representation but truncated to a certain size.
432pub fn truncated_repr(value: &Value) -> EcoString {
433    const _10MB: usize = 10 * 1024 * 1024;
434    truncated_repr_::<_10MB>(value)
435}
436
437/// Run a function with a VM instance in the world
438pub fn with_vm<T>(
439    world: Tracked<dyn World + '_>,
440    f: impl FnOnce(&mut typst_shim::eval::Vm) -> T,
441) -> T {
442    use comemo::Track;
443    use typst::engine::*;
444    use typst::foundations::*;
445    use typst::introspection::*;
446    use typst_shim::eval::*;
447
448    let introspector = Introspector::default();
449    let traced = Traced::default();
450    let mut sink = Sink::new();
451    let engine = Engine {
452        routines: &typst::ROUTINES,
453        world,
454        route: Route::default(),
455        introspector: introspector.track(),
456        traced: traced.track(),
457        sink: sink.track_mut(),
458    };
459
460    let context = Context::none();
461    let mut vm = Vm::new(
462        engine,
463        context.track(),
464        Scopes::new(Some(world.library())),
465        Span::detached(),
466    );
467
468    f(&mut vm)
469}
470
471#[cfg(test)]
472mod tests {
473    use crate::upstream::ROUTE_MAPS;
474
475    #[test]
476    fn docs_test() {
477        assert_eq!(
478            "[citation](https://typst.app/docs/reference/model/cite/)",
479            super::plain_docs_sentence("[citation]($cite)")
480        );
481        assert_eq!(
482            "[citation][cite]",
483            super::plain_docs_sentence("[citation][cite]")
484        );
485        assert_eq!(
486            "[citation](https://typst.app/docs/reference/model/cite/)",
487            super::plain_docs_sentence("[citation]($cite)")
488        );
489        assert_eq!(
490            "[citation][cite][cite2]",
491            super::plain_docs_sentence("[citation][cite][cite2]")
492        );
493        assert_eq!(
494            "[citation][cite](test)[cite2]",
495            super::plain_docs_sentence("[citation][cite](test)[cite2]")
496        );
497    }
498
499    #[test]
500    fn routes() {
501        let access = |route: &String| format!("https://typst.app/docs/{route}");
502        let mut values = ROUTE_MAPS.values().map(access).collect::<Vec<_>>();
503        values.sort();
504
505        insta::assert_snapshot!(values.as_slice().join("\n"), @r###"
506        https://typst.app/docs/reference/data-loading/cbor/
507        https://typst.app/docs/reference/data-loading/cbor/#definitions-decode
508        https://typst.app/docs/reference/data-loading/cbor/#definitions-encode
509        https://typst.app/docs/reference/data-loading/csv/
510        https://typst.app/docs/reference/data-loading/csv/#definitions-decode
511        https://typst.app/docs/reference/data-loading/json/
512        https://typst.app/docs/reference/data-loading/json/#definitions-decode
513        https://typst.app/docs/reference/data-loading/json/#definitions-encode
514        https://typst.app/docs/reference/data-loading/read/
515        https://typst.app/docs/reference/data-loading/toml/
516        https://typst.app/docs/reference/data-loading/toml/#definitions-decode
517        https://typst.app/docs/reference/data-loading/toml/#definitions-encode
518        https://typst.app/docs/reference/data-loading/xml/
519        https://typst.app/docs/reference/data-loading/xml/#definitions-decode
520        https://typst.app/docs/reference/data-loading/yaml/
521        https://typst.app/docs/reference/data-loading/yaml/#definitions-decode
522        https://typst.app/docs/reference/data-loading/yaml/#definitions-encode
523        https://typst.app/docs/reference/foundations/arguments/
524        https://typst.app/docs/reference/foundations/arguments/#definitions-at
525        https://typst.app/docs/reference/foundations/arguments/#definitions-named
526        https://typst.app/docs/reference/foundations/arguments/#definitions-pos
527        https://typst.app/docs/reference/foundations/array/
528        https://typst.app/docs/reference/foundations/array/#definitions-all
529        https://typst.app/docs/reference/foundations/array/#definitions-any
530        https://typst.app/docs/reference/foundations/array/#definitions-at
531        https://typst.app/docs/reference/foundations/array/#definitions-chunks
532        https://typst.app/docs/reference/foundations/array/#definitions-contains
533        https://typst.app/docs/reference/foundations/array/#definitions-dedup
534        https://typst.app/docs/reference/foundations/array/#definitions-enumerate
535        https://typst.app/docs/reference/foundations/array/#definitions-filter
536        https://typst.app/docs/reference/foundations/array/#definitions-find
537        https://typst.app/docs/reference/foundations/array/#definitions-first
538        https://typst.app/docs/reference/foundations/array/#definitions-flatten
539        https://typst.app/docs/reference/foundations/array/#definitions-fold
540        https://typst.app/docs/reference/foundations/array/#definitions-insert
541        https://typst.app/docs/reference/foundations/array/#definitions-intersperse
542        https://typst.app/docs/reference/foundations/array/#definitions-join
543        https://typst.app/docs/reference/foundations/array/#definitions-last
544        https://typst.app/docs/reference/foundations/array/#definitions-len
545        https://typst.app/docs/reference/foundations/array/#definitions-map
546        https://typst.app/docs/reference/foundations/array/#definitions-pop
547        https://typst.app/docs/reference/foundations/array/#definitions-position
548        https://typst.app/docs/reference/foundations/array/#definitions-product
549        https://typst.app/docs/reference/foundations/array/#definitions-push
550        https://typst.app/docs/reference/foundations/array/#definitions-range
551        https://typst.app/docs/reference/foundations/array/#definitions-reduce
552        https://typst.app/docs/reference/foundations/array/#definitions-remove
553        https://typst.app/docs/reference/foundations/array/#definitions-rev
554        https://typst.app/docs/reference/foundations/array/#definitions-slice
555        https://typst.app/docs/reference/foundations/array/#definitions-sorted
556        https://typst.app/docs/reference/foundations/array/#definitions-split
557        https://typst.app/docs/reference/foundations/array/#definitions-sum
558        https://typst.app/docs/reference/foundations/array/#definitions-to-dict
559        https://typst.app/docs/reference/foundations/array/#definitions-windows
560        https://typst.app/docs/reference/foundations/array/#definitions-zip
561        https://typst.app/docs/reference/foundations/assert/
562        https://typst.app/docs/reference/foundations/assert/#definitions-eq
563        https://typst.app/docs/reference/foundations/assert/#definitions-ne
564        https://typst.app/docs/reference/foundations/bool/
565        https://typst.app/docs/reference/foundations/bytes/
566        https://typst.app/docs/reference/foundations/bytes/#definitions-at
567        https://typst.app/docs/reference/foundations/bytes/#definitions-len
568        https://typst.app/docs/reference/foundations/bytes/#definitions-slice
569        https://typst.app/docs/reference/foundations/calc/#functions-abs
570        https://typst.app/docs/reference/foundations/calc/#functions-acos
571        https://typst.app/docs/reference/foundations/calc/#functions-asin
572        https://typst.app/docs/reference/foundations/calc/#functions-atan
573        https://typst.app/docs/reference/foundations/calc/#functions-atan2
574        https://typst.app/docs/reference/foundations/calc/#functions-binom
575        https://typst.app/docs/reference/foundations/calc/#functions-ceil
576        https://typst.app/docs/reference/foundations/calc/#functions-clamp
577        https://typst.app/docs/reference/foundations/calc/#functions-cos
578        https://typst.app/docs/reference/foundations/calc/#functions-cosh
579        https://typst.app/docs/reference/foundations/calc/#functions-div-euclid
580        https://typst.app/docs/reference/foundations/calc/#functions-even
581        https://typst.app/docs/reference/foundations/calc/#functions-exp
582        https://typst.app/docs/reference/foundations/calc/#functions-fact
583        https://typst.app/docs/reference/foundations/calc/#functions-floor
584        https://typst.app/docs/reference/foundations/calc/#functions-fract
585        https://typst.app/docs/reference/foundations/calc/#functions-gcd
586        https://typst.app/docs/reference/foundations/calc/#functions-lcm
587        https://typst.app/docs/reference/foundations/calc/#functions-ln
588        https://typst.app/docs/reference/foundations/calc/#functions-log
589        https://typst.app/docs/reference/foundations/calc/#functions-max
590        https://typst.app/docs/reference/foundations/calc/#functions-min
591        https://typst.app/docs/reference/foundations/calc/#functions-norm
592        https://typst.app/docs/reference/foundations/calc/#functions-odd
593        https://typst.app/docs/reference/foundations/calc/#functions-perm
594        https://typst.app/docs/reference/foundations/calc/#functions-pow
595        https://typst.app/docs/reference/foundations/calc/#functions-quo
596        https://typst.app/docs/reference/foundations/calc/#functions-rem
597        https://typst.app/docs/reference/foundations/calc/#functions-rem-euclid
598        https://typst.app/docs/reference/foundations/calc/#functions-root
599        https://typst.app/docs/reference/foundations/calc/#functions-round
600        https://typst.app/docs/reference/foundations/calc/#functions-sin
601        https://typst.app/docs/reference/foundations/calc/#functions-sinh
602        https://typst.app/docs/reference/foundations/calc/#functions-sqrt
603        https://typst.app/docs/reference/foundations/calc/#functions-tan
604        https://typst.app/docs/reference/foundations/calc/#functions-tanh
605        https://typst.app/docs/reference/foundations/calc/#functions-trunc
606        https://typst.app/docs/reference/foundations/content/
607        https://typst.app/docs/reference/foundations/content/#definitions-at
608        https://typst.app/docs/reference/foundations/content/#definitions-fields
609        https://typst.app/docs/reference/foundations/content/#definitions-func
610        https://typst.app/docs/reference/foundations/content/#definitions-has
611        https://typst.app/docs/reference/foundations/content/#definitions-location
612        https://typst.app/docs/reference/foundations/datetime/
613        https://typst.app/docs/reference/foundations/datetime/#definitions-day
614        https://typst.app/docs/reference/foundations/datetime/#definitions-display
615        https://typst.app/docs/reference/foundations/datetime/#definitions-hour
616        https://typst.app/docs/reference/foundations/datetime/#definitions-minute
617        https://typst.app/docs/reference/foundations/datetime/#definitions-month
618        https://typst.app/docs/reference/foundations/datetime/#definitions-ordinal
619        https://typst.app/docs/reference/foundations/datetime/#definitions-second
620        https://typst.app/docs/reference/foundations/datetime/#definitions-today
621        https://typst.app/docs/reference/foundations/datetime/#definitions-weekday
622        https://typst.app/docs/reference/foundations/datetime/#definitions-year
623        https://typst.app/docs/reference/foundations/decimal/
624        https://typst.app/docs/reference/foundations/dictionary/
625        https://typst.app/docs/reference/foundations/dictionary/#definitions-at
626        https://typst.app/docs/reference/foundations/dictionary/#definitions-insert
627        https://typst.app/docs/reference/foundations/dictionary/#definitions-keys
628        https://typst.app/docs/reference/foundations/dictionary/#definitions-len
629        https://typst.app/docs/reference/foundations/dictionary/#definitions-pairs
630        https://typst.app/docs/reference/foundations/dictionary/#definitions-remove
631        https://typst.app/docs/reference/foundations/dictionary/#definitions-values
632        https://typst.app/docs/reference/foundations/duration/
633        https://typst.app/docs/reference/foundations/duration/#definitions-days
634        https://typst.app/docs/reference/foundations/duration/#definitions-hours
635        https://typst.app/docs/reference/foundations/duration/#definitions-minutes
636        https://typst.app/docs/reference/foundations/duration/#definitions-seconds
637        https://typst.app/docs/reference/foundations/duration/#definitions-weeks
638        https://typst.app/docs/reference/foundations/eval/
639        https://typst.app/docs/reference/foundations/float/
640        https://typst.app/docs/reference/foundations/float/#definitions-from-bytes
641        https://typst.app/docs/reference/foundations/float/#definitions-is-infinite
642        https://typst.app/docs/reference/foundations/float/#definitions-is-nan
643        https://typst.app/docs/reference/foundations/float/#definitions-signum
644        https://typst.app/docs/reference/foundations/float/#definitions-to-bytes
645        https://typst.app/docs/reference/foundations/function/
646        https://typst.app/docs/reference/foundations/function/#definitions-where
647        https://typst.app/docs/reference/foundations/function/#definitions-with
648        https://typst.app/docs/reference/foundations/int/
649        https://typst.app/docs/reference/foundations/int/#definitions-bit-and
650        https://typst.app/docs/reference/foundations/int/#definitions-bit-lshift
651        https://typst.app/docs/reference/foundations/int/#definitions-bit-not
652        https://typst.app/docs/reference/foundations/int/#definitions-bit-or
653        https://typst.app/docs/reference/foundations/int/#definitions-bit-rshift
654        https://typst.app/docs/reference/foundations/int/#definitions-bit-xor
655        https://typst.app/docs/reference/foundations/int/#definitions-from-bytes
656        https://typst.app/docs/reference/foundations/int/#definitions-signum
657        https://typst.app/docs/reference/foundations/int/#definitions-to-bytes
658        https://typst.app/docs/reference/foundations/label/
659        https://typst.app/docs/reference/foundations/module/
660        https://typst.app/docs/reference/foundations/panic/
661        https://typst.app/docs/reference/foundations/plugin/
662        https://typst.app/docs/reference/foundations/plugin/#definitions-transition
663        https://typst.app/docs/reference/foundations/regex/
664        https://typst.app/docs/reference/foundations/repr/
665        https://typst.app/docs/reference/foundations/selector/
666        https://typst.app/docs/reference/foundations/selector/#definitions-after
667        https://typst.app/docs/reference/foundations/selector/#definitions-and
668        https://typst.app/docs/reference/foundations/selector/#definitions-before
669        https://typst.app/docs/reference/foundations/selector/#definitions-or
670        https://typst.app/docs/reference/foundations/str/
671        https://typst.app/docs/reference/foundations/str/#definitions-at
672        https://typst.app/docs/reference/foundations/str/#definitions-clusters
673        https://typst.app/docs/reference/foundations/str/#definitions-codepoints
674        https://typst.app/docs/reference/foundations/str/#definitions-contains
675        https://typst.app/docs/reference/foundations/str/#definitions-ends-with
676        https://typst.app/docs/reference/foundations/str/#definitions-find
677        https://typst.app/docs/reference/foundations/str/#definitions-first
678        https://typst.app/docs/reference/foundations/str/#definitions-from-unicode
679        https://typst.app/docs/reference/foundations/str/#definitions-last
680        https://typst.app/docs/reference/foundations/str/#definitions-len
681        https://typst.app/docs/reference/foundations/str/#definitions-match
682        https://typst.app/docs/reference/foundations/str/#definitions-matches
683        https://typst.app/docs/reference/foundations/str/#definitions-position
684        https://typst.app/docs/reference/foundations/str/#definitions-replace
685        https://typst.app/docs/reference/foundations/str/#definitions-rev
686        https://typst.app/docs/reference/foundations/str/#definitions-slice
687        https://typst.app/docs/reference/foundations/str/#definitions-split
688        https://typst.app/docs/reference/foundations/str/#definitions-starts-with
689        https://typst.app/docs/reference/foundations/str/#definitions-to-unicode
690        https://typst.app/docs/reference/foundations/str/#definitions-trim
691        https://typst.app/docs/reference/foundations/symbol/
692        https://typst.app/docs/reference/foundations/type/
693        https://typst.app/docs/reference/foundations/version/
694        https://typst.app/docs/reference/foundations/version/#definitions-at
695        https://typst.app/docs/reference/introspection/counter/
696        https://typst.app/docs/reference/introspection/counter/#definitions-at
697        https://typst.app/docs/reference/introspection/counter/#definitions-display
698        https://typst.app/docs/reference/introspection/counter/#definitions-final
699        https://typst.app/docs/reference/introspection/counter/#definitions-get
700        https://typst.app/docs/reference/introspection/counter/#definitions-step
701        https://typst.app/docs/reference/introspection/counter/#definitions-update
702        https://typst.app/docs/reference/introspection/here/
703        https://typst.app/docs/reference/introspection/locate/
704        https://typst.app/docs/reference/introspection/location/
705        https://typst.app/docs/reference/introspection/location/#definitions-page
706        https://typst.app/docs/reference/introspection/location/#definitions-page-numbering
707        https://typst.app/docs/reference/introspection/location/#definitions-position
708        https://typst.app/docs/reference/introspection/metadata/
709        https://typst.app/docs/reference/introspection/query/
710        https://typst.app/docs/reference/introspection/state/
711        https://typst.app/docs/reference/introspection/state/#definitions-at
712        https://typst.app/docs/reference/introspection/state/#definitions-final
713        https://typst.app/docs/reference/introspection/state/#definitions-get
714        https://typst.app/docs/reference/introspection/state/#definitions-update
715        https://typst.app/docs/reference/layout/align/
716        https://typst.app/docs/reference/layout/alignment/
717        https://typst.app/docs/reference/layout/alignment/#definitions-axis
718        https://typst.app/docs/reference/layout/alignment/#definitions-inv
719        https://typst.app/docs/reference/layout/angle/
720        https://typst.app/docs/reference/layout/angle/#definitions-deg
721        https://typst.app/docs/reference/layout/angle/#definitions-rad
722        https://typst.app/docs/reference/layout/block/
723        https://typst.app/docs/reference/layout/box/
724        https://typst.app/docs/reference/layout/colbreak/
725        https://typst.app/docs/reference/layout/columns/
726        https://typst.app/docs/reference/layout/direction/
727        https://typst.app/docs/reference/layout/direction/#definitions-axis
728        https://typst.app/docs/reference/layout/direction/#definitions-end
729        https://typst.app/docs/reference/layout/direction/#definitions-inv
730        https://typst.app/docs/reference/layout/direction/#definitions-start
731        https://typst.app/docs/reference/layout/fraction/
732        https://typst.app/docs/reference/layout/grid/
733        https://typst.app/docs/reference/layout/grid/#definitions-cell
734        https://typst.app/docs/reference/layout/grid/#definitions-footer
735        https://typst.app/docs/reference/layout/grid/#definitions-header
736        https://typst.app/docs/reference/layout/grid/#definitions-hline
737        https://typst.app/docs/reference/layout/grid/#definitions-vline
738        https://typst.app/docs/reference/layout/h/
739        https://typst.app/docs/reference/layout/hide/
740        https://typst.app/docs/reference/layout/layout/
741        https://typst.app/docs/reference/layout/length/
742        https://typst.app/docs/reference/layout/length/#definitions-cm
743        https://typst.app/docs/reference/layout/length/#definitions-inches
744        https://typst.app/docs/reference/layout/length/#definitions-mm
745        https://typst.app/docs/reference/layout/length/#definitions-pt
746        https://typst.app/docs/reference/layout/length/#definitions-to-absolute
747        https://typst.app/docs/reference/layout/measure/
748        https://typst.app/docs/reference/layout/move/
749        https://typst.app/docs/reference/layout/pad/
750        https://typst.app/docs/reference/layout/page/
751        https://typst.app/docs/reference/layout/pagebreak/
752        https://typst.app/docs/reference/layout/place/
753        https://typst.app/docs/reference/layout/place/#definitions-flush
754        https://typst.app/docs/reference/layout/ratio/
755        https://typst.app/docs/reference/layout/relative/
756        https://typst.app/docs/reference/layout/repeat/
757        https://typst.app/docs/reference/layout/rotate/
758        https://typst.app/docs/reference/layout/scale/
759        https://typst.app/docs/reference/layout/skew/
760        https://typst.app/docs/reference/layout/stack/
761        https://typst.app/docs/reference/layout/v/
762        https://typst.app/docs/reference/math/accent/
763        https://typst.app/docs/reference/math/attach/#functions-attach
764        https://typst.app/docs/reference/math/attach/#functions-limits
765        https://typst.app/docs/reference/math/attach/#functions-scripts
766        https://typst.app/docs/reference/math/binom/
767        https://typst.app/docs/reference/math/cancel/
768        https://typst.app/docs/reference/math/cases/
769        https://typst.app/docs/reference/math/class/
770        https://typst.app/docs/reference/math/equation/
771        https://typst.app/docs/reference/math/frac/
772        https://typst.app/docs/reference/math/lr/#functions-abs
773        https://typst.app/docs/reference/math/lr/#functions-lr
774        https://typst.app/docs/reference/math/lr/#functions-mid
775        https://typst.app/docs/reference/math/lr/#functions-norm
776        https://typst.app/docs/reference/math/lr/#functions-round
777        https://typst.app/docs/reference/math/mat/
778        https://typst.app/docs/reference/math/op/
779        https://typst.app/docs/reference/math/primes/
780        https://typst.app/docs/reference/math/roots/#functions-root
781        https://typst.app/docs/reference/math/roots/#functions-sqrt
782        https://typst.app/docs/reference/math/sizes/#functions-display
783        https://typst.app/docs/reference/math/sizes/#functions-inline
784        https://typst.app/docs/reference/math/sizes/#functions-script
785        https://typst.app/docs/reference/math/sizes/#functions-sscript
786        https://typst.app/docs/reference/math/stretch/
787        https://typst.app/docs/reference/math/styles/#functions-bold
788        https://typst.app/docs/reference/math/styles/#functions-italic
789        https://typst.app/docs/reference/math/styles/#functions-upright
790        https://typst.app/docs/reference/math/text/
791        https://typst.app/docs/reference/math/underover/#functions-overbrace
792        https://typst.app/docs/reference/math/underover/#functions-overbracket
793        https://typst.app/docs/reference/math/underover/#functions-overline
794        https://typst.app/docs/reference/math/underover/#functions-overparen
795        https://typst.app/docs/reference/math/underover/#functions-overshell
796        https://typst.app/docs/reference/math/underover/#functions-underbrace
797        https://typst.app/docs/reference/math/underover/#functions-underbracket
798        https://typst.app/docs/reference/math/underover/#functions-underline
799        https://typst.app/docs/reference/math/underover/#functions-underparen
800        https://typst.app/docs/reference/math/underover/#functions-undershell
801        https://typst.app/docs/reference/math/variants/#functions-bb
802        https://typst.app/docs/reference/math/variants/#functions-cal
803        https://typst.app/docs/reference/math/variants/#functions-frak
804        https://typst.app/docs/reference/math/variants/#functions-mono
805        https://typst.app/docs/reference/math/variants/#functions-sans
806        https://typst.app/docs/reference/math/variants/#functions-serif
807        https://typst.app/docs/reference/math/vec/
808        https://typst.app/docs/reference/model/bibliography/
809        https://typst.app/docs/reference/model/cite/
810        https://typst.app/docs/reference/model/document/
811        https://typst.app/docs/reference/model/emph/
812        https://typst.app/docs/reference/model/entry/#definitions-body
813        https://typst.app/docs/reference/model/entry/#definitions-indented
814        https://typst.app/docs/reference/model/entry/#definitions-inner
815        https://typst.app/docs/reference/model/entry/#definitions-page
816        https://typst.app/docs/reference/model/entry/#definitions-prefix
817        https://typst.app/docs/reference/model/enum/
818        https://typst.app/docs/reference/model/enum/#definitions-item
819        https://typst.app/docs/reference/model/figure/
820        https://typst.app/docs/reference/model/figure/#definitions-caption
821        https://typst.app/docs/reference/model/footnote/
822        https://typst.app/docs/reference/model/footnote/#definitions-entry
823        https://typst.app/docs/reference/model/heading/
824        https://typst.app/docs/reference/model/link/
825        https://typst.app/docs/reference/model/list/
826        https://typst.app/docs/reference/model/list/#definitions-item
827        https://typst.app/docs/reference/model/numbering/
828        https://typst.app/docs/reference/model/outline/
829        https://typst.app/docs/reference/model/outline/#definitions-entry
830        https://typst.app/docs/reference/model/par/
831        https://typst.app/docs/reference/model/par/#definitions-line
832        https://typst.app/docs/reference/model/parbreak/
833        https://typst.app/docs/reference/model/quote/
834        https://typst.app/docs/reference/model/ref/
835        https://typst.app/docs/reference/model/strong/
836        https://typst.app/docs/reference/model/table/
837        https://typst.app/docs/reference/model/table/#definitions-cell
838        https://typst.app/docs/reference/model/table/#definitions-footer
839        https://typst.app/docs/reference/model/table/#definitions-header
840        https://typst.app/docs/reference/model/table/#definitions-hline
841        https://typst.app/docs/reference/model/table/#definitions-vline
842        https://typst.app/docs/reference/model/terms/
843        https://typst.app/docs/reference/model/terms/#definitions-item
844        https://typst.app/docs/reference/pdf/embed/
845        https://typst.app/docs/reference/text/highlight/
846        https://typst.app/docs/reference/text/linebreak/
847        https://typst.app/docs/reference/text/lorem/
848        https://typst.app/docs/reference/text/lower/
849        https://typst.app/docs/reference/text/overline/
850        https://typst.app/docs/reference/text/raw/
851        https://typst.app/docs/reference/text/raw/#definitions-line
852        https://typst.app/docs/reference/text/smallcaps/
853        https://typst.app/docs/reference/text/smartquote/
854        https://typst.app/docs/reference/text/strike/
855        https://typst.app/docs/reference/text/sub/
856        https://typst.app/docs/reference/text/super/
857        https://typst.app/docs/reference/text/underline/
858        https://typst.app/docs/reference/text/upper/
859        https://typst.app/docs/reference/visualize/circle/
860        https://typst.app/docs/reference/visualize/color/
861        https://typst.app/docs/reference/visualize/color/#definitions-cmyk
862        https://typst.app/docs/reference/visualize/color/#definitions-components
863        https://typst.app/docs/reference/visualize/color/#definitions-darken
864        https://typst.app/docs/reference/visualize/color/#definitions-desaturate
865        https://typst.app/docs/reference/visualize/color/#definitions-hsl
866        https://typst.app/docs/reference/visualize/color/#definitions-hsv
867        https://typst.app/docs/reference/visualize/color/#definitions-lighten
868        https://typst.app/docs/reference/visualize/color/#definitions-linear-rgb
869        https://typst.app/docs/reference/visualize/color/#definitions-luma
870        https://typst.app/docs/reference/visualize/color/#definitions-mix
871        https://typst.app/docs/reference/visualize/color/#definitions-negate
872        https://typst.app/docs/reference/visualize/color/#definitions-oklab
873        https://typst.app/docs/reference/visualize/color/#definitions-oklch
874        https://typst.app/docs/reference/visualize/color/#definitions-opacify
875        https://typst.app/docs/reference/visualize/color/#definitions-rgb
876        https://typst.app/docs/reference/visualize/color/#definitions-rotate
877        https://typst.app/docs/reference/visualize/color/#definitions-saturate
878        https://typst.app/docs/reference/visualize/color/#definitions-space
879        https://typst.app/docs/reference/visualize/color/#definitions-to-hex
880        https://typst.app/docs/reference/visualize/color/#definitions-transparentize
881        https://typst.app/docs/reference/visualize/curve/
882        https://typst.app/docs/reference/visualize/curve/#definitions-close
883        https://typst.app/docs/reference/visualize/curve/#definitions-cubic
884        https://typst.app/docs/reference/visualize/curve/#definitions-line
885        https://typst.app/docs/reference/visualize/curve/#definitions-move
886        https://typst.app/docs/reference/visualize/curve/#definitions-quad
887        https://typst.app/docs/reference/visualize/ellipse/
888        https://typst.app/docs/reference/visualize/gradient/
889        https://typst.app/docs/reference/visualize/gradient/#definitions-angle
890        https://typst.app/docs/reference/visualize/gradient/#definitions-center
891        https://typst.app/docs/reference/visualize/gradient/#definitions-conic
892        https://typst.app/docs/reference/visualize/gradient/#definitions-focal-center
893        https://typst.app/docs/reference/visualize/gradient/#definitions-focal-radius
894        https://typst.app/docs/reference/visualize/gradient/#definitions-kind
895        https://typst.app/docs/reference/visualize/gradient/#definitions-linear
896        https://typst.app/docs/reference/visualize/gradient/#definitions-radial
897        https://typst.app/docs/reference/visualize/gradient/#definitions-radius
898        https://typst.app/docs/reference/visualize/gradient/#definitions-relative
899        https://typst.app/docs/reference/visualize/gradient/#definitions-repeat
900        https://typst.app/docs/reference/visualize/gradient/#definitions-sample
901        https://typst.app/docs/reference/visualize/gradient/#definitions-samples
902        https://typst.app/docs/reference/visualize/gradient/#definitions-sharp
903        https://typst.app/docs/reference/visualize/gradient/#definitions-space
904        https://typst.app/docs/reference/visualize/gradient/#definitions-stops
905        https://typst.app/docs/reference/visualize/image/
906        https://typst.app/docs/reference/visualize/image/#definitions-decode
907        https://typst.app/docs/reference/visualize/line/
908        https://typst.app/docs/reference/visualize/path/
909        https://typst.app/docs/reference/visualize/polygon/
910        https://typst.app/docs/reference/visualize/polygon/#definitions-regular
911        https://typst.app/docs/reference/visualize/rect/
912        https://typst.app/docs/reference/visualize/square/
913        https://typst.app/docs/reference/visualize/stroke/
914        https://typst.app/docs/reference/visualize/tiling/
915        "###);
916    }
917}