summaryrefslogtreecommitdiff
path: root/docs/src/lib.rs
blob: 4a20a008b3a68ab6e37250217ff20be5691701ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
//! Documentation provider for Typst.

mod html;

pub use html::Html;

use std::fmt::{self, Debug, Formatter};
use std::path::Path;

use comemo::Prehashed;
use heck::ToTitleCase;
use include_dir::{include_dir, Dir};
use once_cell::sync::Lazy;
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use serde_yaml as yaml;
use typst::doc::Frame;
use typst::eval::{CastInfo, Func, FuncInfo, Library, Module, ParamInfo, Value};
use typst::font::{Font, FontBook};
use typst::geom::{Abs, Sides, Smart};
use typst_library::layout::PageElem;
use unscanny::Scanner;

static SRC: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/src");
static FILES: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/../assets/files");
static DETAILS: Lazy<yaml::Mapping> = Lazy::new(|| yaml("reference/details.yml"));
static GROUPS: Lazy<Vec<GroupData>> = Lazy::new(|| yaml("reference/groups.yml"));

static FONTS: Lazy<(Prehashed<FontBook>, Vec<Font>)> = Lazy::new(|| {
    static DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/../assets/fonts");
    let fonts: Vec<_> = DIR
        .files()
        .flat_map(|file| Font::iter(file.contents().into()))
        .collect();
    let book = FontBook::from_fonts(&fonts);
    (Prehashed::new(book), fonts)
});

static LIBRARY: Lazy<Prehashed<Library>> = Lazy::new(|| {
    let mut lib = typst_library::build();
    lib.styles
        .set(PageElem::set_width(Smart::Custom(Abs::pt(240.0).into())));
    lib.styles.set(PageElem::set_height(Smart::Auto));
    lib.styles.set(PageElem::set_margin(Sides::splat(Some(Smart::Custom(
        Abs::pt(15.0).into(),
    )))));
    typst::eval::set_lang_items(lib.items.clone());
    Prehashed::new(lib)
});

/// Build documentation pages.
pub fn provide(resolver: &dyn Resolver) -> Vec<PageModel> {
    vec![
        markdown_page(resolver, "/docs/", "general/overview.md").with_route("/docs/"),
        tutorial_page(resolver),
        reference_page(resolver),
        markdown_page(resolver, "/docs/", "general/changelog.md"),
        markdown_page(resolver, "/docs/", "general/community.md"),
    ]
}

/// Resolve consumer dependencies.
pub trait Resolver {
    /// Try to resolve a link that the system cannot resolve itself.
    fn link(&self, link: &str) -> Option<String>;

    /// Produce an URL for an image file.
    fn image(&self, filename: &str, data: &[u8]) -> String;

    /// Produce HTML for an example.
    fn example(&self, source: Html, frames: &[Frame]) -> Html;
}

/// Details about a documentation page and its children.
#[derive(Debug, Serialize)]
pub struct PageModel {
    pub route: String,
    pub title: String,
    pub description: String,
    pub part: Option<&'static str>,
    pub body: BodyModel,
    pub children: Vec<Self>,
}

impl PageModel {
    fn with_route(self, route: &str) -> Self {
        Self { route: route.into(), ..self }
    }

    fn with_part(self, part: &'static str) -> Self {
        Self { part: Some(part), ..self }
    }
}

/// Details about the body of a documentation page.
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "kind", content = "content")]
pub enum BodyModel {
    Html(Html),
    Category(CategoryModel),
    Func(FuncModel),
    Funcs(FuncsModel),
    Type(TypeModel),
    Symbols(SymbolsModel),
}

/// Build the tutorial.
fn tutorial_page(resolver: &dyn Resolver) -> PageModel {
    let mut page = markdown_page(resolver, "/docs/", "tutorial/welcome.md");
    page.children = SRC
        .get_dir("tutorial")
        .unwrap()
        .files()
        .filter(|file| file.path() != Path::new("tutorial/welcome.md"))
        .map(|file| markdown_page(resolver, "/docs/tutorial/", file.path()))
        .collect();
    page
}

/// Build the reference.
fn reference_page(resolver: &dyn Resolver) -> PageModel {
    let mut page = markdown_page(resolver, "/docs/", "reference/welcome.md");
    page.children = vec![
        markdown_page(resolver, "/docs/reference/", "reference/syntax.md")
            .with_part("Language"),
        markdown_page(resolver, "/docs/reference/", "reference/styling.md"),
        markdown_page(resolver, "/docs/reference/", "reference/scripting.md"),
        types_page(resolver, "/docs/reference/"),
        category_page(resolver, "text").with_part("Content"),
        category_page(resolver, "math"),
        category_page(resolver, "layout"),
        category_page(resolver, "visualize"),
        category_page(resolver, "meta"),
        category_page(resolver, "symbols"),
        category_page(resolver, "foundations").with_part("Compute"),
        category_page(resolver, "calculate"),
        category_page(resolver, "construct"),
        category_page(resolver, "data-loading"),
    ];
    page
}

/// Create a page from a markdown file.
#[track_caller]
fn markdown_page(
    resolver: &dyn Resolver,
    parent: &str,
    path: impl AsRef<Path>,
) -> PageModel {
    assert!(parent.starts_with('/') && parent.ends_with('/'));
    let md = SRC.get_file(path).unwrap().contents_utf8().unwrap();
    let html = Html::markdown(resolver, md);
    let title = html.title().expect("chapter lacks a title").to_string();
    PageModel {
        route: format!("{parent}{}/", urlify(&title)),
        title,
        description: html.description().unwrap(),
        part: None,
        body: BodyModel::Html(html),
        children: vec![],
    }
}

/// Details about a category.
#[derive(Debug, Serialize)]
pub struct CategoryModel {
    pub name: String,
    pub details: Html,
    pub kind: &'static str,
    pub items: Vec<CategoryItem>,
}

/// Details about a category item.
#[derive(Debug, Serialize)]
pub struct CategoryItem {
    pub name: String,
    pub route: String,
    pub oneliner: String,
    pub code: bool,
}

/// Create a page for a category.
#[track_caller]
fn category_page(resolver: &dyn Resolver, category: &str) -> PageModel {
    let route = format!("/docs/reference/{category}/");
    let mut children = vec![];
    let mut items = vec![];

    let focus = match category {
        "math" => &LIBRARY.math,
        "calculate" => module(&LIBRARY.global, "calc"),
        _ => &LIBRARY.global,
    };

    let grouped = match category {
        "math" => GROUPS.as_slice(),
        _ => &[],
    };

    // Add functions.
    for (_, value) in focus.scope().iter() {
        let Value::Func(func) = value else { continue };
        let Some(info) = func.info() else { continue };
        if info.category != category {
            continue;
        }

        // Skip grouped functions.
        if grouped
            .iter()
            .flat_map(|group| &group.functions)
            .any(|f| f == info.name)
        {
            continue;
        }

        let subpage = function_page(resolver, &route, func, info);
        items.push(CategoryItem {
            name: info.name.into(),
            route: subpage.route.clone(),
            oneliner: oneliner(info.docs).into(),
            code: true,
        });
        children.push(subpage);
    }

    // Add grouped functions.
    for group in grouped {
        let mut functions = vec![];
        for name in &group.functions {
            let value = focus.get(name).unwrap();
            let Value::Func(func) = value else { panic!("not a function") };
            let info = func.info().unwrap();
            functions.push(func_model(resolver, func, info));
        }

        let route = format!("{}{}/", route, group.name);
        items.push(CategoryItem {
            name: group.name.clone(),
            route: route.clone(),
            oneliner: oneliner(&group.description).into(),
            code: false,
        });
        children.push(PageModel {
            route,
            title: group.title.clone(),
            description: format!("Documentation for {} group of functions.", group.name),
            part: None,
            body: BodyModel::Funcs(FuncsModel {
                name: group.name.clone(),
                details: Html::markdown(resolver, &group.description),
                functions,
            }),
            children: vec![],
        });
    }

    children.sort_by_cached_key(|child| child.title.clone());
    items.sort_by_cached_key(|item| item.name.clone());

    // Add symbol pages. These are ordered manually.
    if category == "symbols" {
        for module in ["sym", "emoji"] {
            let subpage = symbol_page(resolver, &route, module);
            items.push(CategoryItem {
                name: module.into(),
                route: subpage.route.clone(),
                oneliner: oneliner(details(module)).into(),
                code: true,
            });
            children.push(subpage);
        }
    }

    let name = category.to_title_case();
    PageModel {
        route,
        title: name.clone(),
        description: format!("Documentation for functions related to {name} in Typst."),
        part: None,
        body: BodyModel::Category(CategoryModel {
            name,
            details: Html::markdown(resolver, details(category)),
            kind: match category {
                "symbols" => "Modules",
                _ => "Functions",
            },
            items,
        }),
        children,
    }
}

/// Details about a function.
#[derive(Debug, Serialize)]
pub struct FuncModel {
    pub name: &'static str,
    pub display: &'static str,
    pub oneliner: &'static str,
    pub showable: bool,
    pub details: Html,
    pub params: Vec<ParamModel>,
    pub returns: Vec<&'static str>,
    pub methods: Vec<MethodModel>,
}

/// Details about a group of functions.
#[derive(Debug, Serialize)]
pub struct FuncsModel {
    pub name: String,
    pub details: Html,
    pub functions: Vec<FuncModel>,
}

/// Create a page for a function.
fn function_page(
    resolver: &dyn Resolver,
    parent: &str,
    func: &Func,
    info: &FuncInfo,
) -> PageModel {
    PageModel {
        route: format!("{parent}{}/", urlify(info.name)),
        title: info.display.to_string(),
        description: format!("Documentation for the `{}` function.", info.name),
        part: None,
        body: BodyModel::Func(func_model(resolver, func, info)),
        children: vec![],
    }
}

/// Produce a function's model.
fn func_model(resolver: &dyn Resolver, func: &Func, info: &FuncInfo) -> FuncModel {
    let mut s = unscanny::Scanner::new(info.docs);
    let docs = s.eat_until("\n## Methods").trim();
    FuncModel {
        name: info.name,
        display: info.display,
        oneliner: oneliner(docs),
        showable: func.element().is_some(),
        details: Html::markdown(resolver, docs),
        params: info.params.iter().map(|param| param_model(resolver, param)).collect(),
        returns: info.returns.clone(),
        methods: method_models(resolver, info.docs),
    }
}

/// Details about a function parameter.
#[derive(Debug, Serialize)]
pub struct ParamModel {
    pub name: &'static str,
    pub details: Html,
    pub example: Option<Html>,
    pub types: Vec<&'static str>,
    pub strings: Vec<StrParam>,
    pub positional: bool,
    pub named: bool,
    pub required: bool,
    pub variadic: bool,
    pub settable: bool,
}

/// A specific string that can be passed as an argument.
#[derive(Debug, Serialize)]
pub struct StrParam {
    pub string: String,
    pub details: Html,
}

/// Produce a parameter's model.
fn param_model(resolver: &dyn Resolver, info: &ParamInfo) -> ParamModel {
    let mut types = vec![];
    let mut strings = vec![];
    casts(resolver, &mut types, &mut strings, &info.cast);
    if !strings.is_empty() && !types.contains(&"string") {
        types.push("string");
    }
    types.sort_by_key(|ty| type_index(ty));

    let mut details = info.docs;
    let mut example = None;
    if let Some(mut i) = info.docs.find("```example") {
        while info.docs[..i].ends_with('`') {
            i -= 1;
        }
        details = &info.docs[..i];
        example = Some(&info.docs[i..]);
    }

    ParamModel {
        name: info.name,
        details: Html::markdown(resolver, details),
        example: example.map(|md| Html::markdown(resolver, md)),
        types,
        strings,
        positional: info.positional,
        named: info.named,
        required: info.required,
        variadic: info.variadic,
        settable: info.settable,
    }
}

/// Process cast information into types and strings.
fn casts(
    resolver: &dyn Resolver,
    types: &mut Vec<&'static str>,
    strings: &mut Vec<StrParam>,
    info: &CastInfo,
) {
    match info {
        CastInfo::Any => types.push("any"),
        CastInfo::Value(Value::Str(string), docs) => strings.push(StrParam {
            string: string.to_string(),
            details: Html::markdown(resolver, docs),
        }),
        CastInfo::Value(..) => {}
        CastInfo::Type(ty) => types.push(ty),
        CastInfo::Union(options) => {
            for option in options {
                casts(resolver, types, strings, option);
            }
        }
    }
}

/// A collection of symbols.
#[derive(Debug, Serialize)]
pub struct TypeModel {
    pub name: String,
    pub oneliner: &'static str,
    pub details: Html,
    pub methods: Vec<MethodModel>,
}

/// Details about a built-in method on a type.
#[derive(Debug, Serialize)]
pub struct MethodModel {
    pub name: &'static str,
    pub details: Html,
    pub params: Vec<ParamModel>,
    pub returns: Vec<&'static str>,
}

/// Create a page for the types.
fn types_page(resolver: &dyn Resolver, parent: &str) -> PageModel {
    let route = format!("{parent}types/");
    let mut children = vec![];
    let mut items = vec![];

    for model in type_models(resolver) {
        let route = format!("{route}{}/", urlify(&model.name));
        items.push(CategoryItem {
            name: model.name.clone(),
            route: route.clone(),
            oneliner: model.oneliner.into(),
            code: true,
        });
        children.push(PageModel {
            route,
            title: model.name.to_title_case(),
            description: format!("Documentation for the `{}` type.", model.name),
            part: None,
            body: BodyModel::Type(model),
            children: vec![],
        });
    }

    PageModel {
        route,
        title: "Types".into(),
        description: "Documentation for Typst's built-in types.".into(),
        part: None,
        body: BodyModel::Category(CategoryModel {
            name: "Types".into(),
            details: Html::markdown(resolver, details("types")),
            kind: "Types",
            items,
        }),
        children,
    }
}

/// Produce the types' models.
fn type_models(resolver: &dyn Resolver) -> Vec<TypeModel> {
    let file = SRC.get_file("reference/types.md").unwrap();
    let text = file.contents_utf8().unwrap();

    let mut s = unscanny::Scanner::new(text);
    let mut types = vec![];

    while s.eat_if("# ") {
        let part = s.eat_until("\n# ");
        types.push(type_model(resolver, part));
        s.eat_if('\n');
    }

    types
}

/// Produce a type's model.
fn type_model(resolver: &dyn Resolver, part: &'static str) -> TypeModel {
    let mut s = unscanny::Scanner::new(part);
    let display = s.eat_until('\n').trim();
    let docs = s.eat_until("\n## Methods").trim();
    TypeModel {
        name: display.to_lowercase(),
        oneliner: oneliner(docs),
        details: Html::markdown(resolver, docs),
        methods: method_models(resolver, part),
    }
}

/// Produce multiple methods' models.
fn method_models(resolver: &dyn Resolver, docs: &'static str) -> Vec<MethodModel> {
    let mut s = unscanny::Scanner::new(docs);
    s.eat_until("\n## Methods");
    s.eat_whitespace();

    let mut methods = vec![];
    if s.eat_if("## Methods") {
        s.eat_until("\n### ");
        while s.eat_if("\n### ") {
            methods.push(method_model(resolver, s.eat_until("\n### ")));
        }
    }

    methods
}

/// Produce a method's model.
fn method_model(resolver: &dyn Resolver, part: &'static str) -> MethodModel {
    let mut s = unscanny::Scanner::new(part);
    let mut params = vec![];
    let mut returns = vec![];

    let name = s.eat_until('(').trim();
    s.expect("()");
    let docs = s.eat_until("\n- ").trim();

    while s.eat_if("\n- ") {
        let name = s.eat_until(':');
        s.expect(": ");
        let types: Vec<_> =
            s.eat_until(['(', '\n']).split(" or ").map(str::trim).collect();
        if !types.iter().all(|ty| type_index(ty) != usize::MAX) {
            panic!(
                "unknown type in method {} parameter {}",
                name,
                types.iter().find(|ty| type_index(ty) == usize::MAX).unwrap()
            )
        }

        if name == "returns" {
            returns = types;
            continue;
        }

        s.expect('(');

        let mut named = false;
        let mut positional = false;
        let mut required = false;
        let mut variadic = false;
        for part in s.eat_until(')').split(',').map(str::trim) {
            match part {
                "named" => named = true,
                "positional" => positional = true,
                "required" => required = true,
                "variadic" => variadic = true,
                _ => panic!("unknown parameter flag {:?}", part),
            }
        }

        s.expect(')');

        params.push(ParamModel {
            name,
            details: Html::markdown(resolver, s.eat_until("\n- ").trim()),
            example: None,
            types,
            strings: vec![],
            positional,
            named,
            required,
            variadic,
            settable: false,
        });
    }

    MethodModel {
        name,
        details: Html::markdown(resolver, docs),
        params,
        returns,
    }
}

/// A collection of symbols.
#[derive(Debug, Serialize)]
pub struct SymbolsModel {
    pub name: &'static str,
    pub details: Html,
    pub list: Vec<SymbolModel>,
}

/// Details about a symbol.
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SymbolModel {
    pub name: String,
    pub shorthand: Option<&'static str>,
    pub codepoint: u32,
    pub accent: bool,
    pub unicode_name: Option<String>,
    pub alternates: Vec<String>,
}

/// Create a page for symbols.
fn symbol_page(resolver: &dyn Resolver, parent: &str, name: &str) -> PageModel {
    let module = &module(&LIBRARY.global, name);

    let mut list = vec![];
    for (name, value) in module.scope().iter() {
        let Value::Symbol(symbol) = value else { continue };
        let complete = |variant: &str| {
            if variant.is_empty() {
                name.into()
            } else {
                format!("{}.{}", name, variant)
            }
        };

        for (variant, c) in symbol.variants() {
            list.push(SymbolModel {
                name: complete(variant),
                shorthand: typst::syntax::ast::Shorthand::LIST
                    .iter()
                    .copied()
                    .find(|&(_, x)| x == c)
                    .map(|(s, _)| s),
                codepoint: c as u32,
                accent: typst::eval::Symbol::combining_accent(c).is_some(),
                unicode_name: unicode_names2::name(c)
                    .map(|s| s.to_string().to_title_case()),
                alternates: symbol
                    .variants()
                    .filter(|(other, _)| other != &variant)
                    .map(|(other, _)| complete(other))
                    .collect(),
            });
        }
    }

    let title = match name {
        "sym" => "General",
        "emoji" => "Emoji",
        _ => unreachable!(),
    };

    PageModel {
        route: format!("{parent}{name}/"),
        title: title.into(),
        description: format!("Documentation for the `{name}` module."),
        part: None,
        body: BodyModel::Symbols(SymbolsModel {
            name: title,
            details: Html::markdown(resolver, details(name)),
            list,
        }),
        children: vec![],
    }
}

/// Data about a collection of functions.
#[derive(Debug, Deserialize)]
struct GroupData {
    name: String,
    title: String,
    functions: Vec<String>,
    description: String,
}

/// Extract a module from another module.
#[track_caller]
fn module<'a>(parent: &'a Module, name: &str) -> &'a Module {
    match parent.scope().get(name) {
        Some(Value::Module(module)) => module,
        _ => panic!("module doesn't contain module `{name}`"),
    }
}

/// Load YAML from a path.
#[track_caller]
fn yaml<T: DeserializeOwned>(path: &str) -> T {
    let file = SRC.get_file(path).unwrap();
    yaml::from_slice(file.contents()).unwrap()
}

/// Load details for an identifying key.
#[track_caller]
fn details(key: &str) -> &str {
    DETAILS
        .get(&yaml::Value::String(key.into()))
        .and_then(|value| value.as_str())
        .unwrap_or_else(|| panic!("missing details for {key}"))
}

/// Turn a title into an URL fragment.
pub fn urlify(title: &str) -> String {
    title
        .chars()
        .map(|c| c.to_ascii_lowercase())
        .map(|c| match c {
            'a'..='z' | '0'..='9' => c,
            _ => '-',
        })
        .collect()
}

/// Extract the first line of documentation.
fn oneliner(docs: &str) -> &str {
    docs.lines().next().unwrap_or_default()
}

/// The order of types in the documentation.
fn type_index(ty: &str) -> usize {
    TYPE_ORDER.iter().position(|&v| v == ty).unwrap_or(usize::MAX)
}

const TYPE_ORDER: &[&str] = &[
    "any",
    "none",
    "auto",
    "boolean",
    "integer",
    "float",
    "length",
    "angle",
    "ratio",
    "relative length",
    "fraction",
    "color",
    "string",
    "regex",
    "label",
    "content",
    "array",
    "dictionary",
    "function",
    "arguments",
    "location",
    "dir",
    "alignment",
    "2d alignment",
    "selector",
    "stroke",
];

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_docs() {
        provide(&TestResolver);
    }

    struct TestResolver;

    impl Resolver for TestResolver {
        fn link(&self, _: &str) -> Option<String> {
            None
        }

        fn example(&self, _: Html, _: &[Frame]) -> Html {
            Html::new(String::new())
        }

        fn image(&self, _: &str, _: &[u8]) -> String {
            String::new()
        }
    }
}