Skip to content

Commit 8d40b9e

Browse files
Replace askama with rinja
1 parent 49649bf commit 8d40b9e

File tree

11 files changed

+68
-63
lines changed

11 files changed

+68
-63
lines changed

Diff for: Cargo.lock

+49-42
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
5151
checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
5252
dependencies = [
5353
"cfg-if",
54+
"getrandom",
5455
"once_cell",
5556
"version_check",
5657
"zerocopy",
@@ -243,47 +244,6 @@ version = "0.7.4"
243244
source = "registry+https://github.com/rust-lang/crates.io-index"
244245
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
245246

246-
[[package]]
247-
name = "askama"
248-
version = "0.12.1"
249-
source = "registry+https://github.com/rust-lang/crates.io-index"
250-
checksum = "b79091df18a97caea757e28cd2d5fda49c6cd4bd01ddffd7ff01ace0c0ad2c28"
251-
dependencies = [
252-
"askama_derive",
253-
"askama_escape",
254-
]
255-
256-
[[package]]
257-
name = "askama_derive"
258-
version = "0.12.5"
259-
source = "registry+https://github.com/rust-lang/crates.io-index"
260-
checksum = "19fe8d6cb13c4714962c072ea496f3392015f0989b1a2847bb4b2d9effd71d83"
261-
dependencies = [
262-
"askama_parser",
263-
"basic-toml",
264-
"mime",
265-
"mime_guess",
266-
"proc-macro2",
267-
"quote",
268-
"serde",
269-
"syn 2.0.67",
270-
]
271-
272-
[[package]]
273-
name = "askama_escape"
274-
version = "0.10.3"
275-
source = "registry+https://github.com/rust-lang/crates.io-index"
276-
checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341"
277-
278-
[[package]]
279-
name = "askama_parser"
280-
version = "0.2.1"
281-
source = "registry+https://github.com/rust-lang/crates.io-index"
282-
checksum = "acb1161c6b64d1c3d83108213c2a2533a342ac225aabd0bda218278c2ddb00c0"
283-
dependencies = [
284-
"nom",
285-
]
286-
287247
[[package]]
288248
name = "autocfg"
289249
version = "1.3.0"
@@ -2661,6 +2621,18 @@ version = "1.19.0"
26612621
source = "registry+https://github.com/rust-lang/crates.io-index"
26622622
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
26632623

2624+
[[package]]
2625+
name = "once_map"
2626+
version = "0.4.18"
2627+
source = "registry+https://github.com/rust-lang/crates.io-index"
2628+
checksum = "aa7085055bbe9c8edbd982048dbcf8181794d4a81cb04a11931673e63cc18dc6"
2629+
dependencies = [
2630+
"ahash",
2631+
"hashbrown",
2632+
"parking_lot",
2633+
"stable_deref_trait",
2634+
]
2635+
26642636
[[package]]
26652637
name = "opener"
26662638
version = "0.6.1"
@@ -3313,6 +3285,41 @@ dependencies = [
33133285
"walkdir",
33143286
]
33153287

3288+
[[package]]
3289+
name = "rinja"
3290+
version = "0.2.0"
3291+
source = "registry+https://github.com/rust-lang/crates.io-index"
3292+
checksum = "d2d47a46d7729e891c8accf260e9daa02ae6d570aa2a94fb1fb27eb5364a2323"
3293+
dependencies = [
3294+
"rinja_derive",
3295+
]
3296+
3297+
[[package]]
3298+
name = "rinja_derive"
3299+
version = "0.2.0"
3300+
source = "registry+https://github.com/rust-lang/crates.io-index"
3301+
checksum = "44dae9afe59d58ed8d988d67d1945f3638125d2fd2104058399382e11bd3ea2a"
3302+
dependencies = [
3303+
"basic-toml",
3304+
"mime",
3305+
"mime_guess",
3306+
"once_map",
3307+
"proc-macro2",
3308+
"quote",
3309+
"rinja_parser",
3310+
"serde",
3311+
"syn 2.0.67",
3312+
]
3313+
3314+
[[package]]
3315+
name = "rinja_parser"
3316+
version = "0.2.0"
3317+
source = "registry+https://github.com/rust-lang/crates.io-index"
3318+
checksum = "1b1771c78cd5d3b1646ef8d8f2ed100db936e8b291d3cc06e92a339ff346858c"
3319+
dependencies = [
3320+
"nom",
3321+
]
3322+
33163323
[[package]]
33173324
name = "rls"
33183325
version = "2.0.0"
@@ -4799,14 +4806,14 @@ name = "rustdoc"
47994806
version = "0.0.0"
48004807
dependencies = [
48014808
"arrayvec",
4802-
"askama",
48034809
"base64",
48044810
"expect-test",
48054811
"indexmap",
48064812
"itertools",
48074813
"minifier",
48084814
"pulldown-cmark 0.9.6",
48094815
"regex",
4816+
"rinja",
48104817
"rustdoc-json-types",
48114818
"serde",
48124819
"serde_json",

Diff for: src/librustdoc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ path = "lib.rs"
88

99
[dependencies]
1010
arrayvec = { version = "0.7", default-features = false }
11-
askama = { version = "0.12", default-features = false, features = ["config"] }
11+
rinja = { version = "0.2", default-features = false, features = ["config"] }
1212
base64 = "0.21.7"
1313
itertools = "0.12"
1414
indexmap = "2"

Diff for: src/librustdoc/html/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::externalfiles::ExternalHtml;
66
use crate::html::format::{Buffer, Print};
77
use crate::html::render::{ensure_trailing_slash, StylePath};
88

9-
use askama::Template;
9+
use rinja::Template;
1010

1111
use super::static_files::{StaticFiles, STATIC_FILES};
1212

Diff for: src/librustdoc/html/render/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use crate::html::url_parts_builder::UrlPartsBuilder;
3636
use crate::html::{layout, sources, static_files};
3737
use crate::scrape_examples::AllCallLocations;
3838
use crate::try_err;
39-
use askama::Template;
39+
use rinja::Template;
4040

4141
/// Major driving force in all rustdoc rendering. This contains information
4242
/// about where in the tree-like hierarchy rendering is occurring and controls

Diff for: src/librustdoc/html/render/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use std::path::PathBuf;
4646
use std::rc::Rc;
4747
use std::str;
4848

49-
use askama::Template;
49+
use rinja::Template;
5050
use rustc_attr::{ConstStability, DeprecatedSince, Deprecation, StabilityLevel, StableSince};
5151
use rustc_data_structures::captures::Captures;
5252
use rustc_data_structures::fx::{FxHashMap, FxHashSet};

Diff for: src/librustdoc/html/render/print_item.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ use crate::html::markdown::{HeadingOffset, MarkdownSummaryLine};
3636
use crate::html::render::{document_full, document_item_info};
3737
use crate::html::url_parts_builder::UrlPartsBuilder;
3838

39-
use askama::Template;
4039
use itertools::Itertools;
40+
use rinja::Template;
4141

42-
/// Generates an Askama template struct for rendering items with common methods.
42+
/// Generates a Rinja template struct for rendering items with common methods.
4343
///
4444
/// Usage:
4545
/// ```ignore (illustrative)
@@ -309,7 +309,7 @@ fn toggle_close(mut w: impl fmt::Write) {
309309
w.write_str("</details>").unwrap();
310310
}
311311

312-
trait ItemTemplate<'a, 'cx: 'a>: askama::Template + fmt::Display {
312+
trait ItemTemplate<'a, 'cx: 'a>: rinja::Template + fmt::Display {
313313
fn item_and_mut_cx(&self) -> (&'a clean::Item, RefMut<'_, &'a mut Context<'cx>>);
314314
}
315315

Diff for: src/librustdoc/html/render/sidebar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{borrow::Cow, rc::Rc};
22

3-
use askama::Template;
3+
use rinja::Template;
44
use rustc_data_structures::fx::FxHashSet;
55
use rustc_hir::{def::CtorKind, def_id::DefIdSet};
66
use rustc_middle::ty::{self, TyCtxt};

Diff for: src/librustdoc/html/render/type_layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use askama::Template;
1+
use rinja::Template;
22

33
use rustc_data_structures::captures::Captures;
44
use rustc_hir::def_id::DefId;

Diff for: src/librustdoc/html/sources.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::html::layout;
88
use crate::html::render::Context;
99
use crate::visit::DocVisitor;
1010

11-
use askama::Template;
11+
use rinja::Template;
1212
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1313
use rustc_hir::def_id::LOCAL_CRATE;
1414
use rustc_middle::ty::TyCtxt;

Diff for: src/librustdoc/html/templates/STYLE.md

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# Style for Templates
22

3-
This directory has templates in the [Tera templating language][teradoc], which is very
4-
similar to [Jinja2][jinjadoc] and [Django][djangodoc] templates, and also to [Askama][askamadoc].
3+
This directory has templates in the [Rinja templating language][rinjadoc], which is very
4+
similar to [Jinja2][jinjadoc].
55

6-
[teradoc]: https://tera.netlify.app/docs/#templates
76
[jinjadoc]: https://jinja.palletsprojects.com/en/3.1.x/templates/
8-
[djangodoc]: https://docs.djangoproject.com/en/4.1/topics/templates/
9-
[askamadoc]: https://docs.rs/askama/latest/askama/
7+
[rinjadoc]: https://docs.rs/rinja/latest/rinja/
108

119
We want our rendered output to have as little unnecessary whitespace as
12-
possible, so that pages load quickly. To achieve that we use Tera's
10+
possible, so that pages load quickly. To achieve that we use Rinja's
1311
[whitespace control] features. By default, whitespace characters are removed
1412
around jinja tags (`{% %}` for example). At the end of most lines, we put an
1513
empty comment tag: `{# #}`. This causes all whitespace between the end of the
@@ -20,19 +18,19 @@ remove following whitespace but not preceding. We also use the whitespace
2018
control characters in most instances of tags with control flow, for example
2119
`{% if foo %}`.
2220

23-
[whitespace control]: https://tera.netlify.app/docs/#whitespace-control
21+
[whitespace control]: https://rinja.readthedocs.io/en/stable/configuration.html#whitespace-control
2422

2523
We want our templates to be readable, so we use indentation and newlines
2624
liberally. We indent by four spaces after opening an HTML tag _or_ a Jinja
2725
tag. In most cases an HTML tag should be followed by a newline, but if the
2826
tag has simple contents and fits with its close tag on a single line, the
2927
contents don't necessarily need a new line.
3028

31-
Askama templates support quite sophisticated control flow. To keep our templates
29+
Rinja templates support quite sophisticated control flow. To keep our templates
3230
simple and understandable, we use only a subset: `if` and `for`. In particular
33-
we avoid [assignments in the template logic][assignments] and [Askama
31+
we avoid [assignments in the template logic][assignments] and [Rinja
3432
macros][macros]. This also may make things easier if we switch to a different
3533
Jinja-style template system in the future.
3634

37-
[assignments]: https://djc.github.io/askama/template_syntax.html#assignments
38-
[macros]: https://djc.github.io/askama/template_syntax.html#macros
35+
[assignments]: https://rinja.readthedocs.io/en/stable/template_syntax.html#assignments
36+
[macros]: https://rinja.readthedocs.io/en/stable/template_syntax.html#macros
File renamed without changes.

0 commit comments

Comments
 (0)