Skip to content

Commit

Permalink
rustdoc: refactoring and tidying up
Browse files Browse the repository at this point in the history
pulled out of rust-lang#35020
  • Loading branch information
nrc committed Aug 16, 2016
1 parent 197be89 commit 7a7cd64
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 112 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ pub fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> {
url.push_str("/index.html");
}
_ => {
url.push_str(shortty.to_static_str());
url.push_str(shortty.css_class());
url.push_str(".");
url.push_str(fqp.last().unwrap());
url.push_str(".html");
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/item_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl ItemType {
}
}

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

impl fmt::Display for ItemType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.to_static_str().fmt(f)
self.css_class().fmt(f)
}
}
6 changes: 3 additions & 3 deletions src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct Layout {

pub struct Page<'a> {
pub title: &'a str,
pub ty: &'a str,
pub css_class: &'a str,
pub root_path: &'a str,
pub description: &'a str,
pub keywords: &'a str,
Expand Down Expand Up @@ -80,7 +80,7 @@ r##"<!DOCTYPE html>
</form>
</nav>
<section id='main' class="content {ty}">{content}</section>
<section id='main' class="content {css_class}">{content}</section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
Expand Down Expand Up @@ -152,7 +152,7 @@ r##"<!DOCTYPE html>
},
content = *t,
root_path = page.root_path,
ty = page.ty,
css_class = page.css_class,
logo = if layout.logo.is_empty() {
"".to_string()
} else {
Expand Down
Loading

0 comments on commit 7a7cd64

Please sign in to comment.