Skip to content

Commit 7a7cd64

Browse files
committed
rustdoc: refactoring and tidying up
pulled out of rust-lang#35020
1 parent 197be89 commit 7a7cd64

File tree

4 files changed

+114
-112
lines changed

4 files changed

+114
-112
lines changed

src/librustdoc/html/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ pub fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> {
326326
url.push_str("/index.html");
327327
}
328328
_ => {
329-
url.push_str(shortty.to_static_str());
329+
url.push_str(shortty.css_class());
330330
url.push_str(".");
331331
url.push_str(fqp.last().unwrap());
332332
url.push_str(".html");

src/librustdoc/html/item_type.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl ItemType {
9090
}
9191
}
9292

93-
pub fn to_static_str(&self) -> &'static str {
93+
pub fn css_class(&self) -> &'static str {
9494
match *self {
9595
ItemType::Module => "mod",
9696
ItemType::ExternCrate => "externcrate",
@@ -117,6 +117,6 @@ impl ItemType {
117117

118118
impl fmt::Display for ItemType {
119119
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
120-
self.to_static_str().fmt(f)
120+
self.css_class().fmt(f)
121121
}
122122
}

src/librustdoc/html/layout.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct Layout {
2424

2525
pub struct Page<'a> {
2626
pub title: &'a str,
27-
pub ty: &'a str,
27+
pub css_class: &'a str,
2828
pub root_path: &'a str,
2929
pub description: &'a str,
3030
pub keywords: &'a str,
@@ -80,7 +80,7 @@ r##"<!DOCTYPE html>
8080
</form>
8181
</nav>
8282
83-
<section id='main' class="content {ty}">{content}</section>
83+
<section id='main' class="content {css_class}">{content}</section>
8484
<section id='search' class="content hidden"></section>
8585
8686
<section class="footer"></section>
@@ -152,7 +152,7 @@ r##"<!DOCTYPE html>
152152
},
153153
content = *t,
154154
root_path = page.root_path,
155-
ty = page.ty,
155+
css_class = page.css_class,
156156
logo = if layout.logo.is_empty() {
157157
"".to_string()
158158
} else {

0 commit comments

Comments
 (0)