Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 11 pull requests #58266

Merged
merged 23 commits into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
830b3b8
Re-enable history api on file:// protocol
GuillaumeGomez Jan 10, 2019
0c54d2d
Mention that core::intrinsics::transmute is available at core::mem::t…
jrvanwhy Jan 22, 2019
f978563
Update minifier version
GuillaumeGomez Jan 24, 2019
1c8c94a
Instead of adding a paragraph mentioning std::mem::transmute and core…
jrvanwhy Jan 25, 2019
30b1c35
rustdoc: remove blank unstable spans
euclio Jan 28, 2019
ea2b1b0
rustdoc: wrap stability tags in colored spans
euclio Jan 14, 2019
5cf20ca
Fix image link in the settings menu
GuillaumeGomez Jan 31, 2019
d80a558
Improve file list display
GuillaumeGomez Feb 2, 2019
c40fa32
sort elements in the sidebar
GuillaumeGomez Feb 4, 2019
d0f88c4
Prevent automatic collapse of methods impl blocks
GuillaumeGomez Feb 4, 2019
8b886e0
Remove images' url to make it work even without internet connection
GuillaumeGomez Feb 5, 2019
729e37d
Don't apply impl block collapse rules to trait impls
GuillaumeGomez Feb 4, 2019
55c0922
Rollup merge of #57504 - GuillaumeGomez:re-enable-history, r=QuietMis…
GuillaumeGomez Feb 7, 2019
2f2d61a
Rollup merge of #57848 - jrvanwhy:transmute-export-doc, r=QuietMisdre…
GuillaumeGomez Feb 7, 2019
4c62d7e
Rollup merge of #57884 - GuillaumeGomez:update-minifier-array, r=Quie…
GuillaumeGomez Feb 7, 2019
bb9d66d
Rollup merge of #57954 - euclio:rustdoc-stability, r=QuietMisdreavus
GuillaumeGomez Feb 7, 2019
1a99a32
Rollup merge of #58028 - GuillaumeGomez:fix-settings-image-link, r=Qu…
GuillaumeGomez Feb 7, 2019
f61a4f8
Rollup merge of #58033 - euclio:rustdoc-tags, r=QuietMisdreavus
GuillaumeGomez Feb 7, 2019
f22c445
Rollup merge of #58086 - GuillaumeGomez:rustdoc-file-list-improvement…
GuillaumeGomez Feb 7, 2019
2c9f1f5
Rollup merge of #58143 - GuillaumeGomez:sort-elements-in-sidebar, r=Q…
GuillaumeGomez Feb 7, 2019
064b787
Rollup merge of #58146 - GuillaumeGomez:dont-collapse-everything, r=Q…
GuillaumeGomez Feb 7, 2019
da8da5e
Rollup merge of #58150 - GuillaumeGomez:dont-apply-impl-collapse-rule…
GuillaumeGomez Feb 7, 2019
761caa2
Rollup merge of #58185 - GuillaumeGomez:images-url, r=SimonSapin
GuillaumeGomez Feb 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use std::path::PathBuf;

use externalfiles::ExternalHtml;

use html::render::SlashChecker;

#[derive(Clone)]
pub struct Layout {
pub logo: String,
Expand Down Expand Up @@ -176,16 +178,22 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
static_root_path = static_root_path,
root_path = page.root_path,
css_class = page.css_class,
logo = if layout.logo.is_empty() {
format!("<a href='{}{}/index.html'>\
<img src='{static_root_path}rust-logo{suffix}.png' alt='logo' width='100'></a>",
static_root_path=static_root_path,
suffix=page.resource_suffix)
} else {
format!("<a href='{}{}/index.html'>\
<img src='{}' alt='logo' width='100'></a>",
page.root_path, layout.krate,
layout.logo)
logo = {
let p = format!("{}{}", page.root_path, layout.krate);
let p = SlashChecker(&p);
if layout.logo.is_empty() {
format!("<a href='{path}index.html'>\
<img src='{static_root_path}rust-logo{suffix}.png' \
alt='logo' width='100'></a>",
path=p,
static_root_path=static_root_path,
suffix=page.resource_suffix)
} else {
format!("<a href='{}index.html'>\
<img src='{}' alt='logo' width='100'></a>",
p,
layout.logo)
}
},
title = page.title,
description = page.description,
Expand Down
20 changes: 16 additions & 4 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ use minifier;
/// A pair of name and its optional document.
pub type NameDoc = (String, Option<String>);

pub struct SlashChecker<'a>(pub &'a str);

impl<'a> Display for SlashChecker<'a> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
if !self.0.ends_with("/") && !self.0.is_empty() {
write!(f, "{}/", self.0)
} else {
write!(f, "{}", self.0)
}
}
}

/// Major driving force in all rustdoc rendering. This contains information
/// about where in the tree-like hierarchy rendering is occurring and controls
/// how the current page is being rendered.
Expand Down Expand Up @@ -1140,7 +1152,8 @@ themePicker.onblur = handleThemeButtonsBlur;
krates
.iter()
.map(|s| {
format!("<li><a href=\"{}/index.html\">{}</li>", s, s)
format!("<li><a href=\"{}index.html\">{}</li>",
SlashChecker(s), s)
})
.collect::<String>());
try_err!(layout::render(&mut w, &cx.shared.layout,
Expand Down Expand Up @@ -2075,8 +2088,7 @@ impl Context {
let mut themes = self.shared.themes.clone();
let sidebar = "<p class='location'>Settings</p><div class='sidebar-elems'></div>";
themes.push(PathBuf::from("settings.css"));
let mut layout = self.shared.layout.clone();
layout.krate = String::new();
let layout = self.shared.layout.clone();
try_err!(layout::render(&mut w, &layout,
&page, &sidebar, &settings,
self.shared.css_file_extension.is_some(),
Expand Down Expand Up @@ -2455,7 +2467,7 @@ impl<'a> fmt::Display for Item<'a> {

fn item_path(ty: ItemType, name: &str) -> String {
match ty {
ItemType::Module => format!("{}/index.html", name),
ItemType::Module => format!("{}index.html", SlashChecker(name)),
_ => format!("{}.{}.html", ty.css_class(), name),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// @has foo/keyword.match.html '//a[@class="keyword"]' 'match'
// @has foo/keyword.match.html '//span[@class="in-band"]' 'Keyword match'
// @has foo/keyword.match.html '//section[@id="main"]//div[@class="docblock"]//p' 'this is a test!'
// @!has foo/index.html '//a/@href' 'foo/index.html'
// @has foo/index.html '//a/@href' '../foo/index.html'
// @!has foo/foo/index.html
// @!has-dir foo/foo
#[doc(keyword = "match")]
Expand Down