Auto merge of #150348 - GuillaumeGomez:update-askama, r=kobzol,jieyouxu
Update askama version to `0.15` New release comes with lots of improvements like improved compile-time. More information here: https://github.com/askama-rs/askama/releases/tag/v0.15.0 r? `@yotamofek`
This commit is contained in:
commit
112a274275
9 changed files with 112 additions and 123 deletions
62
Cargo.lock
62
Cargo.lock
|
|
@ -188,7 +188,20 @@ version = "0.14.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f75363874b771be265f4ffe307ca705ef6f3baa19011c149da8674a87f1b75c4"
|
||||
dependencies = [
|
||||
"askama_derive",
|
||||
"askama_derive 0.14.0",
|
||||
"itoa",
|
||||
"percent-encoding",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb7125972258312e79827b60c9eb93938334100245081cf701a2dee981b17427"
|
||||
dependencies = [
|
||||
"askama_macros",
|
||||
"itoa",
|
||||
"percent-encoding",
|
||||
"serde",
|
||||
|
|
@ -201,7 +214,7 @@ version = "0.14.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "129397200fe83088e8a68407a8e2b1f826cf0086b21ccdb866a722c8bcd3a94f"
|
||||
dependencies = [
|
||||
"askama_parser",
|
||||
"askama_parser 0.14.0",
|
||||
"basic-toml",
|
||||
"memchr",
|
||||
"proc-macro2",
|
||||
|
|
@ -212,6 +225,32 @@ dependencies = [
|
|||
"syn 2.0.110",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_derive"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ba5e7259a1580c61571e3116ebaaa01e3c001b2132b17c4cc5c70780ca3e994"
|
||||
dependencies = [
|
||||
"askama_parser 0.15.1",
|
||||
"basic-toml",
|
||||
"memchr",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustc-hash 2.1.1",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"syn 2.0.110",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_macros"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "236ce20b77cb13506eaf5024899f4af6e12e8825f390bd943c4c37fd8f322e46"
|
||||
dependencies = [
|
||||
"askama_derive 0.15.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_parser"
|
||||
version = "0.14.0"
|
||||
|
|
@ -224,6 +263,19 @@ dependencies = [
|
|||
"winnow 0.7.13",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_parser"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3c63392767bb2df6aa65a6e1e3b80fd89bb7af6d58359b924c0695620f1512e"
|
||||
dependencies = [
|
||||
"rustc-hash 2.1.1",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"unicode-ident",
|
||||
"winnow 0.7.13",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "assert_cmd"
|
||||
version = "2.1.1"
|
||||
|
|
@ -624,7 +676,7 @@ name = "clippy"
|
|||
version = "0.1.94"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"askama",
|
||||
"askama 0.14.0",
|
||||
"cargo_metadata 0.18.1",
|
||||
"clippy_config",
|
||||
"clippy_lints",
|
||||
|
|
@ -1515,7 +1567,7 @@ name = "generate-copyright"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"askama",
|
||||
"askama 0.15.1",
|
||||
"cargo_metadata 0.21.0",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
|
@ -4862,7 +4914,7 @@ name = "rustdoc"
|
|||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"askama",
|
||||
"askama 0.15.1",
|
||||
"base64",
|
||||
"expect-test",
|
||||
"indexmap",
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ pub static CRATES: &[&str] = &[
|
|||
// tidy-alphabetical-start
|
||||
"annotate-snippets",
|
||||
"anstyle",
|
||||
"askama_derive",
|
||||
"askama_parser",
|
||||
"basic-toml",
|
||||
"block-buffer",
|
||||
|
|
|
|||
|
|
@ -66,11 +66,11 @@ checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
|
|||
|
||||
[[package]]
|
||||
name = "askama"
|
||||
version = "0.14.0"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f75363874b771be265f4ffe307ca705ef6f3baa19011c149da8674a87f1b75c4"
|
||||
checksum = "bb7125972258312e79827b60c9eb93938334100245081cf701a2dee981b17427"
|
||||
dependencies = [
|
||||
"askama_derive",
|
||||
"askama_macros",
|
||||
"itoa",
|
||||
"percent-encoding",
|
||||
"serde",
|
||||
|
|
@ -79,9 +79,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "askama_derive"
|
||||
version = "0.14.0"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "129397200fe83088e8a68407a8e2b1f826cf0086b21ccdb866a722c8bcd3a94f"
|
||||
checksum = "8ba5e7259a1580c61571e3116ebaaa01e3c001b2132b17c4cc5c70780ca3e994"
|
||||
dependencies = [
|
||||
"askama_parser",
|
||||
"basic-toml",
|
||||
|
|
@ -95,14 +95,24 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_parser"
|
||||
version = "0.14.0"
|
||||
name = "askama_macros"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6ab5630b3d5eaf232620167977f95eb51f3432fc76852328774afbd242d4358"
|
||||
checksum = "236ce20b77cb13506eaf5024899f4af6e12e8825f390bd943c4c37fd8f322e46"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"askama_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_parser"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3c63392767bb2df6aa65a6e1e3b80fd89bb7af6d58359b924c0695620f1512e"
|
||||
dependencies = [
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"unicode-ident",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ edition = "2024"
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
askama = "0.14"
|
||||
askama = "0.15.1"
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
csv = "1"
|
||||
diff = "0.1"
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ passed: {{ r.passed.len() }}, ignored: {{ r.ignored.len() }}
|
|||
{% for (name, test) in root_tests %}
|
||||
<li>
|
||||
{% if let Some(result) = test.single_test() %}
|
||||
<b>{{ name }}</b> ({% call test_result(result) %})
|
||||
<b>{{ name }}</b> ({% call test_result(result) %}{% endcall %})
|
||||
{% else %}
|
||||
<b>{{ name }}</b> ({{ test.revisions.len() }} revision{{ test.revisions.len() | pluralize }})
|
||||
<ul>
|
||||
{% for (revision, result) in test.revisions %}
|
||||
<li>#<i>{{ revision }}</i> ({% call test_result(result) %})</li>
|
||||
<li>#<i>{{ revision }}</i> ({% call test_result(result) %}{% endcall %})</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ path = "lib.rs"
|
|||
[dependencies]
|
||||
# tidy-alphabetical-start
|
||||
arrayvec = { version = "0.7", default-features = false }
|
||||
askama = { version = "0.14", default-features = false, features = ["alloc", "config", "derive"] }
|
||||
askama = { version = "0.15.1", default-features = false, features = ["alloc", "config", "derive"] }
|
||||
base64 = "0.21.7"
|
||||
indexmap = { version = "2", features = ["serde"] }
|
||||
itertools = "0.12"
|
||||
|
|
|
|||
|
|
@ -40,90 +40,6 @@ use crate::html::render::sidebar::filters;
|
|||
use crate::html::render::{document_full, document_item_info};
|
||||
use crate::html::url_parts_builder::UrlPartsBuilder;
|
||||
|
||||
/// Generates an Askama template struct for rendering items with common methods.
|
||||
///
|
||||
/// Usage:
|
||||
/// ```ignore (illustrative)
|
||||
/// item_template!(
|
||||
/// #[template(path = "<template.html>", /* additional values */)]
|
||||
/// /* additional meta items */
|
||||
/// struct MyItem<'a, 'cx> {
|
||||
/// cx: RefCell<&'a mut Context<'cx>>,
|
||||
/// it: &'a clean::Item,
|
||||
/// /* additional fields */
|
||||
/// },
|
||||
/// methods = [ /* method names (comma separated; refer to macro definition of `item_template_methods!()`) */ ]
|
||||
/// )
|
||||
/// ```
|
||||
///
|
||||
/// NOTE: ensure that the generic lifetimes (`'a`, `'cx`) and
|
||||
/// required fields (`cx`, `it`) are identical (in terms of order and definition).
|
||||
macro_rules! item_template {
|
||||
(
|
||||
$(#[$meta:meta])*
|
||||
struct $name:ident<'a, 'cx> {
|
||||
cx: &'a Context<'cx>,
|
||||
it: &'a clean::Item,
|
||||
$($field_name:ident: $field_ty:ty),*,
|
||||
},
|
||||
methods = [$($methods:tt),* $(,)?]
|
||||
) => {
|
||||
#[derive(Template)]
|
||||
$(#[$meta])*
|
||||
struct $name<'a, 'cx> {
|
||||
cx: &'a Context<'cx>,
|
||||
it: &'a clean::Item,
|
||||
$($field_name: $field_ty),*
|
||||
}
|
||||
|
||||
impl<'a, 'cx: 'a> ItemTemplate<'a, 'cx> for $name<'a, 'cx> {
|
||||
fn item_and_cx(&self) -> (&'a clean::Item, &'a Context<'cx>) {
|
||||
(&self.it, &self.cx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'cx: 'a> $name<'a, 'cx> {
|
||||
item_template_methods!($($methods)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// Implement common methods for item template structs generated by `item_template!()`.
|
||||
///
|
||||
/// NOTE: this macro is intended to be used only by `item_template!()`.
|
||||
macro_rules! item_template_methods {
|
||||
() => {};
|
||||
(document $($rest:tt)*) => {
|
||||
fn document(&self) -> impl fmt::Display {
|
||||
let (item, cx) = self.item_and_cx();
|
||||
document(cx, item, None, HeadingOffset::H2)
|
||||
}
|
||||
item_template_methods!($($rest)*);
|
||||
};
|
||||
(document_type_layout $($rest:tt)*) => {
|
||||
fn document_type_layout(&self) -> impl fmt::Display {
|
||||
let (item, cx) = self.item_and_cx();
|
||||
let def_id = item.item_id.expect_def_id();
|
||||
document_type_layout(cx, def_id)
|
||||
}
|
||||
item_template_methods!($($rest)*);
|
||||
};
|
||||
(render_assoc_items $($rest:tt)*) => {
|
||||
fn render_assoc_items(&self) -> impl fmt::Display {
|
||||
let (item, cx) = self.item_and_cx();
|
||||
let def_id = item.item_id.expect_def_id();
|
||||
render_assoc_items(cx, item, def_id, AssocItemRender::All)
|
||||
}
|
||||
item_template_methods!($($rest)*);
|
||||
};
|
||||
($method:ident $($rest:tt)*) => {
|
||||
compile_error!(concat!("unknown method: ", stringify!($method)));
|
||||
};
|
||||
($token:tt $($rest:tt)*) => {
|
||||
compile_error!(concat!("unexpected token: ", stringify!($token)));
|
||||
};
|
||||
}
|
||||
|
||||
const ITEM_TABLE_OPEN: &str = "<dl class=\"item-table\">";
|
||||
const REEXPORTS_TABLE_OPEN: &str = "<dl class=\"item-table reexports\">";
|
||||
const ITEM_TABLE_CLOSE: &str = "</dl>";
|
||||
|
|
@ -300,10 +216,6 @@ fn toggle_close(mut w: impl fmt::Write) {
|
|||
w.write_str("</details>").unwrap();
|
||||
}
|
||||
|
||||
trait ItemTemplate<'a, 'cx: 'a>: askama::Template + Display {
|
||||
fn item_and_cx(&self) -> (&'a clean::Item, &'a Context<'cx>);
|
||||
}
|
||||
|
||||
fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> impl fmt::Display {
|
||||
fmt::from_fn(|w| {
|
||||
write!(w, "{}", document(cx, item, None, HeadingOffset::H2))?;
|
||||
|
|
@ -1482,20 +1394,32 @@ fn item_type_alias(cx: &Context<'_>, it: &clean::Item, t: &clean::TypeAlias) ->
|
|||
})
|
||||
}
|
||||
|
||||
item_template!(
|
||||
#[template(path = "item_union.html")]
|
||||
struct ItemUnion<'a, 'cx> {
|
||||
cx: &'a Context<'cx>,
|
||||
it: &'a clean::Item,
|
||||
fields: &'a [clean::Item],
|
||||
generics: &'a clean::Generics,
|
||||
is_type_alias: bool,
|
||||
def_id: DefId,
|
||||
},
|
||||
methods = [document, document_type_layout, render_assoc_items]
|
||||
);
|
||||
#[derive(Template)]
|
||||
#[template(path = "item_union.html")]
|
||||
struct ItemUnion<'a, 'cx> {
|
||||
cx: &'a Context<'cx>,
|
||||
it: &'a clean::Item,
|
||||
fields: &'a [clean::Item],
|
||||
generics: &'a clean::Generics,
|
||||
is_type_alias: bool,
|
||||
def_id: DefId,
|
||||
}
|
||||
|
||||
impl<'a, 'cx: 'a> ItemUnion<'a, 'cx> {
|
||||
fn document(&self) -> impl fmt::Display {
|
||||
document(self.cx, self.it, None, HeadingOffset::H2)
|
||||
}
|
||||
|
||||
fn document_type_layout(&self) -> impl fmt::Display {
|
||||
let def_id = self.it.item_id.expect_def_id();
|
||||
document_type_layout(self.cx, def_id)
|
||||
}
|
||||
|
||||
fn render_assoc_items(&self) -> impl fmt::Display {
|
||||
let def_id = self.it.item_id.expect_def_id();
|
||||
render_assoc_items(self.cx, self.it, def_id, AssocItemRender::All)
|
||||
}
|
||||
|
||||
fn render_union(&self) -> impl Display {
|
||||
render_union(
|
||||
self.it,
|
||||
|
|
|
|||
|
|
@ -128,10 +128,12 @@ pub(crate) mod filters {
|
|||
use askama::filters::Safe;
|
||||
|
||||
use crate::html::escape::EscapeBodyTextWithWbr;
|
||||
pub(crate) fn wrapped<T, V: askama::Values>(v: T, _: V) -> askama::Result<Safe<impl Display>>
|
||||
where
|
||||
T: Display,
|
||||
{
|
||||
|
||||
#[askama::filter_fn]
|
||||
pub(crate) fn wrapped(
|
||||
v: impl Display,
|
||||
_: &dyn askama::Values,
|
||||
) -> askama::Result<Safe<impl Display>> {
|
||||
let string = v.to_string();
|
||||
Ok(Safe(fmt::from_fn(move |f| EscapeBodyTextWithWbr(&string).fmt(f))))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ description = "Produces a manifest of all the copyrighted materials in the Rust
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1.0.65"
|
||||
askama = "0.14.0"
|
||||
askama = "0.15.1"
|
||||
cargo_metadata = "0.21"
|
||||
serde = { version = "1.0.147", features = ["derive"] }
|
||||
serde_json = "1.0.85"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue