Adapt docs infrastructure

This commit is contained in:
Laurenz 2023-07-04 15:49:02 +02:00
parent 615b1eacc7
commit 22052f4b59
3 changed files with 7 additions and 6 deletions

View File

@ -2,7 +2,7 @@ use std::cmp::Reverse;
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt::Write; use std::fmt::Write;
use serde::Deserialize; use serde::{Deserialize, Serialize};
use super::{Html, Resolver}; use super::{Html, Resolver};
@ -73,13 +73,13 @@ struct Contributor {
} }
/// A commit on the `typst` repository. /// A commit on the `typst` repository.
#[derive(Debug, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct Commit { pub struct Commit {
author: Author, author: Author,
} }
/// A commit author. /// A commit author.
#[derive(Debug, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct Author { pub struct Author {
login: String, login: String,
avatar_url: String, avatar_url: String,

View File

@ -446,7 +446,8 @@ fn code_block(resolver: &dyn Resolver, lang: &str, text: &str) -> Html {
frames.truncate(1); frames.truncate(1);
} }
resolver.example(highlighted, &frames) let hash = typst::util::hash128(text);
resolver.example(hash, highlighted, &frames)
} }
/// Extract an attribute value from an HTML element. /// Extract an attribute value from an HTML element.

View File

@ -73,7 +73,7 @@ pub trait Resolver {
fn image(&self, filename: &str, data: &[u8]) -> String; fn image(&self, filename: &str, data: &[u8]) -> String;
/// Produce HTML for an example. /// Produce HTML for an example.
fn example(&self, source: Html, frames: &[Frame]) -> Html; fn example(&self, hash: u128, source: Html, frames: &[Frame]) -> Html;
/// Determine the commits between two tags. /// Determine the commits between two tags.
fn commits(&self, from: &str, to: &str) -> Vec<Commit>; fn commits(&self, from: &str, to: &str) -> Vec<Commit>;
@ -988,7 +988,7 @@ mod tests {
None None
} }
fn example(&self, _: Html, _: &[Frame]) -> Html { fn example(&self, _: u128, _: Html, _: &[Frame]) -> Html {
Html::new(String::new()) Html::new(String::new())
} }