diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs index ab9c4ef942230..dc98a56eb1a4e 100644 --- a/src/librustdoc/markdown.rs +++ b/src/librustdoc/markdown.rs @@ -91,6 +91,7 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches, + {title} diff --git a/src/rustbook/build.rs b/src/rustbook/build.rs index 44b1630d9fb4c..50a6ad43aeeb1 100644 --- a/src/rustbook/build.rs +++ b/src/rustbook/build.rs @@ -20,6 +20,7 @@ use error::{Error, CliResult, CommandResult}; use book; use book::{Book, BookItem}; use css; +use javascript; use regex::Regex; @@ -63,7 +64,7 @@ fn write_toc(book: &Book, path_to_root: &Path, out: &mut Writer) -> IoResult<()> Ok(()) } - try!(writeln!(out, "
")); + try!(writeln!(out, "
")); try!(writeln!(out, "")); @@ -102,6 +103,14 @@ fn render(book: &Book, tgt: &Path) -> CliResult<()> { let prelude = tmp.path().join("prelude.html"); { let mut toc = BufferedWriter::new(try!(File::create(&prelude))); + try!(writeln!(&mut toc, r#""#)); let _ = write_toc(book, &item.path_to_root, &mut toc); try!(writeln!(&mut toc, "
")); try!(writeln!(&mut toc, "
")); @@ -111,6 +120,7 @@ fn render(book: &Book, tgt: &Path) -> CliResult<()> { let postlude = tmp.path().join("postlude.html"); { let mut toc = BufferedWriter::new(try!(File::create(&postlude))); + try!(toc.write_str(javascript::JAVASCRIPT)); try!(writeln!(&mut toc, "
")); } diff --git a/src/rustbook/css.rs b/src/rustbook/css.rs index 92433589155ba..65ba031a2d634 100644 --- a/src/rustbook/css.rs +++ b/src/rustbook/css.rs @@ -45,7 +45,7 @@ body { #page { margin-left: auto; margin-right:auto; - width: 750px; + max-width: 750px; } .chapter { @@ -69,4 +69,58 @@ body { .chapter li a { color: #000000; } + +@media only screen and (max-width: 1060px) { + #toc { + width: 100%; + margin-right: 0; + top: 40px; + } + #page-wrapper { + top: 40px; + left: 15px; + padding-right: 15px; + } + .mobile-hidden { + display: none; + } +} + + +#toggle-nav { + height: 20px; + width: 30px; + padding: 3px 3px 0 3px; +} + +#toggle-nav { + margin-top: 5px; + width: 30px; + height: 30px; + background-color: #FFF; + border: 1px solid #666; + border-radius: 3px 3px 3px 3px; +} + +.sr-only { + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + overflow: hidden; + clip: rect(0, 0, 0, 0); + border: 0; +} + +.bar { + display: block; + background-color: #000; + border-radius: 2px; + width: 100%; + height: 2px; + margin: 2px 0 3px; + padding: 0; +} + "#; diff --git a/src/rustbook/javascript.rs b/src/rustbook/javascript.rs new file mode 100644 index 0000000000000..eb4401e1835a2 --- /dev/null +++ b/src/rustbook/javascript.rs @@ -0,0 +1,43 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// The rust-book JavaScript in string form. + +pub static JAVASCRIPT: &'static str = r#" + +"#; diff --git a/src/rustbook/main.rs b/src/rustbook/main.rs index 48dad14321a8d..85b9a7d79dbfe 100644 --- a/src/rustbook/main.rs +++ b/src/rustbook/main.rs @@ -39,6 +39,7 @@ mod serve; mod test; mod css; +mod javascript; #[cfg(not(test))] // thanks #12327 fn main() {