]> git.lizzy.rs Git - rust.git/commitdiff
rustbook: Fix relative links on the Introduction page
authorNick Howell <howellnick@gmail.com>
Fri, 4 Sep 2015 21:00:33 +0000 (17:00 -0400)
committerNick Howell <howellnick@gmail.com>
Fri, 4 Sep 2015 21:00:33 +0000 (17:00 -0400)
The Introduction page generated by rustbook used weird relative links
like "./getting-started.html" instead of just "getting-started.html"
like on the other pages. This adversely affected Windows builds the
worst, since it generated links like ".\getting-started.html" (note the
backslash). If you then try to upload the generated book to a webserver,
you end up with 404's. See this example of what is going on with the
Introduction page links and why this PR should fix it:
http://is.gd/fRUTXk

Compare the links on these two pages, for instance:
https://doc.rust-lang.org/nightly/book/
https://doc.rust-lang.org/nightly/book/getting-started.html

Also, fix a few whitespace issues in build.rs.

src/rustbook/book.rs
src/rustbook/build.rs

index 2d630d8fe8de7ebd4a03d17cfcd1502832a53efb..e14c3346cc155f83a972e62d868e943983ba57b2 100644 (file)
@@ -102,7 +102,7 @@ fn collapse(stack: &mut Vec<BookItem>,
     top_items.push(BookItem {
         title: "Introduction".to_string(),
         path: PathBuf::from("README.md"),
-        path_to_root: PathBuf::from("."),
+        path_to_root: PathBuf::from(""),
         children: vec!(),
     });
 
index a1f4539443d9b6ab80ad74e85d579bb99197c4c8..aca0db4e1adbefad9bb35145f8eaad1043042cbd 100644 (file)
@@ -52,16 +52,16 @@ fn walk_item(item: &BookItem,
                  current_page: &BookItem,
                  out: &mut Write) -> io::Result<()> {
         let class_string = if item.path == current_page.path {
-          "class='active'"
+            "class='active'"
         } else {
-        ""
+            ""
         };
 
         try!(writeln!(out, "<li><a {} href='{}'><b>{}</b> {}</a>",
-                 class_string,
-                 current_page.path_to_root.join(&item.path).with_extension("html").display(),
-                 section,
-                 item.title));
+                      class_string,
+                      current_page.path_to_root.join(&item.path).with_extension("html").display(),
+                      section,
+                      item.title));
         if !item.children.is_empty() {
             try!(writeln!(out, "<ul class='section'>"));
             let _ = walk_items(&item.children[..], section, current_page, out);