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 5 pull requests #46574

Merged
merged 12 commits into from
Dec 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
src/etc/installer/gfx/* binary
*.woff binary
src/vendor/** -text
Cargo.lock -merge
2 changes: 1 addition & 1 deletion src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ mod builtin {
#[cfg(dox)]
macro_rules! module_path { () => ({ /* compiler built-in */ }) }

/// Boolean evaluation of configuration flags.
/// Boolean evaluation of configuration flags, at compile-time.
///
/// For more information, see the documentation for [`std::cfg!`].
///
Expand Down
17 changes: 17 additions & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,12 @@ impl<T> Option<T> {

/// Returns the contained value or a default.
///
/// Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing
/// the result of a function call, it is recommended to use [`unwrap_or_else`],
/// which is lazily evaluated.
///
/// [`unwrap_or_else`]: #method.unwrap_or_else
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -451,11 +457,16 @@ impl<T> Option<T> {
/// Transforms the `Option<T>` into a [`Result<T, E>`], mapping [`Some(v)`] to
/// [`Ok(v)`] and [`None`] to [`Err(err)`].
///
/// Arguments passed to `ok_or` are eagerly evaluated; if you are passing the
/// result of a function call, it is recommended to use [`ok_or_else`], which is
/// lazily evaluated.
///
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
/// [`Ok(v)`]: ../../std/result/enum.Result.html#variant.Ok
/// [`Err(err)`]: ../../std/result/enum.Result.html#variant.Err
/// [`None`]: #variant.None
/// [`Some(v)`]: #variant.Some
/// [`ok_or_else`]: #method.ok_or_else
///
/// # Examples
///
Expand Down Expand Up @@ -644,6 +655,12 @@ impl<T> Option<T> {

/// Returns the option if it contains a value, otherwise returns `optb`.
///
/// Arguments passed to `or` are eagerly evaluated; if you are passing the
/// result of a function call, it is recommended to use [`or_else`], which is
/// lazily evaluated.
///
/// [`or_else`]: #method.or_else
///
/// # Examples
///
/// ```
Expand Down
10 changes: 10 additions & 0 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,13 @@ impl<T, E> Result<T, E> {

/// Returns `res` if the result is [`Err`], otherwise returns the [`Ok`] value of `self`.
///
/// Arguments passed to `or` are eagerly evaluated; if you are passing the
/// result of a function call, it is recommended to use [`or_else`], which is
/// lazily evaluated.
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
/// [`or_else`]: #method.or_else
///
/// # Examples
///
Expand Down Expand Up @@ -690,8 +695,13 @@ impl<T, E> Result<T, E> {
/// Unwraps a result, yielding the content of an [`Ok`].
/// Else, it returns `optb`.
///
/// Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing
/// the result of a function call, it is recommended to use [`unwrap_or_else`],
/// which is lazily evaluated.
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
/// [`unwrap_or_else`]: #method.unwrap_or_else
///
/// # Examples
///
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ r##"<!DOCTYPE html>
{before_content}

<nav class="sidebar">
<div class="sidebar-menu">&#9776;</div>
{logo}
{sidebar}
</nav>
Expand Down
7 changes: 7 additions & 0 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3542,6 +3542,7 @@ impl<'a> fmt::Display for Sidebar<'a> {
let cx = self.cx;
let it = self.item;
let parentlen = cx.current.len() - if it.is_mod() {1} else {0};
let mut should_close = false;

if it.is_struct() || it.is_trait() || it.is_primitive() || it.is_union()
|| it.is_enum() || it.is_mod() || it.is_typedef()
Expand Down Expand Up @@ -3575,6 +3576,8 @@ impl<'a> fmt::Display for Sidebar<'a> {
}
}

write!(fmt, "<div class=\"sidebar-elems\">")?;
should_close = true;
match it.inner {
clean::StructItem(ref s) => sidebar_struct(fmt, it, s)?,
clean::TraitItem(ref t) => sidebar_trait(fmt, it, t)?,
Expand Down Expand Up @@ -3625,6 +3628,10 @@ impl<'a> fmt::Display for Sidebar<'a> {
write!(fmt, "<script defer src=\"{path}sidebar-items.js\"></script>",
path = relpath)?;
}
if should_close {
// Closes sidebar-elems div.
write!(fmt, "</div>")?;
}

Ok(())
}
Expand Down
44 changes: 43 additions & 1 deletion src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,30 @@
return (elem.offsetParent === null)
}

function showSidebar() {
var elems = document.getElementsByClassName("sidebar-elems")[0];
if (elems) {
elems.style.display = "block";
}
var sidebar = document.getElementsByClassName('sidebar')[0];
sidebar.style.position = 'fixed';
sidebar.style.width = '100%';
sidebar.style.marginLeft = '0';
document.getElementsByTagName("body")[0].style.marginTop = '45px';
}

function hideSidebar() {
var elems = document.getElementsByClassName("sidebar-elems")[0];
if (elems) {
elems.style.display = "";
}
var sidebar = document.getElementsByClassName('sidebar')[0];
sidebar.style.position = '';
sidebar.style.width = '';
sidebar.style.marginLeft = '';
document.getElementsByTagName("body")[0].style.marginTop = '';
}

// used for special search precedence
var TY_PRIMITIVE = itemTypes.indexOf("primitive");

Expand All @@ -130,6 +154,8 @@
}

function highlightSourceLines(ev) {
// If we're in mobile mode, we should add the sidebar in any case.
hideSidebar();
var search = document.getElementById("search");
var i, from, to, match = window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/);
if (match) {
Expand Down Expand Up @@ -1459,7 +1485,7 @@

// delayed sidebar rendering.
function initSidebarItems(items) {
var sidebar = document.getElementsByClassName('sidebar')[0];
var sidebar = document.getElementsByClassName('sidebar-elems')[0];
var current = window.sidebarCurrent;

function block(shortty, longty) {
Expand Down Expand Up @@ -1829,6 +1855,22 @@
removeClass(search, "hidden");
search.innerHTML = '<h3 style="text-align: center;">Loading search results...</h3>';
}

var sidebar_menu = document.getElementsByClassName("sidebar-menu")[0];
if (sidebar_menu) {
sidebar_menu.onclick = function() {
var sidebar = document.getElementsByClassName('sidebar')[0];
if (sidebar.style.position === "fixed") {
hideSidebar();
} else {
showSidebar();
}
};
}

window.onresize = function() {
hideSidebar();
};
}());

// Sets the focus on the search bar at the top of the page
Expand Down
Loading