Skip to content

Commit 3d156ba

Browse files
Move back RustdocPage to web::rustdoc
1 parent 103b721 commit 3d156ba

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

src/utils/html.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use crate::web::page::templates::{Body, Head, RustdocPage, Vendored};
1+
use crate::web::page::templates::{Body, Head, Vendored};
2+
use crate::web::rustdoc::RustdocPage;
23
use lol_html::element;
34
use lol_html::errors::RewritingError;
45
use rinja::Template;

src/web/page/templates.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::error::Result;
2-
use crate::web::crate_details::CrateDetails;
3-
use crate::web::MetaData;
2+
use crate::web::rustdoc::RustdocPage;
43
use anyhow::Context;
54
use rinja::Template;
65
use std::{fmt, sync::Arc};
@@ -28,24 +27,6 @@ pub struct Vendored;
2827
#[template(path = "rustdoc/body.html")]
2928
pub struct Body;
3029

31-
#[derive(Template)]
32-
#[template(path = "rustdoc/topbar.html")]
33-
#[derive(Debug, Clone)]
34-
pub struct RustdocPage {
35-
pub latest_path: String,
36-
pub permalink_path: String,
37-
pub inner_path: String,
38-
// true if we are displaying the latest version of the crate, regardless
39-
// of whether the URL specifies a version number or the string "latest."
40-
pub is_latest_version: bool,
41-
// true if the URL specifies a version using the string "latest."
42-
pub is_latest_url: bool,
43-
pub is_prerelease: bool,
44-
pub krate: CrateDetails,
45-
pub metadata: MetaData,
46-
pub current_target: String,
47-
}
48-
4930
/// Holds all data relevant to templating
5031
#[derive(Debug)]
5132
pub(crate) struct TemplateData {

src/web/rustdoc.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ use crate::{
1414
extractors::{DbConnection, Path},
1515
file::File,
1616
match_version,
17-
page::templates::RustdocPage,
17+
page::templates::filters,
1818
page::TemplateData,
19-
ReqVersion,
19+
MetaData, ReqVersion,
2020
},
2121
AsyncStorage, Config, InstanceMetrics, RUSTDOC_STATIC_STORAGE_PREFIX,
2222
};
@@ -28,6 +28,7 @@ use axum::{
2828
};
2929
use lol_html::errors::RewritingError;
3030
use once_cell::sync::Lazy;
31+
use rinja::Template;
3132
use semver::Version;
3233
use serde::Deserialize;
3334
use std::{
@@ -258,6 +259,24 @@ pub(crate) async fn rustdoc_redirector_handler(
258259
}
259260
}
260261

262+
#[derive(Template)]
263+
#[template(path = "rustdoc/topbar.html")]
264+
#[derive(Debug, Clone)]
265+
pub struct RustdocPage {
266+
pub latest_path: String,
267+
pub permalink_path: String,
268+
pub inner_path: String,
269+
// true if we are displaying the latest version of the crate, regardless
270+
// of whether the URL specifies a version number or the string "latest."
271+
pub is_latest_version: bool,
272+
// true if the URL specifies a version using the string "latest."
273+
pub is_latest_url: bool,
274+
pub is_prerelease: bool,
275+
pub krate: CrateDetails,
276+
pub metadata: MetaData,
277+
pub current_target: String,
278+
}
279+
261280
impl RustdocPage {
262281
fn into_response(
263282
self,

0 commit comments

Comments
 (0)