From a076961fd0e3d8a68f8b047460b8f5191d203b08 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 7 Feb 2017 18:13:57 -0500 Subject: [PATCH 1/8] Re-implement rustbook in terms of mdbook mdbook has a lot of optional dependencies that we don't want, so instead of using it directly, we re-build rustbook to use mdbook as a library. For convenience' sake, we keep the same CLI interface as mdbook; the only difference is that it only accepts build and test subcommands, rather than the full range. --- src/Cargo.lock | 216 +++++++++++++++++++++++- src/bootstrap/doc.rs | 1 + src/doc/book/src/SUMMARY.md | 3 + src/doc/book/src/chapter_1.md | 1 + src/doc/nomicon/src/SUMMARY.md | 3 + src/doc/nomicon/src/chapter_1.md | 1 + src/tools/rustbook/Cargo.toml | 13 +- src/tools/rustbook/book.rs | 171 ------------------- src/tools/rustbook/build.rs | 220 ------------------------- src/tools/rustbook/error.rs | 36 ---- src/tools/rustbook/help.rs | 46 ------ src/tools/rustbook/main.rs | 69 -------- src/tools/rustbook/serve.rs | 36 ---- src/tools/rustbook/src/main.rs | 79 +++++++++ src/tools/rustbook/static/rustbook.css | 157 ------------------ src/tools/rustbook/static/rustbook.js | 78 --------- src/tools/rustbook/subcommand.rs | 44 ----- src/tools/rustbook/term.rs | 34 ---- src/tools/rustbook/test.rs | 75 --------- 19 files changed, 311 insertions(+), 972 deletions(-) create mode 100644 src/doc/book/src/SUMMARY.md create mode 100644 src/doc/book/src/chapter_1.md create mode 100644 src/doc/nomicon/src/SUMMARY.md create mode 100644 src/doc/nomicon/src/chapter_1.md delete mode 100644 src/tools/rustbook/book.rs delete mode 100644 src/tools/rustbook/build.rs delete mode 100644 src/tools/rustbook/error.rs delete mode 100644 src/tools/rustbook/help.rs delete mode 100644 src/tools/rustbook/main.rs delete mode 100644 src/tools/rustbook/serve.rs create mode 100644 src/tools/rustbook/src/main.rs delete mode 100644 src/tools/rustbook/static/rustbook.css delete mode 100644 src/tools/rustbook/static/rustbook.js delete mode 100644 src/tools/rustbook/subcommand.rs delete mode 100644 src/tools/rustbook/term.rs delete mode 100644 src/tools/rustbook/test.rs diff --git a/src/Cargo.lock b/src/Cargo.lock index 219ed5d6bc2..51d45c06fcb 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -6,6 +6,14 @@ dependencies = [ "libc 0.0.0", ] +[[package]] +name = "aho-corasick" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "alloc" version = "0.0.0" @@ -31,10 +39,25 @@ dependencies = [ "libc 0.0.0", ] +[[package]] +name = "ansi_term" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "arena" version = "0.0.0" +[[package]] +name = "bitflags" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bitflags" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "bootstrap" version = "0.0.0" @@ -69,6 +92,21 @@ dependencies = [ name = "cargotest" version = "0.1.0" +[[package]] +name = "clap" +version = "2.19.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "term_size 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "vec_map 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cmake" version = "0.1.18" @@ -114,6 +152,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -158,6 +197,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "graphviz" version = "0.0.0" +[[package]] +name = "handlebars" +version = "0.20.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "quick-error 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "lazy_static" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "libc" version = "0.0.0" @@ -183,6 +249,27 @@ name = "log" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "mdbook" +version = "0.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "clap 2.19.3 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "handlebars 0.20.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "pulldown-cmark 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "memchr" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "num_cpus" version = "0.2.13" @@ -209,6 +296,11 @@ dependencies = [ "unwind 0.0.0", ] +[[package]] +name = "pest" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "proc_macro" version = "0.0.0" @@ -225,6 +317,15 @@ dependencies = [ "syntax_pos 0.0.0", ] +[[package]] +name = "pulldown-cmark" +version = "0.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "qemu-test-client" version = "0.1.0" @@ -233,6 +334,11 @@ version = "0.1.0" name = "qemu-test-server" version = "0.1.0" +[[package]] +name = "quick-error" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "rand" version = "0.0.0" @@ -240,9 +346,30 @@ dependencies = [ "core 0.0.0", ] +[[package]] +name = "regex" +version = "0.1.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex-syntax" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "rustbook" -version = "0.0.0" +version = "0.1.0" +dependencies = [ + "clap 2.19.3 (registry+https://github.com/rust-lang/crates.io-index)", + "mdbook 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "rustc" @@ -650,6 +777,11 @@ dependencies = [ "core 0.0.0", ] +[[package]] +name = "strsim" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "syntax" version = "0.0.0" @@ -685,6 +817,16 @@ dependencies = [ name = "term" version = "0.0.0" +[[package]] +name = "term_size" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "test" version = "0.0.0" @@ -700,6 +842,23 @@ dependencies = [ "test 0.0.0", ] +[[package]] +name = "thread-id" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "thread_local" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tidy" version = "0.1.0" @@ -712,14 +871,69 @@ dependencies = [ "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "unicode-segmentation" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unicode-width" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "utf8-ranges" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "vec_map" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [metadata] +"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" +"checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" +"checksum bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4f67931368edf3a9a51d29886d245f1c3db2f1ef0dcc9e35ff70341b78c10d23" +"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" +"checksum clap 2.19.3 (registry+https://github.com/rust-lang/crates.io-index)" = "95b78f3fe0fc94c13c731714363260e04b557a637166f33a4570d3189d642374" "checksum cmake 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0e5bcf27e097a184c1df4437654ed98df3d7a516e8508a6ba45d8b092bbdf283" "checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" "checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922" "checksum gcc 0.3.43 (registry+https://github.com/rust-lang/crates.io-index)" = "c07c758b972368e703a562686adb39125707cc1ef3399da8c019fc6c2498a75d" "checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685" +"checksum handlebars 0.20.5 (registry+https://github.com/rust-lang/crates.io-index)" = "07f9c1d28bcfb97143c95ed0667141677b2b5675c7ba3d5b81459ad43b1073bd" +"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +"checksum lazy_static 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "cf186d1a8aa5f5bee5fd662bc9c1b949e0259e1bcc379d1f006847b0080c7417" "checksum libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "044d1360593a78f5c8e5e710beccdc24ab71d1f01bc19a29bcacdba22e8475d8" "checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054" +"checksum mdbook 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "a629cd0194bbd0340a70db83a94b27cf9881fac8c55e6a2db983addcb7114ee4" +"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" "checksum num_cpus 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "cee7e88156f3f9e19bdd598f8d6c9db7bf4078f99f8381f43a55b09648d1a6e3" +"checksum pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0a6dda33d67c26f0aac90d324ab2eb7239c819fc7b2552fe9faa4fe88441edc8" +"checksum pulldown-cmark 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1058d7bb927ca067656537eec4e02c2b4b70eaaa129664c5b90c111e20326f41" +"checksum quick-error 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0aad603e8d7fb67da22dbdf1f4b826ce8829e406124109e73cf1b2454b93a71c" +"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" +"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" "checksum rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "6159e4e6e559c81bd706afe9c8fd68f547d3e851ce12e76b1de7914bab61691b" +"checksum strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "67f84c44fbb2f91db7fef94554e6b2ac05909c9c0b0bc23bb98d3a1aebfe7f7c" +"checksum term_size 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f7f5f3f71b0040cecc71af239414c23fd3c73570f5ff54cf50e03cef637f2a0" +"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" +"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" "checksum toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "0590d72182e50e879c4da3b11c6488dae18fccb1ae0c7a3eda18e16795844796" +"checksum unicode-segmentation 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c3bc443ded17b11305ffffe6b37e2076f328a5a8cb6aa877b1b98f77699e98b5" +"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" +"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" +"checksum vec_map 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cac5efe5cb0fa14ec2f84f83c701c562ee63f6dcc680861b21d65c682adfb05f" +"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 3dc9b837555..74b13144f2f 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -47,6 +47,7 @@ pub fn rustbook(build: &Build, target: &str, name: &str) { build.run(build.tool_cmd(&compiler, "rustbook") .arg("build") .arg(&src) + .arg("-d") .arg(out)); } diff --git a/src/doc/book/src/SUMMARY.md b/src/doc/book/src/SUMMARY.md new file mode 100644 index 00000000000..7390c82896e --- /dev/null +++ b/src/doc/book/src/SUMMARY.md @@ -0,0 +1,3 @@ +# Summary + +- [Chapter 1](./chapter_1.md) diff --git a/src/doc/book/src/chapter_1.md b/src/doc/book/src/chapter_1.md new file mode 100644 index 00000000000..b743fda3546 --- /dev/null +++ b/src/doc/book/src/chapter_1.md @@ -0,0 +1 @@ +# Chapter 1 diff --git a/src/doc/nomicon/src/SUMMARY.md b/src/doc/nomicon/src/SUMMARY.md new file mode 100644 index 00000000000..7390c82896e --- /dev/null +++ b/src/doc/nomicon/src/SUMMARY.md @@ -0,0 +1,3 @@ +# Summary + +- [Chapter 1](./chapter_1.md) diff --git a/src/doc/nomicon/src/chapter_1.md b/src/doc/nomicon/src/chapter_1.md new file mode 100644 index 00000000000..b743fda3546 --- /dev/null +++ b/src/doc/nomicon/src/chapter_1.md @@ -0,0 +1 @@ +# Chapter 1 diff --git a/src/tools/rustbook/Cargo.toml b/src/tools/rustbook/Cargo.toml index e7690c03de5..25c310aa877 100644 --- a/src/tools/rustbook/Cargo.toml +++ b/src/tools/rustbook/Cargo.toml @@ -1,9 +1,12 @@ [package] authors = ["The Rust Project Developers"] name = "rustbook" -version = "0.0.0" -build = false +version = "0.1.0" +license = "MIT/Apache-2.0" -[[bin]] -name = "rustbook" -path = "main.rs" +[dependencies] +clap = "2.19.3" + +[dependencies.mdbook] +version = "0.0.14" +default-features = false diff --git a/src/tools/rustbook/book.rs b/src/tools/rustbook/book.rs deleted file mode 100644 index c5f72127a9c..00000000000 --- a/src/tools/rustbook/book.rs +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2014 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. - -//! Basic data structures for representing a book. - -use std::io::prelude::*; -use std::io::BufReader; -use std::iter; -use std::path::{Path, PathBuf}; - -pub struct BookItem { - pub title: String, - pub path: PathBuf, - pub path_to_root: PathBuf, - pub children: Vec, -} - -pub struct Book { - pub chapters: Vec, -} - -/// A depth-first iterator over a book. -pub struct BookItems<'a> { - cur_items: &'a [BookItem], - cur_idx: usize, - stack: Vec<(&'a [BookItem], usize)>, -} - -impl<'a> Iterator for BookItems<'a> { - type Item = (String, &'a BookItem); - - fn next(&mut self) -> Option<(String, &'a BookItem)> { - loop { - if self.cur_idx >= self.cur_items.len() { - match self.stack.pop() { - None => return None, - Some((parent_items, parent_idx)) => { - self.cur_items = parent_items; - self.cur_idx = parent_idx + 1; - } - } - } else { - let cur = self.cur_items.get(self.cur_idx).unwrap(); - - let mut section = "".to_string(); - for &(_, idx) in &self.stack { - section.push_str(&(idx + 1).to_string()[..]); - section.push('.'); - } - section.push_str(&(self.cur_idx + 1).to_string()[..]); - section.push('.'); - - self.stack.push((self.cur_items, self.cur_idx)); - self.cur_items = &cur.children[..]; - self.cur_idx = 0; - return Some((section, cur)) - } - } - } -} - -impl Book { - pub fn iter(&self) -> BookItems { - BookItems { - cur_items: &self.chapters[..], - cur_idx: 0, - stack: Vec::new(), - } - } -} - -/// Construct a book by parsing a summary (markdown table of contents). -pub fn parse_summary(input: &mut Read, src: &Path) -> Result> { - fn collapse(stack: &mut Vec, - top_items: &mut Vec, - to_level: usize) { - loop { - if stack.len() < to_level { return } - if stack.len() == 1 { - top_items.push(stack.pop().unwrap()); - return; - } - - let tip = stack.pop().unwrap(); - let last = stack.len() - 1; - stack[last].children.push(tip); - } - } - - let mut top_items = vec![]; - let mut stack = vec![]; - let mut errors = vec![]; - - // always include the introduction - top_items.push(BookItem { - title: "Introduction".to_string(), - path: PathBuf::from("README.md"), - path_to_root: PathBuf::from(""), - children: vec![], - }); - - for line_result in BufReader::new(input).lines() { - let line = match line_result { - Ok(line) => line, - Err(err) => { - errors.push(err.to_string()); - return Err(errors); - } - }; - - let star_idx = match line.find("*") { Some(i) => i, None => continue }; - - let start_bracket = star_idx + line[star_idx..].find("[").unwrap(); - let end_bracket = start_bracket + line[start_bracket..].find("](").unwrap(); - let start_paren = end_bracket + 1; - let end_paren = start_paren + line[start_paren..].find(")").unwrap(); - - let given_path = &line[start_paren + 1 .. end_paren]; - let title = line[start_bracket + 1..end_bracket].to_string(); - let indent = &line[..star_idx]; - - let path_from_root = match src.join(given_path).strip_prefix(src) { - Ok(p) => p.to_path_buf(), - Err(..) => { - errors.push(format!("paths in SUMMARY.md must be relative, \ - but path '{}' for section '{}' is not.", - given_path, title)); - PathBuf::new() - } - }; - let path_to_root = PathBuf::from(&iter::repeat("../") - .take(path_from_root.components().count() - 1) - .collect::()); - let item = BookItem { - title: title, - path: path_from_root, - path_to_root: path_to_root, - children: vec![], - }; - let level = indent.chars().map(|c| -> usize { - match c { - ' ' => 1, - '\t' => 4, - _ => unreachable!() - } - }).sum::() / 4 + 1; - - if level > stack.len() + 1 { - errors.push(format!("section '{}' is indented too deeply; \ - found {}, expected {} or less", - item.title, level, stack.len() + 1)); - } else if level <= stack.len() { - collapse(&mut stack, &mut top_items, level); - } - stack.push(item) - } - - if errors.is_empty() { - collapse(&mut stack, &mut top_items, 1); - Ok(Book { chapters: top_items }) - } else { - Err(errors) - } -} diff --git a/src/tools/rustbook/build.rs b/src/tools/rustbook/build.rs deleted file mode 100644 index d88ff48843a..00000000000 --- a/src/tools/rustbook/build.rs +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright 2014-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. - -//! Implementation of the `build` subcommand, used to compile a book. - -use std::env; -use std::fs::{self, File}; -use std::io::prelude::*; -use std::io::{self, BufWriter}; -use std::path::{Path, PathBuf}; -use rustc_back::tempdir::TempDir; - -use subcommand::Subcommand; -use term::Term; -use error::{err, CliResult, CommandResult}; -use book; -use book::{Book, BookItem}; - -use rustdoc; - -struct Build; - -pub fn parse_cmd(name: &str) -> Option> { - if name == "build" { - Some(Box::new(Build)) - } else { - None - } -} - -fn write_toc(book: &Book, current_page: &BookItem, out: &mut Write) -> io::Result<()> { - fn walk_items(items: &[BookItem], - section: &str, - current_page: &BookItem, - out: &mut Write) -> io::Result<()> { - for (i, item) in items.iter().enumerate() { - walk_item(item, &format!("{}{}.", section, i + 1)[..], current_page, out)?; - } - Ok(()) - } - fn walk_item(item: &BookItem, - section: &str, - current_page: &BookItem, - out: &mut Write) -> io::Result<()> { - let class_string = if item.path == current_page.path { - "class='active'" - } else { - "" - }; - - writeln!(out, "
  • {} {}", - class_string, - current_page.path_to_root.join(&item.path).with_extension("html").display(), - section, - item.title)?; - if !item.children.is_empty() { - writeln!(out, "
      ")?; - let _ = walk_items(&item.children[..], section, current_page, out); - writeln!(out, "
    ")?; - } - writeln!(out, "
  • ")?; - - Ok(()) - } - - writeln!(out, "
    ")?; - writeln!(out, "
      ")?; - walk_items(&book.chapters[..], "", ¤t_page, out)?; - writeln!(out, "
    ")?; - writeln!(out, "
    ")?; - - Ok(()) -} - -fn render(book: &Book, tgt: &Path) -> CliResult<()> { - let tmp = TempDir::new("rustbook")?; - - for (_section, item) in book.iter() { - let out_path = match item.path.parent() { - Some(p) => tgt.join(p), - None => tgt.to_path_buf(), - }; - - let src; - if env::args().len() < 3 { - src = env::current_dir().unwrap().clone(); - } else { - src = PathBuf::from(&env::args().nth(2).unwrap()); - } - // preprocess the markdown, rerouting markdown references to html - // references - let mut markdown_data = String::new(); - File::open(&src.join(&item.path)).and_then(|mut f| { - f.read_to_string(&mut markdown_data) - })?; - let preprocessed_path = tmp.path().join(item.path.file_name().unwrap()); - { - let urls = markdown_data.replace(".md)", ".html)"); - File::create(&preprocessed_path).and_then(|mut f| { - f.write_all(urls.as_bytes()) - })?; - } - - // write the prelude to a temporary HTML file for rustdoc inclusion - let prelude = tmp.path().join("prelude.html"); - { - let mut buffer = BufWriter::new(File::create(&prelude)?); - writeln!(&mut buffer, r#" - "#)?; - let _ = write_toc(book, &item, &mut buffer); - writeln!(&mut buffer, "
    ")?; - writeln!(&mut buffer, "
    ")?; - } - - // write the postlude to a temporary HTML file for rustdoc inclusion - let postlude = tmp.path().join("postlude.html"); - { - let mut buffer = BufWriter::new(File::create(&postlude)?); - writeln!(&mut buffer, "")?; - writeln!(&mut buffer, "
    ")?; - } - - fs::create_dir_all(&out_path)?; - - let rustdoc_args: &[String] = &[ - "".to_string(), - preprocessed_path.display().to_string(), - format!("-o{}", out_path.display()), - format!("--html-before-content={}", prelude.display()), - format!("--html-after-content={}", postlude.display()), - format!("--markdown-playground-url=https://play.rust-lang.org/"), - format!("--markdown-css={}", item.path_to_root.join("rustbook.css").display()), - "--markdown-no-toc".to_string(), - ]; - let output_result = rustdoc::main_args(rustdoc_args); - if output_result != 0 { - let message = format!("Could not execute `rustdoc` with {:?}: {}", - rustdoc_args, output_result); - return Err(err(&message)); - } - } - - // create index.html from the root README - fs::copy(&tgt.join("README.html"), &tgt.join("index.html"))?; - - Ok(()) -} - -impl Subcommand for Build { - fn parse_args(&mut self, _: &[String]) -> CliResult<()> { - Ok(()) - } - fn usage(&self) {} - fn execute(&mut self, term: &mut Term) -> CommandResult<()> { - let cwd = env::current_dir().unwrap(); - let src; - let tgt; - - if env::args().len() < 3 { - src = cwd.clone(); - } else { - src = PathBuf::from(&env::args().nth(2).unwrap()); - } - - if env::args().len() < 4 { - tgt = cwd.join("_book"); - } else { - tgt = PathBuf::from(&env::args().nth(3).unwrap()); - } - - // `_book` directory may already exist from previous runs. Check and - // delete it if it exists. - for entry in fs::read_dir(&cwd)? { - let path = entry?.path(); - if path == tgt { fs::remove_dir_all(&tgt)? } - } - fs::create_dir(&tgt)?; - - // Copy static files - let css = include_bytes!("static/rustbook.css"); - let js = include_bytes!("static/rustbook.js"); - - let mut css_file = File::create(tgt.join("rustbook.css"))?; - css_file.write_all(css)?; - - let mut js_file = File::create(tgt.join("rustbook.js"))?; - js_file.write_all(js)?; - - - let mut summary = File::open(&src.join("SUMMARY.md"))?; - match book::parse_summary(&mut summary, &src) { - Ok(book) => { - // execute rustdoc on the whole book - render(&book, &tgt) - } - Err(errors) => { - let n = errors.len(); - for err in errors { - term.err(&format!("error: {}", err)[..]); - } - - Err(err(&format!("{} errors occurred", n))) - } - } - } -} diff --git a/src/tools/rustbook/error.rs b/src/tools/rustbook/error.rs deleted file mode 100644 index e896dee2791..00000000000 --- a/src/tools/rustbook/error.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 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. - -//! Error handling utilities. WIP. - -use std::error::Error; -use std::fmt; - -pub type CliError = Box; -pub type CliResult = Result; - -pub type CommandError = Box; -pub type CommandResult = Result; - -pub fn err(s: &str) -> CliError { - #[derive(Debug)] - struct E(String); - - impl Error for E { - fn description(&self) -> &str { &self.0 } - } - impl fmt::Display for E { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.0.fmt(f) - } - } - - Box::new(E(s.to_string())) -} diff --git a/src/tools/rustbook/help.rs b/src/tools/rustbook/help.rs deleted file mode 100644 index c90c2b93609..00000000000 --- a/src/tools/rustbook/help.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 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. - -//! Implementation of the `help` subcommand. Currently just prints basic usage info. - -use subcommand::Subcommand; -use error::CliResult; -use error::CommandResult; -use term::Term; - -struct Help; - -pub fn parse_cmd(name: &str) -> Option> { - match name { - "help" | "--help" | "-h" | "-?" => Some(Box::new(Help)), - _ => None - } -} - -impl Subcommand for Help { - fn parse_args(&mut self, _: &[String]) -> CliResult<()> { - Ok(()) - } - fn usage(&self) {} - fn execute(&mut self, _: &mut Term) -> CommandResult<()> { - usage(); - Ok(()) - } -} - -pub fn usage() { - println!("Usage: rustbook []"); - println!(""); - println!("The must be one of:"); - println!(" help Print this message."); - println!(" build Build the book in subdirectory _book"); - println!(" serve --NOT YET IMPLEMENTED--"); - println!(" test --NOT YET IMPLEMENTED--"); -} diff --git a/src/tools/rustbook/main.rs b/src/tools/rustbook/main.rs deleted file mode 100644 index 906251db1c2..00000000000 --- a/src/tools/rustbook/main.rs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2014 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. - -#![deny(warnings)] - -#![feature(rustc_private)] -#![feature(rustdoc)] - -extern crate rustdoc; -extern crate rustc_back; - -use std::env; -use std::process; -use std::sync::atomic::{AtomicIsize, ATOMIC_ISIZE_INIT, Ordering}; -use term::Term; - -mod term; -mod error; -mod book; - -mod subcommand; -mod help; -mod build; -mod serve; -mod test; - -static EXIT_STATUS: AtomicIsize = ATOMIC_ISIZE_INIT; - -pub fn main() { - let mut term = Term::new(); - let cmd: Vec<_> = env::args().collect(); - - if cmd.len() <= 1 { - help::usage() - } else { - match subcommand::parse_name(&cmd[1][..]) { - Some(mut subcmd) => { - match subcmd.parse_args(&cmd[..cmd.len()-1]) { - Ok(_) => { - match subcmd.execute(&mut term) { - Ok(_) => (), - Err(err) => { - term.err(&format!("error: {}", err)); - } - } - } - Err(err) => { - println!("{}", err.description()); - println!(""); - subcmd.usage(); - } - } - } - None => { - println!("Unrecognized command '{}'.", cmd[1]); - println!(""); - help::usage(); - } - } - } - process::exit(EXIT_STATUS.load(Ordering::SeqCst) as i32); -} diff --git a/src/tools/rustbook/serve.rs b/src/tools/rustbook/serve.rs deleted file mode 100644 index 2fa7b7eed7b..00000000000 --- a/src/tools/rustbook/serve.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 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. - -//! Implementation of the `serve` subcommand. Just a stub for now. - -use subcommand::Subcommand; -use error::CliResult; -use error::CommandResult; -use term::Term; - -struct Serve; - -pub fn parse_cmd(name: &str) -> Option> { - if name == "serve" { - Some(Box::new(Serve)) - } else { - None - } -} - -impl Subcommand for Serve { - fn parse_args(&mut self, _: &[String]) -> CliResult<()> { - Ok(()) - } - fn usage(&self) {} - fn execute(&mut self, _: &mut Term) -> CommandResult<()> { - Ok(()) - } -} diff --git a/src/tools/rustbook/src/main.rs b/src/tools/rustbook/src/main.rs new file mode 100644 index 00000000000..837c934934a --- /dev/null +++ b/src/tools/rustbook/src/main.rs @@ -0,0 +1,79 @@ +extern crate mdbook; +#[macro_use] +extern crate clap; + +use std::env; +use std::error::Error; +use std::io::{self, Write}; +use std::path::{Path, PathBuf}; + +use clap::{App, ArgMatches, SubCommand, AppSettings}; + +use mdbook::MDBook; + +const NAME: &'static str = "rustbook"; + +fn main() { + // Create a list of valid arguments and sub-commands + let matches = App::new(NAME) + .about("Build a book with mdBook") + .author("Steve Klabnik ") + .version(&*format!("v{}", crate_version!())) + .setting(AppSettings::SubcommandRequired) + .subcommand(SubCommand::with_name("build") + .about("Build the book from the markdown files") + .arg_from_usage("-d, --dest-dir=[dest-dir] 'The output directory for your book{n}(Defaults to ./book when omitted)'") + .arg_from_usage("[dir] 'A directory for your book{n}(Defaults to Current Directory when omitted)'")) + .get_matches(); + + // Check which subcomamnd the user ran... + let res = match matches.subcommand() { + ("build", Some(sub_matches)) => build(sub_matches), + ("test", Some(sub_matches)) => test(sub_matches), + (_, _) => unreachable!(), + }; + + if let Err(e) = res { + writeln!(&mut io::stderr(), "An error occured:\n{}", e).ok(); + ::std::process::exit(101); + } +} + +// Build command implementation +fn build(args: &ArgMatches) -> Result<(), Box> { + let book_dir = get_book_dir(args); + let book = MDBook::new(&book_dir).read_config(); + + let mut book = match args.value_of("dest-dir") { + Some(dest_dir) => book.set_dest(Path::new(dest_dir)), + None => book + }; + + try!(book.build()); + + Ok(()) +} + +fn test(args: &ArgMatches) -> Result<(), Box> { + let book_dir = get_book_dir(args); + let mut book = MDBook::new(&book_dir).read_config(); + + try!(book.test()); + + Ok(()) +} + +fn get_book_dir(args: &ArgMatches) -> PathBuf { + if let Some(dir) = args.value_of("dir") { + // Check if path is relative from current dir, or absolute... + let p = Path::new(dir); + if p.is_relative() { + env::current_dir().unwrap().join(dir) + } else { + p.to_path_buf() + } + } else { + env::current_dir().unwrap() + } +} + diff --git a/src/tools/rustbook/static/rustbook.css b/src/tools/rustbook/static/rustbook.css deleted file mode 100644 index ba0151fa2ed..00000000000 --- a/src/tools/rustbook/static/rustbook.css +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Copyright 2013-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. - */ - -@import url('../rust.css'); - -body { - max-width: none; - font: 16px/1.6 'Source Serif Pro', Georgia, Times, 'Times New Roman', serif; - color: #333; -} - -h1, h2, h3, h4, h5, h6 { - font-family: 'Open Sans', 'Fira Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; - font-weight: bold; - color: #333; -} - -@media only screen { - #toc { - position: fixed; - top: 0; - left: 0; - bottom: 0; - width: 300px; - overflow-y: auto; - border-right: 1px solid #e8e8e8; - padding: 0 15px; - font-size: 14px; - background-color: #fafafa; - -webkit-overflow-scrolling: touch; - } - - #page-wrapper { - position: absolute; - top: 0; - left: 300px; - right: 0; - padding: 0 15px; - -webkit-overflow-scrolling: touch; - } -} - -@media only print { - #toc, #nav { - display: none; - } -} - -@media only screen and (max-width: 1023px) { - #toc { - width: 100%; - top: 40px; - } - - #page-wrapper { - top: 40px; - left: 0; - } - - .mobile-hidden { - display: none; - } -} - -#page { - margin: 0 auto; - max-width: 750px; - padding-bottom: 50px; -} - -.chapter { - list-style: none; - padding-left: 0; - line-height: 30px; -} - -.section { - list-style: none; - padding-left: 20px; - line-height: 40px; -} - -.section li { - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; -} - -.chapter li a { - color: #333; - padding: 5px 0; -} - -.chapter li a.active, -.chapter li a:hover { - color: #008cff; - text-decoration: none; -} - -#toggle-nav { - cursor: pointer; - margin-top: 5px; - width: 30px; - height: 30px; - background-color: #fff; - border: 1px solid #666; - border-radius: 3px; - padding: 3px 3px 0 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; -} - -pre { - padding: 11px; - overflow: auto; - font-size: 85%; - line-height: 1.45; - background-color: #f7f7f7; - border: 0; - border-radius: 3px; -} - -.left { - float: left; -} - -.right { - float: right; -} diff --git a/src/tools/rustbook/static/rustbook.js b/src/tools/rustbook/static/rustbook.js deleted file mode 100644 index d8ab15260ed..00000000000 --- a/src/tools/rustbook/static/rustbook.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2014-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. - -/*jslint browser: true, es5: true */ -/*globals $: true, rootPath: true */ - -document.addEventListener('DOMContentLoaded', function() { - 'use strict'; - - document.getElementById('toggle-nav').onclick = function(e) { - var toc = document.getElementById('toc'); - var pagewrapper = document.getElementById('page-wrapper'); - toggleClass(toc, 'mobile-hidden'); - toggleClass(pagewrapper, 'mobile-hidden'); - }; - - function toggleClass(el, className) { - // from http://youmightnotneedjquery.com/ - if (el.classList) { - el.classList.toggle(className); - } else { - var classes = el.className.split(' '); - var existingIndex = classes.indexOf(className); - - if (existingIndex >= 0) { - classes.splice(existingIndex, 1); - } else { - classes.push(className); - } - - el.className = classes.join(' '); - } - } - - // The below code is used to add prev and next navigation links to the - // bottom of each of the sections. - // It works by extracting the current page based on the url and iterates - // over the menu links until it finds the menu item for the current page. We - // then create a copy of the preceding and following menu links and add the - // correct css class and insert them into the bottom of the page. - var toc = document.getElementById('toc').getElementsByTagName('a'); - var href = document.location.pathname.split('/').pop(); - - if (href === 'index.html' || href === '') { - href = 'README.html'; - } - - for (var i = 0; i < toc.length; i++) { - if (toc[i].attributes.href.value.split('/').pop() === href) { - var nav = document.createElement('p'); - - if (i > 0) { - var prevNode = toc[i-1].cloneNode(true); - prevNode.className = 'left'; - prevNode.setAttribute('rel', 'prev'); - nav.appendChild(prevNode); - } - - if (i < toc.length - 1) { - var nextNode = toc[i+1].cloneNode(true); - nextNode.className = 'right'; - nextNode.setAttribute('rel', 'next'); - nav.appendChild(nextNode); - } - - document.getElementById('page').appendChild(nav); - - break; - } - } -}); diff --git a/src/tools/rustbook/subcommand.rs b/src/tools/rustbook/subcommand.rs deleted file mode 100644 index a66c2b4f302..00000000000 --- a/src/tools/rustbook/subcommand.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2014 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. - -//! Common API for all rustbook subcommands. - -use error::CliResult; -use error::CommandResult; -use term::Term; - -use help; -use build; -use serve; -use test; - -pub trait Subcommand { - /// Mutate the subcommand by parsing its arguments. - /// - /// Returns `Err` on a parsing error. - fn parse_args(&mut self, args: &[String]) -> CliResult<()>; - /// Print the CLI usage information. - fn usage(&self); - /// Actually execute the subcommand. - fn execute(&mut self, term: &mut Term) -> CommandResult<()>; -} - -/// Create a Subcommand object based on its name. -pub fn parse_name(name: &str) -> Option> { - let cmds: [fn(&str) -> Option>; 4] = [help::parse_cmd, - build::parse_cmd, - serve::parse_cmd, - test::parse_cmd]; - for parser in &cmds { - let parsed = (*parser)(name); - if parsed.is_some() { return parsed } - } - None -} diff --git a/src/tools/rustbook/term.rs b/src/tools/rustbook/term.rs deleted file mode 100644 index cdd25e67c8f..00000000000 --- a/src/tools/rustbook/term.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 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. - -//! An abstraction of the terminal. Eventually, provide color and -//! verbosity support. For now, just a wrapper around stdout/stderr. - -use std::io; -use std::io::prelude::*; -use std::sync::atomic::Ordering; - -pub struct Term { - err: Box -} - -impl Term { - pub fn new() -> Term { - Term { - err: Box::new(io::stderr()) - } - } - - pub fn err(&mut self, msg: &str) { - // swallow any errors - let _ = writeln!(&mut self.err, "{}", msg); - ::EXIT_STATUS.store(101, Ordering::SeqCst); - } -} diff --git a/src/tools/rustbook/test.rs b/src/tools/rustbook/test.rs deleted file mode 100644 index 002c46a7af4..00000000000 --- a/src/tools/rustbook/test.rs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2014 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. - -//! Implementation of the `test` subcommand. Just a stub for now. - -use subcommand::Subcommand; -use error::{err, CliResult, CommandResult}; -use term::Term; -use book; - -use std::fs::File; -use std::env; -use std::process::Command; - -struct Test; - -pub fn parse_cmd(name: &str) -> Option> { - if name == "test" { - Some(Box::new(Test)) - } else { - None - } -} - -impl Subcommand for Test { - fn parse_args(&mut self, _: &[String]) -> CliResult<()> { - Ok(()) - } - fn usage(&self) {} - fn execute(&mut self, term: &mut Term) -> CommandResult<()> { - let cwd = env::current_dir().unwrap(); - let src = cwd.clone(); - - let mut summary = File::open(&src.join("SUMMARY.md"))?; - match book::parse_summary(&mut summary, &src) { - Ok(book) => { - for (_, item) in book.iter() { - let output_result = Command::new("rustdoc") - .arg(&item.path) - .arg("--test") - .output(); - match output_result { - Ok(output) => { - if !output.status.success() { - term.err(&format!("{}\n{}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr))); - return Err(err("some tests failed")); - } - - } - Err(e) => { - let message = format!("could not execute `rustdoc`: {}", e); - return Err(err(&message)) - } - } - } - } - Err(errors) => { - for err in errors { - term.err(&err[..]); - } - return Err(err("there was an error")) - } - } - Ok(()) // lol - } -} From e943e68a47dfbdd73d34f3b40e628f3031f90b6a Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 7 Feb 2017 19:07:28 -0500 Subject: [PATCH 2/8] Port TRPL to mdbook 1. move everything under a src directory 2. add README.md to the SUMMARY.md --- src/doc/book/SUMMARY.md | 70 ------------------ src/doc/book/{ => src}/README.md | 2 +- src/doc/book/src/SUMMARY.md | 71 ++++++++++++++++++- src/doc/book/{ => src}/advanced-linking.md | 2 +- .../book/{ => src}/associated-constants.md | 2 +- src/doc/book/{ => src}/associated-types.md | 2 +- src/doc/book/{ => src}/attributes.md | 2 +- src/doc/book/{ => src}/benchmark-tests.md | 2 +- src/doc/book/{ => src}/bibliography.md | 2 +- src/doc/book/{ => src}/borrow-and-asref.md | 2 +- .../book/{ => src}/box-syntax-and-patterns.md | 2 +- .../book/{ => src}/casting-between-types.md | 8 +-- .../{ => src}/choosing-your-guarantees.md | 2 +- src/doc/book/{ => src}/closures.md | 2 +- src/doc/book/{ => src}/comments.md | 2 +- src/doc/book/{ => src}/compiler-plugins.md | 4 +- src/doc/book/{ => src}/concurrency.md | 2 +- .../book/{ => src}/conditional-compilation.md | 2 +- src/doc/book/{ => src}/const-and-static.md | 2 +- src/doc/book/{ => src}/crates-and-modules.md | 2 +- src/doc/book/{ => src}/custom-allocators.md | 2 +- src/doc/book/{ => src}/deref-coercions.md | 2 +- src/doc/book/{ => src}/documentation.md | 2 +- src/doc/book/{ => src}/drop.md | 2 +- src/doc/book/{ => src}/effective-rust.md | 2 +- src/doc/book/{ => src}/enums.md | 2 +- src/doc/book/{ => src}/error-handling.md | 2 +- src/doc/book/{ => src}/ffi.md | 2 +- src/doc/book/{ => src}/functions.md | 2 +- src/doc/book/{ => src}/generics.md | 2 +- src/doc/book/{ => src}/getting-started.md | 2 +- src/doc/book/{ => src}/glossary.md | 2 +- src/doc/book/{ => src}/guessing-game.md | 2 +- src/doc/book/{ => src}/if-let.md | 2 +- src/doc/book/{ => src}/if.md | 2 +- src/doc/book/{ => src}/inline-assembly.md | 2 +- src/doc/book/{ => src}/intrinsics.md | 2 +- src/doc/book/{ => src}/iterators.md | 2 +- src/doc/book/{ => src}/lang-items.md | 2 +- src/doc/book/{ => src}/lifetimes.md | 2 +- src/doc/book/{ => src}/loops.md | 2 +- src/doc/book/{ => src}/macros.md | 2 +- src/doc/book/{ => src}/match.md | 2 +- src/doc/book/{ => src}/method-syntax.md | 2 +- src/doc/book/{ => src}/mutability.md | 2 +- src/doc/book/{ => src}/nightly-rust.md | 7 +- src/doc/book/{ => src}/no-stdlib.md | 2 +- .../{ => src}/operators-and-overloading.md | 2 +- src/doc/book/{ => src}/ownership.md | 2 +- src/doc/book/{ => src}/patterns.md | 2 +- src/doc/book/{ => src}/primitive-types.md | 2 +- src/doc/book/{ => src}/procedural-macros.md | 2 +- src/doc/book/{ => src}/raw-pointers.md | 2 +- .../{ => src}/references-and-borrowing.md | 2 +- src/doc/book/{ => src}/release-channels.md | 2 +- src/doc/book/{ => src}/slice-patterns.md | 2 +- src/doc/book/{ => src}/strings.md | 2 +- src/doc/book/{ => src}/structs.md | 2 +- .../book/{ => src}/syntax-and-semantics.md | 2 +- src/doc/book/{ => src}/syntax-index.md | 2 +- src/doc/book/{ => src}/testing.md | 2 +- .../book/{ => src}/the-stack-and-the-heap.md | 2 +- src/doc/book/{ => src}/trait-objects.md | 2 +- src/doc/book/{ => src}/traits.md | 2 +- src/doc/book/{ => src}/type-aliases.md | 2 +- src/doc/book/{ => src}/ufcs.md | 2 +- src/doc/book/{ => src}/unsafe.md | 2 +- src/doc/book/{ => src}/unsized-types.md | 2 +- ...using-rust-without-the-standard-library.md | 2 +- src/doc/book/{ => src}/variable-bindings.md | 2 +- src/doc/book/{ => src}/vectors.md | 2 +- 71 files changed, 146 insertions(+), 146 deletions(-) delete mode 100644 src/doc/book/SUMMARY.md rename src/doc/book/{ => src}/README.md (98%) rename src/doc/book/{ => src}/advanced-linking.md (99%) rename src/doc/book/{ => src}/associated-constants.md (98%) rename src/doc/book/{ => src}/associated-types.md (99%) rename src/doc/book/{ => src}/attributes.md (99%) rename src/doc/book/{ => src}/benchmark-tests.md (99%) rename src/doc/book/{ => src}/bibliography.md (99%) rename src/doc/book/{ => src}/borrow-and-asref.md (99%) rename src/doc/book/{ => src}/box-syntax-and-patterns.md (98%) rename src/doc/book/{ => src}/casting-between-types.md (98%) rename src/doc/book/{ => src}/choosing-your-guarantees.md (99%) rename src/doc/book/{ => src}/closures.md (99%) rename src/doc/book/{ => src}/comments.md (99%) rename src/doc/book/{ => src}/compiler-plugins.md (99%) rename src/doc/book/{ => src}/concurrency.md (99%) rename src/doc/book/{ => src}/conditional-compilation.md (98%) rename src/doc/book/{ => src}/const-and-static.md (99%) rename src/doc/book/{ => src}/crates-and-modules.md (99%) rename src/doc/book/{ => src}/custom-allocators.md (99%) rename src/doc/book/{ => src}/deref-coercions.md (99%) rename src/doc/book/{ => src}/documentation.md (99%) rename src/doc/book/{ => src}/drop.md (99%) rename src/doc/book/{ => src}/effective-rust.md (95%) rename src/doc/book/{ => src}/enums.md (99%) rename src/doc/book/{ => src}/error-handling.md (99%) rename src/doc/book/{ => src}/ffi.md (99%) rename src/doc/book/{ => src}/functions.md (99%) rename src/doc/book/{ => src}/generics.md (99%) rename src/doc/book/{ => src}/getting-started.md (99%) rename src/doc/book/{ => src}/glossary.md (99%) rename src/doc/book/{ => src}/guessing-game.md (99%) rename src/doc/book/{ => src}/if-let.md (99%) rename src/doc/book/{ => src}/if.md (99%) rename src/doc/book/{ => src}/inline-assembly.md (99%) rename src/doc/book/{ => src}/intrinsics.md (98%) rename src/doc/book/{ => src}/iterators.md (99%) rename src/doc/book/{ => src}/lang-items.md (99%) rename src/doc/book/{ => src}/lifetimes.md (99%) rename src/doc/book/{ => src}/loops.md (99%) rename src/doc/book/{ => src}/macros.md (99%) rename src/doc/book/{ => src}/match.md (99%) rename src/doc/book/{ => src}/method-syntax.md (99%) rename src/doc/book/{ => src}/mutability.md (99%) rename src/doc/book/{ => src}/nightly-rust.md (95%) rename src/doc/book/{ => src}/no-stdlib.md (99%) rename src/doc/book/{ => src}/operators-and-overloading.md (99%) rename src/doc/book/{ => src}/ownership.md (99%) rename src/doc/book/{ => src}/patterns.md (99%) rename src/doc/book/{ => src}/primitive-types.md (99%) rename src/doc/book/{ => src}/procedural-macros.md (99%) rename src/doc/book/{ => src}/raw-pointers.md (99%) rename src/doc/book/{ => src}/references-and-borrowing.md (99%) rename src/doc/book/{ => src}/release-channels.md (99%) rename src/doc/book/{ => src}/slice-patterns.md (98%) rename src/doc/book/{ => src}/strings.md (99%) rename src/doc/book/{ => src}/structs.md (99%) rename src/doc/book/{ => src}/syntax-and-semantics.md (93%) rename src/doc/book/{ => src}/syntax-index.md (99%) rename src/doc/book/{ => src}/testing.md (99%) rename src/doc/book/{ => src}/the-stack-and-the-heap.md (99%) rename src/doc/book/{ => src}/trait-objects.md (99%) rename src/doc/book/{ => src}/traits.md (99%) rename src/doc/book/{ => src}/type-aliases.md (98%) rename src/doc/book/{ => src}/ufcs.md (98%) rename src/doc/book/{ => src}/unsafe.md (99%) rename src/doc/book/{ => src}/unsized-types.md (99%) rename src/doc/book/{ => src}/using-rust-without-the-standard-library.md (97%) rename src/doc/book/{ => src}/variable-bindings.md (99%) rename src/doc/book/{ => src}/vectors.md (99%) diff --git a/src/doc/book/SUMMARY.md b/src/doc/book/SUMMARY.md deleted file mode 100644 index babbafa078f..00000000000 --- a/src/doc/book/SUMMARY.md +++ /dev/null @@ -1,70 +0,0 @@ -# Summary - -* [Getting Started](getting-started.md) -* [Tutorial: Guessing Game](guessing-game.md) -* [Syntax and Semantics](syntax-and-semantics.md) - * [Variable Bindings](variable-bindings.md) - * [Functions](functions.md) - * [Primitive Types](primitive-types.md) - * [Comments](comments.md) - * [if](if.md) - * [Loops](loops.md) - * [Vectors](vectors.md) - * [Ownership](ownership.md) - * [References and Borrowing](references-and-borrowing.md) - * [Lifetimes](lifetimes.md) - * [Mutability](mutability.md) - * [Structs](structs.md) - * [Enums](enums.md) - * [Match](match.md) - * [Patterns](patterns.md) - * [Method Syntax](method-syntax.md) - * [Strings](strings.md) - * [Generics](generics.md) - * [Traits](traits.md) - * [Drop](drop.md) - * [if let](if-let.md) - * [Trait Objects](trait-objects.md) - * [Closures](closures.md) - * [Universal Function Call Syntax](ufcs.md) - * [Crates and Modules](crates-and-modules.md) - * [`const` and `static`](const-and-static.md) - * [Attributes](attributes.md) - * [`type` aliases](type-aliases.md) - * [Casting between types](casting-between-types.md) - * [Associated Types](associated-types.md) - * [Unsized Types](unsized-types.md) - * [Operators and Overloading](operators-and-overloading.md) - * [Deref coercions](deref-coercions.md) - * [Macros](macros.md) - * [Raw Pointers](raw-pointers.md) - * [`unsafe`](unsafe.md) -* [Effective Rust](effective-rust.md) - * [The Stack and the Heap](the-stack-and-the-heap.md) - * [Testing](testing.md) - * [Conditional Compilation](conditional-compilation.md) - * [Documentation](documentation.md) - * [Iterators](iterators.md) - * [Concurrency](concurrency.md) - * [Error Handling](error-handling.md) - * [Choosing your Guarantees](choosing-your-guarantees.md) - * [FFI](ffi.md) - * [Borrow and AsRef](borrow-and-asref.md) - * [Release Channels](release-channels.md) - * [Using Rust without the standard library](using-rust-without-the-standard-library.md) - * [Procedural Macros (and custom derive)](procedural-macros.md) -* [Nightly Rust](nightly-rust.md) - * [Compiler Plugins](compiler-plugins.md) - * [Inline Assembly](inline-assembly.md) - * [No stdlib](no-stdlib.md) - * [Intrinsics](intrinsics.md) - * [Lang items](lang-items.md) - * [Advanced linking](advanced-linking.md) - * [Benchmark Tests](benchmark-tests.md) - * [Box Syntax and Patterns](box-syntax-and-patterns.md) - * [Slice Patterns](slice-patterns.md) - * [Associated Constants](associated-constants.md) - * [Custom Allocators](custom-allocators.md) -* [Glossary](glossary.md) -* [Syntax Index](syntax-index.md) -* [Bibliography](bibliography.md) diff --git a/src/doc/book/README.md b/src/doc/book/src/README.md similarity index 98% rename from src/doc/book/README.md rename to src/doc/book/src/README.md index 9f9b6a9b043..9162642b1cc 100644 --- a/src/doc/book/README.md +++ b/src/doc/book/src/README.md @@ -1,4 +1,4 @@ -% The Rust Programming Language +# The Rust Programming Language Welcome! This book will teach you about the [Rust Programming Language][rust]. Rust is a systems programming language focused on three goals: safety, speed, diff --git a/src/doc/book/src/SUMMARY.md b/src/doc/book/src/SUMMARY.md index 7390c82896e..74b9b7fa5b2 100644 --- a/src/doc/book/src/SUMMARY.md +++ b/src/doc/book/src/SUMMARY.md @@ -1,3 +1,72 @@ # Summary -- [Chapter 1](./chapter_1.md) +[Introduction](README.md) + +* [Getting Started](getting-started.md) +* [Tutorial: Guessing Game](guessing-game.md) +* [Syntax and Semantics](syntax-and-semantics.md) + * [Variable Bindings](variable-bindings.md) + * [Functions](functions.md) + * [Primitive Types](primitive-types.md) + * [Comments](comments.md) + * [if](if.md) + * [Loops](loops.md) + * [Vectors](vectors.md) + * [Ownership](ownership.md) + * [References and Borrowing](references-and-borrowing.md) + * [Lifetimes](lifetimes.md) + * [Mutability](mutability.md) + * [Structs](structs.md) + * [Enums](enums.md) + * [Match](match.md) + * [Patterns](patterns.md) + * [Method Syntax](method-syntax.md) + * [Strings](strings.md) + * [Generics](generics.md) + * [Traits](traits.md) + * [Drop](drop.md) + * [if let](if-let.md) + * [Trait Objects](trait-objects.md) + * [Closures](closures.md) + * [Universal Function Call Syntax](ufcs.md) + * [Crates and Modules](crates-and-modules.md) + * [`const` and `static`](const-and-static.md) + * [Attributes](attributes.md) + * [`type` aliases](type-aliases.md) + * [Casting between types](casting-between-types.md) + * [Associated Types](associated-types.md) + * [Unsized Types](unsized-types.md) + * [Operators and Overloading](operators-and-overloading.md) + * [Deref coercions](deref-coercions.md) + * [Macros](macros.md) + * [Raw Pointers](raw-pointers.md) + * [`unsafe`](unsafe.md) +* [Effective Rust](effective-rust.md) + * [The Stack and the Heap](the-stack-and-the-heap.md) + * [Testing](testing.md) + * [Conditional Compilation](conditional-compilation.md) + * [Documentation](documentation.md) + * [Iterators](iterators.md) + * [Concurrency](concurrency.md) + * [Error Handling](error-handling.md) + * [Choosing your Guarantees](choosing-your-guarantees.md) + * [FFI](ffi.md) + * [Borrow and AsRef](borrow-and-asref.md) + * [Release Channels](release-channels.md) + * [Using Rust without the standard library](using-rust-without-the-standard-library.md) + * [Procedural Macros (and custom derive)](procedural-macros.md) +* [Nightly Rust](nightly-rust.md) + * [Compiler Plugins](compiler-plugins.md) + * [Inline Assembly](inline-assembly.md) + * [No stdlib](no-stdlib.md) + * [Intrinsics](intrinsics.md) + * [Lang items](lang-items.md) + * [Advanced linking](advanced-linking.md) + * [Benchmark Tests](benchmark-tests.md) + * [Box Syntax and Patterns](box-syntax-and-patterns.md) + * [Slice Patterns](slice-patterns.md) + * [Associated Constants](associated-constants.md) + * [Custom Allocators](custom-allocators.md) +* [Glossary](glossary.md) +* [Syntax Index](syntax-index.md) +* [Bibliography](bibliography.md) diff --git a/src/doc/book/advanced-linking.md b/src/doc/book/src/advanced-linking.md similarity index 99% rename from src/doc/book/advanced-linking.md rename to src/doc/book/src/advanced-linking.md index ddaebaf98d9..a882d6d2ebe 100644 --- a/src/doc/book/advanced-linking.md +++ b/src/doc/book/src/advanced-linking.md @@ -1,4 +1,4 @@ -% Advanced Linking +# Advanced Linking The common cases of linking with Rust have been covered earlier in this book, but supporting the range of linking possibilities made available by other diff --git a/src/doc/book/associated-constants.md b/src/doc/book/src/associated-constants.md similarity index 98% rename from src/doc/book/associated-constants.md rename to src/doc/book/src/associated-constants.md index 81f7ea104e4..61bad3d3948 100644 --- a/src/doc/book/associated-constants.md +++ b/src/doc/book/src/associated-constants.md @@ -1,4 +1,4 @@ -% Associated Constants +# Associated Constants With the `associated_consts` feature, you can define constants like this: diff --git a/src/doc/book/associated-types.md b/src/doc/book/src/associated-types.md similarity index 99% rename from src/doc/book/associated-types.md rename to src/doc/book/src/associated-types.md index f416e600415..4db2b9e5eec 100644 --- a/src/doc/book/associated-types.md +++ b/src/doc/book/src/associated-types.md @@ -1,4 +1,4 @@ -% Associated Types +# Associated Types Associated types are a powerful part of Rust’s type system. They’re related to the idea of a ‘type family’, in other words, grouping multiple types together. That diff --git a/src/doc/book/attributes.md b/src/doc/book/src/attributes.md similarity index 99% rename from src/doc/book/attributes.md rename to src/doc/book/src/attributes.md index 63496471b5a..9e3cdb7ec09 100644 --- a/src/doc/book/attributes.md +++ b/src/doc/book/src/attributes.md @@ -1,4 +1,4 @@ -% Attributes +# Attributes Declarations can be annotated with ‘attributes’ in Rust. They look like this: diff --git a/src/doc/book/benchmark-tests.md b/src/doc/book/src/benchmark-tests.md similarity index 99% rename from src/doc/book/benchmark-tests.md rename to src/doc/book/src/benchmark-tests.md index e054736eb30..a6ae2b3049a 100644 --- a/src/doc/book/benchmark-tests.md +++ b/src/doc/book/src/benchmark-tests.md @@ -1,4 +1,4 @@ -% Benchmark tests +# Benchmark tests Rust supports benchmark tests, which can test the performance of your code. Let's make our `src/lib.rs` look like this (comments elided): diff --git a/src/doc/book/bibliography.md b/src/doc/book/src/bibliography.md similarity index 99% rename from src/doc/book/bibliography.md rename to src/doc/book/src/bibliography.md index 6f6f51d1f60..07b2aa94a77 100644 --- a/src/doc/book/bibliography.md +++ b/src/doc/book/src/bibliography.md @@ -1,4 +1,4 @@ -% Bibliography +# Bibliography This is a reading list of material relevant to Rust. It includes prior research that has - at one time or another - influenced the design of diff --git a/src/doc/book/borrow-and-asref.md b/src/doc/book/src/borrow-and-asref.md similarity index 99% rename from src/doc/book/borrow-and-asref.md rename to src/doc/book/src/borrow-and-asref.md index c30b2e68665..a6e396571c6 100644 --- a/src/doc/book/borrow-and-asref.md +++ b/src/doc/book/src/borrow-and-asref.md @@ -1,4 +1,4 @@ -% Borrow and AsRef +# Borrow and AsRef The [`Borrow`][borrow] and [`AsRef`][asref] traits are very similar, but different. Here’s a quick refresher on what these two traits mean. diff --git a/src/doc/book/box-syntax-and-patterns.md b/src/doc/book/src/box-syntax-and-patterns.md similarity index 98% rename from src/doc/book/box-syntax-and-patterns.md rename to src/doc/book/src/box-syntax-and-patterns.md index cbf65dfa9ba..f03e881f474 100644 --- a/src/doc/book/box-syntax-and-patterns.md +++ b/src/doc/book/src/box-syntax-and-patterns.md @@ -1,4 +1,4 @@ -% Box Syntax and Patterns +# Box Syntax and Patterns Currently the only stable way to create a `Box` is via the `Box::new` method. Also it is not possible in stable Rust to destructure a `Box` in a match diff --git a/src/doc/book/casting-between-types.md b/src/doc/book/src/casting-between-types.md similarity index 98% rename from src/doc/book/casting-between-types.md rename to src/doc/book/src/casting-between-types.md index a8f8224c58b..853fb1ec254 100644 --- a/src/doc/book/casting-between-types.md +++ b/src/doc/book/src/casting-between-types.md @@ -1,4 +1,4 @@ -% Casting Between Types +# Casting Between Types Rust, with its focus on safety, provides two different ways of casting different types between each other. The first, `as`, is for safe casts. @@ -19,7 +19,7 @@ The most common case of coercion is removing mutability from a reference: * `&mut T` to `&T` An analogous conversion is to remove mutability from a -[raw pointer](raw-pointers.md): +[raw pointer](raw-pointers.html): * `*mut T` to `*const T` @@ -29,7 +29,7 @@ References can also be coerced to raw pointers: * `&mut T` to `*mut T` -Custom coercions may be defined using [`Deref`](deref-coercions.md). +Custom coercions may be defined using [`Deref`](deref-coercions.html). Coercion is transitive. @@ -101,7 +101,7 @@ The semantics of numeric casts are: ## Pointer casts -Perhaps surprisingly, it is safe to cast [raw pointers](raw-pointers.md) to and +Perhaps surprisingly, it is safe to cast [raw pointers](raw-pointers.html) to and from integers, and to cast between pointers to different types subject to some constraints. It is only unsafe to dereference the pointer: diff --git a/src/doc/book/choosing-your-guarantees.md b/src/doc/book/src/choosing-your-guarantees.md similarity index 99% rename from src/doc/book/choosing-your-guarantees.md rename to src/doc/book/src/choosing-your-guarantees.md index 17741cac10b..89dd09e6704 100644 --- a/src/doc/book/choosing-your-guarantees.md +++ b/src/doc/book/src/choosing-your-guarantees.md @@ -1,4 +1,4 @@ -% Choosing your Guarantees +# Choosing your Guarantees One important feature of Rust is that it lets us control the costs and guarantees of a program. diff --git a/src/doc/book/closures.md b/src/doc/book/src/closures.md similarity index 99% rename from src/doc/book/closures.md rename to src/doc/book/src/closures.md index 115fe1f7662..5426ed0ff4c 100644 --- a/src/doc/book/closures.md +++ b/src/doc/book/src/closures.md @@ -1,4 +1,4 @@ -% Closures +# Closures Sometimes it is useful to wrap up a function and _free variables_ for better clarity and reuse. The free variables that can be used come from the diff --git a/src/doc/book/comments.md b/src/doc/book/src/comments.md similarity index 99% rename from src/doc/book/comments.md rename to src/doc/book/src/comments.md index 8fa397cd9a6..0e68ab218e8 100644 --- a/src/doc/book/comments.md +++ b/src/doc/book/src/comments.md @@ -1,4 +1,4 @@ -% Comments +# Comments Now that we have some functions, it’s a good idea to learn about comments. Comments are notes that you leave to other programmers to help explain things diff --git a/src/doc/book/compiler-plugins.md b/src/doc/book/src/compiler-plugins.md similarity index 99% rename from src/doc/book/compiler-plugins.md rename to src/doc/book/src/compiler-plugins.md index ff29358df94..1b7ce678982 100644 --- a/src/doc/book/compiler-plugins.md +++ b/src/doc/book/src/compiler-plugins.md @@ -1,6 +1,6 @@ -% Compiler Plugins +# Compiler Plugins -# Introduction +## Introduction `rustc` can load compiler plugins, which are user-provided libraries that extend the compiler's behavior with new syntax extensions, lint checks, etc. diff --git a/src/doc/book/concurrency.md b/src/doc/book/src/concurrency.md similarity index 99% rename from src/doc/book/concurrency.md rename to src/doc/book/src/concurrency.md index 67d89d5484c..a64178c26f2 100644 --- a/src/doc/book/concurrency.md +++ b/src/doc/book/src/concurrency.md @@ -1,4 +1,4 @@ -% Concurrency +# Concurrency Concurrency and parallelism are incredibly important topics in computer science, and are also a hot topic in industry today. Computers are gaining more diff --git a/src/doc/book/conditional-compilation.md b/src/doc/book/src/conditional-compilation.md similarity index 98% rename from src/doc/book/conditional-compilation.md rename to src/doc/book/src/conditional-compilation.md index 78ab3c18e45..938c1c51326 100644 --- a/src/doc/book/conditional-compilation.md +++ b/src/doc/book/src/conditional-compilation.md @@ -1,4 +1,4 @@ -% Conditional Compilation +# Conditional Compilation Rust has a special attribute, `#[cfg]`, which allows you to compile code based on a flag passed to the compiler. It has two forms: diff --git a/src/doc/book/const-and-static.md b/src/doc/book/src/const-and-static.md similarity index 99% rename from src/doc/book/const-and-static.md rename to src/doc/book/src/const-and-static.md index e8f17a41cbe..25b4bd94799 100644 --- a/src/doc/book/const-and-static.md +++ b/src/doc/book/src/const-and-static.md @@ -1,4 +1,4 @@ -% const and static +# const and static Rust has a way of defining constants with the `const` keyword: diff --git a/src/doc/book/crates-and-modules.md b/src/doc/book/src/crates-and-modules.md similarity index 99% rename from src/doc/book/crates-and-modules.md rename to src/doc/book/src/crates-and-modules.md index 0e336635235..84f5fac044e 100644 --- a/src/doc/book/crates-and-modules.md +++ b/src/doc/book/src/crates-and-modules.md @@ -1,4 +1,4 @@ -% Crates and Modules +# Crates and Modules When a project starts getting large, it’s considered good software engineering practice to split it up into a bunch of smaller pieces, and then diff --git a/src/doc/book/custom-allocators.md b/src/doc/book/src/custom-allocators.md similarity index 99% rename from src/doc/book/custom-allocators.md rename to src/doc/book/src/custom-allocators.md index 1996305f09e..154b5f0f4e2 100644 --- a/src/doc/book/custom-allocators.md +++ b/src/doc/book/src/custom-allocators.md @@ -1,4 +1,4 @@ -% Custom Allocators +# Custom Allocators Allocating memory isn't always the easiest thing to do, and while Rust generally takes care of this by default it often becomes necessary to customize how diff --git a/src/doc/book/deref-coercions.md b/src/doc/book/src/deref-coercions.md similarity index 99% rename from src/doc/book/deref-coercions.md rename to src/doc/book/src/deref-coercions.md index 864cd282d93..8552a7c8b34 100644 --- a/src/doc/book/deref-coercions.md +++ b/src/doc/book/src/deref-coercions.md @@ -1,4 +1,4 @@ -% `Deref` coercions +# `Deref` coercions The standard library provides a special trait, [`Deref`][deref]. It’s normally used to overload `*`, the dereference operator: diff --git a/src/doc/book/documentation.md b/src/doc/book/src/documentation.md similarity index 99% rename from src/doc/book/documentation.md rename to src/doc/book/src/documentation.md index d2402ddb2e9..69d49e2f96a 100644 --- a/src/doc/book/documentation.md +++ b/src/doc/book/src/documentation.md @@ -1,4 +1,4 @@ -% Documentation +# Documentation Documentation is an important part of any software project, and it's first-class in Rust. Let's talk about the tooling Rust gives you to diff --git a/src/doc/book/drop.md b/src/doc/book/src/drop.md similarity index 99% rename from src/doc/book/drop.md rename to src/doc/book/src/drop.md index 0b7ddcfbe88..53c507eba3f 100644 --- a/src/doc/book/drop.md +++ b/src/doc/book/src/drop.md @@ -1,4 +1,4 @@ -% Drop +# Drop Now that we’ve discussed traits, let’s talk about a particular trait provided by the Rust standard library, [`Drop`][drop]. The `Drop` trait provides a way diff --git a/src/doc/book/effective-rust.md b/src/doc/book/src/effective-rust.md similarity index 95% rename from src/doc/book/effective-rust.md rename to src/doc/book/src/effective-rust.md index 65873c80e55..ce2dfe4eae2 100644 --- a/src/doc/book/effective-rust.md +++ b/src/doc/book/src/effective-rust.md @@ -1,4 +1,4 @@ -% Effective Rust +# Effective Rust So you’ve learned how to write some Rust code. But there’s a difference between writing *any* Rust code and writing *good* Rust code. diff --git a/src/doc/book/enums.md b/src/doc/book/src/enums.md similarity index 99% rename from src/doc/book/enums.md rename to src/doc/book/src/enums.md index 790d6ff8546..9cf5e6bfa21 100644 --- a/src/doc/book/enums.md +++ b/src/doc/book/src/enums.md @@ -1,4 +1,4 @@ -% Enums +# Enums An `enum` in Rust is a type that represents data that is one of several possible variants. Each variant in the `enum` can optionally diff --git a/src/doc/book/error-handling.md b/src/doc/book/src/error-handling.md similarity index 99% rename from src/doc/book/error-handling.md rename to src/doc/book/src/error-handling.md index 0d9f49d66cb..c823c32a135 100644 --- a/src/doc/book/error-handling.md +++ b/src/doc/book/src/error-handling.md @@ -1,4 +1,4 @@ -% Error Handling +# Error Handling Like most programming languages, Rust encourages the programmer to handle errors in a particular way. Generally speaking, error handling is divided into diff --git a/src/doc/book/ffi.md b/src/doc/book/src/ffi.md similarity index 99% rename from src/doc/book/ffi.md rename to src/doc/book/src/ffi.md index 8d29f11aa05..cccefd8dfe7 100644 --- a/src/doc/book/ffi.md +++ b/src/doc/book/src/ffi.md @@ -1,4 +1,4 @@ -% Foreign Function Interface +# Foreign Function Interface # Introduction diff --git a/src/doc/book/functions.md b/src/doc/book/src/functions.md similarity index 99% rename from src/doc/book/functions.md rename to src/doc/book/src/functions.md index b453936fe00..eff77a54d83 100644 --- a/src/doc/book/functions.md +++ b/src/doc/book/src/functions.md @@ -1,4 +1,4 @@ -% Functions +# Functions Every Rust program has at least one function, the `main` function: diff --git a/src/doc/book/generics.md b/src/doc/book/src/generics.md similarity index 99% rename from src/doc/book/generics.md rename to src/doc/book/src/generics.md index eafad6a05fc..56655ac41d0 100644 --- a/src/doc/book/generics.md +++ b/src/doc/book/src/generics.md @@ -1,4 +1,4 @@ -% Generics +# Generics Sometimes, when writing a function or data type, we may want it to work for multiple types of arguments. In Rust, we can do this with generics. diff --git a/src/doc/book/getting-started.md b/src/doc/book/src/getting-started.md similarity index 99% rename from src/doc/book/getting-started.md rename to src/doc/book/src/getting-started.md index 5aae693ad6b..6208b1f4c12 100644 --- a/src/doc/book/getting-started.md +++ b/src/doc/book/src/getting-started.md @@ -1,4 +1,4 @@ -% Getting Started +# Getting Started This first chapter of the book will get us going with Rust and its tooling. First, we’ll install Rust. Then, the classic ‘Hello World’ program. Finally, diff --git a/src/doc/book/glossary.md b/src/doc/book/src/glossary.md similarity index 99% rename from src/doc/book/glossary.md rename to src/doc/book/src/glossary.md index 8aa7fdff948..b17b89633f3 100644 --- a/src/doc/book/glossary.md +++ b/src/doc/book/src/glossary.md @@ -1,4 +1,4 @@ -% Glossary +# Glossary Not every Rustacean has a background in systems programming, nor in computer science, so we've added explanations of terms that might be unfamiliar. diff --git a/src/doc/book/guessing-game.md b/src/doc/book/src/guessing-game.md similarity index 99% rename from src/doc/book/guessing-game.md rename to src/doc/book/src/guessing-game.md index c854b7c373d..7368d2184e5 100644 --- a/src/doc/book/guessing-game.md +++ b/src/doc/book/src/guessing-game.md @@ -1,4 +1,4 @@ -% Guessing Game +# Guessing Game Let’s learn some Rust! For our first project, we’ll implement a classic beginner programming problem: the guessing game. Here’s how it works: Our diff --git a/src/doc/book/if-let.md b/src/doc/book/src/if-let.md similarity index 99% rename from src/doc/book/if-let.md rename to src/doc/book/src/if-let.md index e76149ad270..17bf1369000 100644 --- a/src/doc/book/if-let.md +++ b/src/doc/book/src/if-let.md @@ -1,4 +1,4 @@ -% if let +# if let `if let` permits [patterns][pattern] matching within the condition of an [if][if] statement. This allows us to reduce the overhead of certain kinds of [pattern][patterns] matches diff --git a/src/doc/book/if.md b/src/doc/book/src/if.md similarity index 99% rename from src/doc/book/if.md rename to src/doc/book/src/if.md index 52d0dd888ef..d74503757bc 100644 --- a/src/doc/book/if.md +++ b/src/doc/book/src/if.md @@ -1,4 +1,4 @@ -% if +# if Rust’s take on `if` is not particularly complex, but it’s much more like the `if` you’ll find in a dynamically typed language than in a more traditional diff --git a/src/doc/book/inline-assembly.md b/src/doc/book/src/inline-assembly.md similarity index 99% rename from src/doc/book/inline-assembly.md rename to src/doc/book/src/inline-assembly.md index e531d5d7fc0..4262289acbf 100644 --- a/src/doc/book/inline-assembly.md +++ b/src/doc/book/src/inline-assembly.md @@ -1,4 +1,4 @@ -% Inline Assembly +# Inline Assembly For extremely low-level manipulations and performance reasons, one might wish to control the CPU directly. Rust supports using inline diff --git a/src/doc/book/intrinsics.md b/src/doc/book/src/intrinsics.md similarity index 98% rename from src/doc/book/intrinsics.md rename to src/doc/book/src/intrinsics.md index d1d836fe188..e1edce3e80f 100644 --- a/src/doc/book/intrinsics.md +++ b/src/doc/book/src/intrinsics.md @@ -1,4 +1,4 @@ -% Intrinsics +# Intrinsics > **Note**: intrinsics will forever have an unstable interface, it is > recommended to use the stable interfaces of libcore rather than intrinsics diff --git a/src/doc/book/iterators.md b/src/doc/book/src/iterators.md similarity index 99% rename from src/doc/book/iterators.md rename to src/doc/book/src/iterators.md index c174d2d6bac..1437c0f0b54 100644 --- a/src/doc/book/iterators.md +++ b/src/doc/book/src/iterators.md @@ -1,4 +1,4 @@ -% Iterators +# Iterators Let's talk about loops. diff --git a/src/doc/book/lang-items.md b/src/doc/book/src/lang-items.md similarity index 99% rename from src/doc/book/lang-items.md rename to src/doc/book/src/lang-items.md index 0d6a142ca4f..9bd64d38179 100644 --- a/src/doc/book/lang-items.md +++ b/src/doc/book/src/lang-items.md @@ -1,4 +1,4 @@ -% Lang items +# Lang items > **Note**: lang items are often provided by crates in the Rust distribution, > and lang items themselves have an unstable interface. It is recommended to use diff --git a/src/doc/book/lifetimes.md b/src/doc/book/src/lifetimes.md similarity index 99% rename from src/doc/book/lifetimes.md rename to src/doc/book/src/lifetimes.md index 2bf2beb8b74..8bca13c28f0 100644 --- a/src/doc/book/lifetimes.md +++ b/src/doc/book/src/lifetimes.md @@ -1,4 +1,4 @@ -% Lifetimes +# Lifetimes This is the last of three sections presenting Rust’s ownership system. This is one of Rust’s most distinct and compelling features, with which Rust developers should diff --git a/src/doc/book/loops.md b/src/doc/book/src/loops.md similarity index 99% rename from src/doc/book/loops.md rename to src/doc/book/src/loops.md index 688e8c55265..ec4acfa3112 100644 --- a/src/doc/book/loops.md +++ b/src/doc/book/src/loops.md @@ -1,4 +1,4 @@ -% Loops +# Loops Rust currently provides three approaches to performing some kind of iterative activity. They are: `loop`, `while` and `for`. Each approach has its own set of uses. diff --git a/src/doc/book/macros.md b/src/doc/book/src/macros.md similarity index 99% rename from src/doc/book/macros.md rename to src/doc/book/src/macros.md index 7f52b33948e..22d53779bb9 100644 --- a/src/doc/book/macros.md +++ b/src/doc/book/src/macros.md @@ -1,4 +1,4 @@ -% Macros +# Macros By now you’ve learned about many of the tools Rust provides for abstracting and reusing code. These units of code reuse have a rich semantic structure. For diff --git a/src/doc/book/match.md b/src/doc/book/src/match.md similarity index 99% rename from src/doc/book/match.md rename to src/doc/book/src/match.md index 52d3c6ae926..b1e26a9c9d3 100644 --- a/src/doc/book/match.md +++ b/src/doc/book/src/match.md @@ -1,4 +1,4 @@ -% Match +# Match Often, a simple [`if`][if]/`else` isn’t enough, because you have more than two possible options. Also, conditions can get quite complex. Rust diff --git a/src/doc/book/method-syntax.md b/src/doc/book/src/method-syntax.md similarity index 99% rename from src/doc/book/method-syntax.md rename to src/doc/book/src/method-syntax.md index b2532663339..0404a5c992b 100644 --- a/src/doc/book/method-syntax.md +++ b/src/doc/book/src/method-syntax.md @@ -1,4 +1,4 @@ -% Method Syntax +# Method Syntax Functions are great, but if you want to call a bunch of them on some data, it can be awkward. Consider this code: diff --git a/src/doc/book/mutability.md b/src/doc/book/src/mutability.md similarity index 99% rename from src/doc/book/mutability.md rename to src/doc/book/src/mutability.md index 18017cc4a5e..fa7a259392a 100644 --- a/src/doc/book/mutability.md +++ b/src/doc/book/src/mutability.md @@ -1,4 +1,4 @@ -% Mutability +# Mutability Mutability, the ability to change something, works a bit differently in Rust than in other languages. The first aspect of mutability is its non-default diff --git a/src/doc/book/nightly-rust.md b/src/doc/book/src/nightly-rust.md similarity index 95% rename from src/doc/book/nightly-rust.md rename to src/doc/book/src/nightly-rust.md index f55bb078420..5dfaa9e0fa8 100644 --- a/src/doc/book/nightly-rust.md +++ b/src/doc/book/src/nightly-rust.md @@ -1,8 +1,8 @@ -% Nightly Rust +# Nightly Rust Rust provides three distribution channels for Rust: nightly, beta, and stable. Unstable features are only available on nightly Rust. For more details on this -process, see ‘[Stability as a deliverable][stability]’. +process, see [Stability as a deliverable][stability]. [stability]: http://blog.rust-lang.org/2014/10/30/Stability.html @@ -91,9 +91,10 @@ If not, there are a number of places where you can get help. The easiest is [the #rust IRC channel on irc.mozilla.org][irc], which you can access through [Mibbit][mibbit]. Click that link, and you'll be chatting with other Rustaceans (a silly nickname we call ourselves), and we can help you out. Other great -resources include [the user’s forum][users], and [Stack Overflow][stackoverflow]. +resources include [the users forum][users], and [Stack Overflow][stackoverflow]. [irc]: irc://irc.mozilla.org/#rust [mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust [users]: https://users.rust-lang.org/ [stackoverflow]: http://stackoverflow.com/questions/tagged/rust + diff --git a/src/doc/book/no-stdlib.md b/src/doc/book/src/no-stdlib.md similarity index 99% rename from src/doc/book/no-stdlib.md rename to src/doc/book/src/no-stdlib.md index 79f0593be17..dcb0fbc8005 100644 --- a/src/doc/book/no-stdlib.md +++ b/src/doc/book/src/no-stdlib.md @@ -1,4 +1,4 @@ -% No stdlib +# No stdlib Rust’s standard library provides a lot of useful functionality, but assumes support for various features of its host system: threads, networking, heap diff --git a/src/doc/book/operators-and-overloading.md b/src/doc/book/src/operators-and-overloading.md similarity index 99% rename from src/doc/book/operators-and-overloading.md rename to src/doc/book/src/operators-and-overloading.md index 78ff871046e..a69cd6adb3b 100644 --- a/src/doc/book/operators-and-overloading.md +++ b/src/doc/book/src/operators-and-overloading.md @@ -1,4 +1,4 @@ -% Operators and Overloading +# Operators and Overloading Rust allows for a limited form of operator overloading. There are certain operators that are able to be overloaded. To support a particular operator diff --git a/src/doc/book/ownership.md b/src/doc/book/src/ownership.md similarity index 99% rename from src/doc/book/ownership.md rename to src/doc/book/src/ownership.md index 11eda399adc..21ebd6333f7 100644 --- a/src/doc/book/ownership.md +++ b/src/doc/book/src/ownership.md @@ -1,4 +1,4 @@ -% Ownership +# Ownership This is the first of three sections presenting Rust’s ownership system. This is one of Rust’s most distinct and compelling features, with which Rust developers should diff --git a/src/doc/book/patterns.md b/src/doc/book/src/patterns.md similarity index 99% rename from src/doc/book/patterns.md rename to src/doc/book/src/patterns.md index 24f71608a5b..1983927085c 100644 --- a/src/doc/book/patterns.md +++ b/src/doc/book/src/patterns.md @@ -1,4 +1,4 @@ -% Patterns +# Patterns Patterns are quite common in Rust. We use them in [variable bindings][bindings], [match expressions][match], and other places, too. Let’s go diff --git a/src/doc/book/primitive-types.md b/src/doc/book/src/primitive-types.md similarity index 99% rename from src/doc/book/primitive-types.md rename to src/doc/book/src/primitive-types.md index c4169d64ccc..8fd3d17c15e 100644 --- a/src/doc/book/primitive-types.md +++ b/src/doc/book/src/primitive-types.md @@ -1,4 +1,4 @@ -% Primitive Types +# Primitive Types The Rust language has a number of types that are considered ‘primitive’. This means that they’re built-in to the language. Rust is structured in such a way diff --git a/src/doc/book/procedural-macros.md b/src/doc/book/src/procedural-macros.md similarity index 99% rename from src/doc/book/procedural-macros.md rename to src/doc/book/src/procedural-macros.md index 37d3d20c06d..d286c3b7bdc 100644 --- a/src/doc/book/procedural-macros.md +++ b/src/doc/book/src/procedural-macros.md @@ -1,4 +1,4 @@ -% Procedural Macros (and custom Derive) +# Procedural Macros (and custom Derive) As you've seen throughout the rest of the book, Rust provides a mechanism called "derive" that lets you implement traits easily. For example, diff --git a/src/doc/book/raw-pointers.md b/src/doc/book/src/raw-pointers.md similarity index 99% rename from src/doc/book/raw-pointers.md rename to src/doc/book/src/raw-pointers.md index 2386475d15e..1f75665f4b8 100644 --- a/src/doc/book/raw-pointers.md +++ b/src/doc/book/src/raw-pointers.md @@ -1,4 +1,4 @@ -% Raw Pointers +# Raw Pointers Rust has a number of different smart pointer types in its standard library, but there are two types that are extra-special. Much of Rust’s safety comes from diff --git a/src/doc/book/references-and-borrowing.md b/src/doc/book/src/references-and-borrowing.md similarity index 99% rename from src/doc/book/references-and-borrowing.md rename to src/doc/book/src/references-and-borrowing.md index 6c9c4fa7dd4..f01aa45385a 100644 --- a/src/doc/book/references-and-borrowing.md +++ b/src/doc/book/src/references-and-borrowing.md @@ -1,4 +1,4 @@ -% References and Borrowing +# References and Borrowing This is the second of three sections presenting Rust’s ownership system. This is one of Rust’s most distinct and compelling features, with which Rust developers should diff --git a/src/doc/book/release-channels.md b/src/doc/book/src/release-channels.md similarity index 99% rename from src/doc/book/release-channels.md rename to src/doc/book/src/release-channels.md index 1e203c6553e..af89ca83484 100644 --- a/src/doc/book/release-channels.md +++ b/src/doc/book/src/release-channels.md @@ -1,4 +1,4 @@ -% Release Channels +# Release Channels The Rust project uses a concept called ‘release channels’ to manage releases. It’s important to understand this process to choose which version of Rust diff --git a/src/doc/book/slice-patterns.md b/src/doc/book/src/slice-patterns.md similarity index 98% rename from src/doc/book/slice-patterns.md rename to src/doc/book/src/slice-patterns.md index fcedf0c994f..3f7398dde5e 100644 --- a/src/doc/book/slice-patterns.md +++ b/src/doc/book/src/slice-patterns.md @@ -1,4 +1,4 @@ -% Slice patterns +# Slice patterns If you want to match against a slice or array, you can use `&` with the `slice_patterns` feature: diff --git a/src/doc/book/strings.md b/src/doc/book/src/strings.md similarity index 99% rename from src/doc/book/strings.md rename to src/doc/book/src/strings.md index a2146b669e3..ac41be11854 100644 --- a/src/doc/book/strings.md +++ b/src/doc/book/src/strings.md @@ -1,4 +1,4 @@ -% Strings +# Strings Strings are an important concept for any programmer to master. Rust’s string handling system is a bit different from other languages, due to its systems diff --git a/src/doc/book/structs.md b/src/doc/book/src/structs.md similarity index 99% rename from src/doc/book/structs.md rename to src/doc/book/src/structs.md index f10fb6274c6..51af343c130 100644 --- a/src/doc/book/structs.md +++ b/src/doc/book/src/structs.md @@ -1,4 +1,4 @@ -% Structs +# Structs `struct`s are a way of creating more complex data types. For example, if we were doing calculations involving coordinates in 2D space, we would need both an `x` diff --git a/src/doc/book/syntax-and-semantics.md b/src/doc/book/src/syntax-and-semantics.md similarity index 93% rename from src/doc/book/syntax-and-semantics.md rename to src/doc/book/src/syntax-and-semantics.md index e9ec26dccdc..aa4c1251024 100644 --- a/src/doc/book/syntax-and-semantics.md +++ b/src/doc/book/src/syntax-and-semantics.md @@ -1,4 +1,4 @@ -% Syntax and Semantics +# Syntax and Semantics This chapter breaks Rust down into small chunks, one for each concept. diff --git a/src/doc/book/syntax-index.md b/src/doc/book/src/syntax-index.md similarity index 99% rename from src/doc/book/syntax-index.md rename to src/doc/book/src/syntax-index.md index 5fa78001fad..d8bb4fadc0b 100644 --- a/src/doc/book/syntax-index.md +++ b/src/doc/book/src/syntax-index.md @@ -1,4 +1,4 @@ -% Syntax Index +# Syntax Index ## Keywords diff --git a/src/doc/book/testing.md b/src/doc/book/src/testing.md similarity index 99% rename from src/doc/book/testing.md rename to src/doc/book/src/testing.md index ef19c0dc7cc..291c4481d55 100644 --- a/src/doc/book/testing.md +++ b/src/doc/book/src/testing.md @@ -1,4 +1,4 @@ -% Testing +# Testing > Program testing can be a very effective way to show the presence of bugs, but > it is hopelessly inadequate for showing their absence. diff --git a/src/doc/book/the-stack-and-the-heap.md b/src/doc/book/src/the-stack-and-the-heap.md similarity index 99% rename from src/doc/book/the-stack-and-the-heap.md rename to src/doc/book/src/the-stack-and-the-heap.md index aee45299cf2..b9b3b801eae 100644 --- a/src/doc/book/the-stack-and-the-heap.md +++ b/src/doc/book/src/the-stack-and-the-heap.md @@ -1,4 +1,4 @@ -% The Stack and the Heap +# The Stack and the Heap As a systems language, Rust operates at a low level. If you’re coming from a high-level language, there are some aspects of systems programming that you may diff --git a/src/doc/book/trait-objects.md b/src/doc/book/src/trait-objects.md similarity index 99% rename from src/doc/book/trait-objects.md rename to src/doc/book/src/trait-objects.md index 00a841a75db..a77d5fe93b5 100644 --- a/src/doc/book/trait-objects.md +++ b/src/doc/book/src/trait-objects.md @@ -1,4 +1,4 @@ -% Trait Objects +# Trait Objects When code involves polymorphism, there needs to be a mechanism to determine which specific version is actually run. This is called ‘dispatch’. There are diff --git a/src/doc/book/traits.md b/src/doc/book/src/traits.md similarity index 99% rename from src/doc/book/traits.md rename to src/doc/book/src/traits.md index 4747869b65c..19a133f84b0 100644 --- a/src/doc/book/traits.md +++ b/src/doc/book/src/traits.md @@ -1,4 +1,4 @@ -% Traits +# Traits A trait is a language feature that tells the Rust compiler about functionality a type must provide. diff --git a/src/doc/book/type-aliases.md b/src/doc/book/src/type-aliases.md similarity index 98% rename from src/doc/book/type-aliases.md rename to src/doc/book/src/type-aliases.md index 3798336f0a5..1bd0f78e368 100644 --- a/src/doc/book/type-aliases.md +++ b/src/doc/book/src/type-aliases.md @@ -1,4 +1,4 @@ -% Type Aliases +# Type Aliases The `type` keyword lets you declare an alias of another type: diff --git a/src/doc/book/ufcs.md b/src/doc/book/src/ufcs.md similarity index 98% rename from src/doc/book/ufcs.md rename to src/doc/book/src/ufcs.md index 7725970564b..016ecc70976 100644 --- a/src/doc/book/ufcs.md +++ b/src/doc/book/src/ufcs.md @@ -1,4 +1,4 @@ -% Universal Function Call Syntax +# Universal Function Call Syntax Sometimes, functions can have the same names. Consider this code: diff --git a/src/doc/book/unsafe.md b/src/doc/book/src/unsafe.md similarity index 99% rename from src/doc/book/unsafe.md rename to src/doc/book/src/unsafe.md index a272afa70bb..e90a4b1c268 100644 --- a/src/doc/book/unsafe.md +++ b/src/doc/book/src/unsafe.md @@ -1,4 +1,4 @@ -% Unsafe +# Unsafe Rust’s main draw is its powerful static guarantees about behavior. But safety checks are conservative by nature: there are some programs that are actually diff --git a/src/doc/book/unsized-types.md b/src/doc/book/src/unsized-types.md similarity index 99% rename from src/doc/book/unsized-types.md rename to src/doc/book/src/unsized-types.md index a23470d39fa..2d090925d51 100644 --- a/src/doc/book/unsized-types.md +++ b/src/doc/book/src/unsized-types.md @@ -1,4 +1,4 @@ -% Unsized Types +# Unsized Types Most types have a particular size, in bytes, that is knowable at compile time. For example, an `i32` is thirty-two bits big, or four bytes. However, there are diff --git a/src/doc/book/using-rust-without-the-standard-library.md b/src/doc/book/src/using-rust-without-the-standard-library.md similarity index 97% rename from src/doc/book/using-rust-without-the-standard-library.md rename to src/doc/book/src/using-rust-without-the-standard-library.md index e66e1d05fff..8458f9314f9 100644 --- a/src/doc/book/using-rust-without-the-standard-library.md +++ b/src/doc/book/src/using-rust-without-the-standard-library.md @@ -1,4 +1,4 @@ -% Using Rust Without the Standard Library +# Using Rust Without the Standard Library Rust’s standard library provides a lot of useful functionality, but assumes support for various features of its host system: threads, networking, heap diff --git a/src/doc/book/variable-bindings.md b/src/doc/book/src/variable-bindings.md similarity index 99% rename from src/doc/book/variable-bindings.md rename to src/doc/book/src/variable-bindings.md index e1947310a9a..0c8324d83e0 100644 --- a/src/doc/book/variable-bindings.md +++ b/src/doc/book/src/variable-bindings.md @@ -1,4 +1,4 @@ -% Variable Bindings +# Variable Bindings Virtually every non-'Hello World’ Rust program uses *variable bindings*. They bind some value to a name, so it can be used later. `let` is diff --git a/src/doc/book/vectors.md b/src/doc/book/src/vectors.md similarity index 99% rename from src/doc/book/vectors.md rename to src/doc/book/src/vectors.md index b948a54f44a..aff078718df 100644 --- a/src/doc/book/vectors.md +++ b/src/doc/book/src/vectors.md @@ -1,4 +1,4 @@ -% Vectors +# Vectors A ‘vector’ is a dynamic or ‘growable’ array, implemented as the standard library type [`Vec`][vec]. The `T` means that we can have vectors From 22d4adf14aabfb0ea0cfc8daff203e8d474cbc52 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 7 Feb 2017 19:08:12 -0500 Subject: [PATCH 3/8] Port Nomicon to mdbook 1. move everything under a src directory 2. add README.md to the SUMMARY.md --- src/doc/nomicon/SUMMARY.md | 53 ------------------ src/doc/nomicon/{ => src}/README.md | 2 +- src/doc/nomicon/src/SUMMARY.md | 54 ++++++++++++++++++- src/doc/nomicon/{ => src}/arc-and-mutex.md | 2 +- src/doc/nomicon/{ => src}/atomics.md | 2 +- src/doc/nomicon/{ => src}/borrow-splitting.md | 2 +- src/doc/nomicon/{ => src}/casts.md | 2 +- src/doc/nomicon/{ => src}/checked-uninit.md | 2 +- src/doc/nomicon/{ => src}/coercions.md | 2 +- src/doc/nomicon/{ => src}/concurrency.md | 2 +- src/doc/nomicon/{ => src}/constructors.md | 2 +- src/doc/nomicon/{ => src}/conversions.md | 2 +- src/doc/nomicon/{ => src}/data.md | 2 +- src/doc/nomicon/{ => src}/destructors.md | 2 +- src/doc/nomicon/{ => src}/dot-operator.md | 2 +- src/doc/nomicon/{ => src}/drop-flags.md | 2 +- src/doc/nomicon/{ => src}/dropck.md | 2 +- src/doc/nomicon/{ => src}/exception-safety.md | 2 +- src/doc/nomicon/{ => src}/exotic-sizes.md | 2 +- src/doc/nomicon/{ => src}/hrtb.md | 2 +- src/doc/nomicon/{ => src}/leaking.md | 2 +- src/doc/nomicon/{ => src}/lifetime-elision.md | 2 +- .../nomicon/{ => src}/lifetime-mismatch.md | 2 +- src/doc/nomicon/{ => src}/lifetimes.md | 2 +- .../nomicon/{ => src}/meet-safe-and-unsafe.md | 2 +- src/doc/nomicon/{ => src}/obrm.md | 2 +- src/doc/nomicon/{ => src}/other-reprs.md | 2 +- src/doc/nomicon/{ => src}/ownership.md | 2 +- src/doc/nomicon/{ => src}/phantom-data.md | 2 +- src/doc/nomicon/{ => src}/poisoning.md | 2 +- src/doc/nomicon/{ => src}/races.md | 2 +- src/doc/nomicon/{ => src}/references.md | 2 +- src/doc/nomicon/{ => src}/repr-rust.md | 2 +- .../nomicon/{ => src}/safe-unsafe-meaning.md | 2 +- src/doc/nomicon/{ => src}/send-and-sync.md | 2 +- src/doc/nomicon/{ => src}/subtyping.md | 2 +- src/doc/nomicon/{ => src}/transmutes.md | 2 +- .../nomicon/{ => src}/unbounded-lifetimes.md | 2 +- src/doc/nomicon/{ => src}/unchecked-uninit.md | 2 +- src/doc/nomicon/{ => src}/uninitialized.md | 2 +- src/doc/nomicon/{ => src}/unwinding.md | 2 +- src/doc/nomicon/{ => src}/vec-alloc.md | 2 +- src/doc/nomicon/{ => src}/vec-dealloc.md | 2 +- src/doc/nomicon/{ => src}/vec-deref.md | 2 +- src/doc/nomicon/{ => src}/vec-drain.md | 2 +- src/doc/nomicon/{ => src}/vec-final.md | 2 +- .../nomicon/{ => src}/vec-insert-remove.md | 2 +- src/doc/nomicon/{ => src}/vec-into-iter.md | 2 +- src/doc/nomicon/{ => src}/vec-layout.md | 2 +- src/doc/nomicon/{ => src}/vec-push-pop.md | 2 +- src/doc/nomicon/{ => src}/vec-raw.md | 2 +- src/doc/nomicon/{ => src}/vec-zsts.md | 2 +- src/doc/nomicon/{ => src}/vec.md | 2 +- .../nomicon/{ => src}/working-with-unsafe.md | 2 +- 54 files changed, 105 insertions(+), 106 deletions(-) delete mode 100644 src/doc/nomicon/SUMMARY.md rename src/doc/nomicon/{ => src}/README.md (99%) rename src/doc/nomicon/{ => src}/arc-and-mutex.md (89%) rename src/doc/nomicon/{ => src}/atomics.md (99%) rename src/doc/nomicon/{ => src}/borrow-splitting.md (99%) rename src/doc/nomicon/{ => src}/casts.md (99%) rename src/doc/nomicon/{ => src}/checked-uninit.md (98%) rename src/doc/nomicon/{ => src}/coercions.md (99%) rename src/doc/nomicon/{ => src}/concurrency.md (96%) rename src/doc/nomicon/{ => src}/constructors.md (99%) rename src/doc/nomicon/{ => src}/conversions.md (98%) rename src/doc/nomicon/{ => src}/data.md (87%) rename src/doc/nomicon/{ => src}/destructors.md (99%) rename src/doc/nomicon/{ => src}/dot-operator.md (93%) rename src/doc/nomicon/{ => src}/drop-flags.md (99%) rename src/doc/nomicon/{ => src}/dropck.md (99%) rename src/doc/nomicon/{ => src}/exception-safety.md (99%) rename src/doc/nomicon/{ => src}/exotic-sizes.md (99%) rename src/doc/nomicon/{ => src}/hrtb.md (98%) rename src/doc/nomicon/{ => src}/leaking.md (99%) rename src/doc/nomicon/{ => src}/lifetime-elision.md (99%) rename src/doc/nomicon/{ => src}/lifetime-mismatch.md (98%) rename src/doc/nomicon/{ => src}/lifetimes.md (99%) rename src/doc/nomicon/{ => src}/meet-safe-and-unsafe.md (99%) rename src/doc/nomicon/{ => src}/obrm.md (93%) rename src/doc/nomicon/{ => src}/other-reprs.md (99%) rename src/doc/nomicon/{ => src}/ownership.md (99%) rename src/doc/nomicon/{ => src}/phantom-data.md (99%) rename src/doc/nomicon/{ => src}/poisoning.md (99%) rename src/doc/nomicon/{ => src}/races.md (99%) rename src/doc/nomicon/{ => src}/references.md (99%) rename src/doc/nomicon/{ => src}/repr-rust.md (99%) rename src/doc/nomicon/{ => src}/safe-unsafe-meaning.md (99%) rename src/doc/nomicon/{ => src}/send-and-sync.md (99%) rename src/doc/nomicon/{ => src}/subtyping.md (99%) rename src/doc/nomicon/{ => src}/transmutes.md (99%) rename src/doc/nomicon/{ => src}/unbounded-lifetimes.md (98%) rename src/doc/nomicon/{ => src}/unchecked-uninit.md (99%) rename src/doc/nomicon/{ => src}/uninitialized.md (93%) rename src/doc/nomicon/{ => src}/unwinding.md (99%) rename src/doc/nomicon/{ => src}/vec-alloc.md (99%) rename src/doc/nomicon/{ => src}/vec-dealloc.md (98%) rename src/doc/nomicon/{ => src}/vec-deref.md (99%) rename src/doc/nomicon/{ => src}/vec-drain.md (99%) rename src/doc/nomicon/{ => src}/vec-final.md (99%) rename src/doc/nomicon/{ => src}/vec-insert-remove.md (98%) rename src/doc/nomicon/{ => src}/vec-into-iter.md (99%) rename src/doc/nomicon/{ => src}/vec-layout.md (99%) rename src/doc/nomicon/{ => src}/vec-push-pop.md (99%) rename src/doc/nomicon/{ => src}/vec-raw.md (99%) rename src/doc/nomicon/{ => src}/vec-zsts.md (99%) rename src/doc/nomicon/{ => src}/vec.md (97%) rename src/doc/nomicon/{ => src}/working-with-unsafe.md (99%) diff --git a/src/doc/nomicon/SUMMARY.md b/src/doc/nomicon/SUMMARY.md deleted file mode 100644 index 7d4ef9c2514..00000000000 --- a/src/doc/nomicon/SUMMARY.md +++ /dev/null @@ -1,53 +0,0 @@ -# Summary - -* [Meet Safe and Unsafe](meet-safe-and-unsafe.md) - * [How Safe and Unsafe Interact](safe-unsafe-meaning.md) - * [Working with Unsafe](working-with-unsafe.md) -* [Data Layout](data.md) - * [repr(Rust)](repr-rust.md) - * [Exotically Sized Types](exotic-sizes.md) - * [Other reprs](other-reprs.md) -* [Ownership](ownership.md) - * [References](references.md) - * [Lifetimes](lifetimes.md) - * [Limits of Lifetimes](lifetime-mismatch.md) - * [Lifetime Elision](lifetime-elision.md) - * [Unbounded Lifetimes](unbounded-lifetimes.md) - * [Higher-Rank Trait Bounds](hrtb.md) - * [Subtyping and Variance](subtyping.md) - * [Drop Check](dropck.md) - * [PhantomData](phantom-data.md) - * [Splitting Borrows](borrow-splitting.md) -* [Type Conversions](conversions.md) - * [Coercions](coercions.md) - * [The Dot Operator](dot-operator.md) - * [Casts](casts.md) - * [Transmutes](transmutes.md) -* [Uninitialized Memory](uninitialized.md) - * [Checked](checked-uninit.md) - * [Drop Flags](drop-flags.md) - * [Unchecked](unchecked-uninit.md) -* [Ownership Based Resource Management](obrm.md) - * [Constructors](constructors.md) - * [Destructors](destructors.md) - * [Leaking](leaking.md) -* [Unwinding](unwinding.md) - * [Exception Safety](exception-safety.md) - * [Poisoning](poisoning.md) -* [Concurrency](concurrency.md) - * [Races](races.md) - * [Send and Sync](send-and-sync.md) - * [Atomics](atomics.md) -* [Implementing Vec](vec.md) - * [Layout](vec-layout.md) - * [Allocating](vec-alloc.md) - * [Push and Pop](vec-push-pop.md) - * [Deallocating](vec-dealloc.md) - * [Deref](vec-deref.md) - * [Insert and Remove](vec-insert-remove.md) - * [IntoIter](vec-into-iter.md) - * [RawVec](vec-raw.md) - * [Drain](vec-drain.md) - * [Handling Zero-Sized Types](vec-zsts.md) - * [Final Code](vec-final.md) -* [Implementing Arc and Mutex](arc-and-mutex.md) diff --git a/src/doc/nomicon/README.md b/src/doc/nomicon/src/README.md similarity index 99% rename from src/doc/nomicon/README.md rename to src/doc/nomicon/src/README.md index b2e1eac5e0d..d577d7b5cc9 100644 --- a/src/doc/nomicon/README.md +++ b/src/doc/nomicon/src/README.md @@ -1,4 +1,4 @@ -% The Rustonomicon +# The Rustonomicon #### The Dark Arts of Advanced and Unsafe Rust Programming diff --git a/src/doc/nomicon/src/SUMMARY.md b/src/doc/nomicon/src/SUMMARY.md index 7390c82896e..e33dcbbb418 100644 --- a/src/doc/nomicon/src/SUMMARY.md +++ b/src/doc/nomicon/src/SUMMARY.md @@ -1,3 +1,55 @@ # Summary -- [Chapter 1](./chapter_1.md) +[Introduction](README.md) + +* [Meet Safe and Unsafe](meet-safe-and-unsafe.md) + * [How Safe and Unsafe Interact](safe-unsafe-meaning.md) + * [Working with Unsafe](working-with-unsafe.md) +* [Data Layout](data.md) + * [repr(Rust)](repr-rust.md) + * [Exotically Sized Types](exotic-sizes.md) + * [Other reprs](other-reprs.md) +* [Ownership](ownership.md) + * [References](references.md) + * [Lifetimes](lifetimes.md) + * [Limits of Lifetimes](lifetime-mismatch.md) + * [Lifetime Elision](lifetime-elision.md) + * [Unbounded Lifetimes](unbounded-lifetimes.md) + * [Higher-Rank Trait Bounds](hrtb.md) + * [Subtyping and Variance](subtyping.md) + * [Drop Check](dropck.md) + * [PhantomData](phantom-data.md) + * [Splitting Borrows](borrow-splitting.md) +* [Type Conversions](conversions.md) + * [Coercions](coercions.md) + * [The Dot Operator](dot-operator.md) + * [Casts](casts.md) + * [Transmutes](transmutes.md) +* [Uninitialized Memory](uninitialized.md) + * [Checked](checked-uninit.md) + * [Drop Flags](drop-flags.md) + * [Unchecked](unchecked-uninit.md) +* [Ownership Based Resource Management](obrm.md) + * [Constructors](constructors.md) + * [Destructors](destructors.md) + * [Leaking](leaking.md) +* [Unwinding](unwinding.md) + * [Exception Safety](exception-safety.md) + * [Poisoning](poisoning.md) +* [Concurrency](concurrency.md) + * [Races](races.md) + * [Send and Sync](send-and-sync.md) + * [Atomics](atomics.md) +* [Implementing Vec](vec.md) + * [Layout](vec-layout.md) + * [Allocating](vec-alloc.md) + * [Push and Pop](vec-push-pop.md) + * [Deallocating](vec-dealloc.md) + * [Deref](vec-deref.md) + * [Insert and Remove](vec-insert-remove.md) + * [IntoIter](vec-into-iter.md) + * [RawVec](vec-raw.md) + * [Drain](vec-drain.md) + * [Handling Zero-Sized Types](vec-zsts.md) + * [Final Code](vec-final.md) +* [Implementing Arc and Mutex](arc-and-mutex.md) diff --git a/src/doc/nomicon/arc-and-mutex.md b/src/doc/nomicon/src/arc-and-mutex.md similarity index 89% rename from src/doc/nomicon/arc-and-mutex.md rename to src/doc/nomicon/src/arc-and-mutex.md index fcafe55e409..fedc7b8bd6a 100644 --- a/src/doc/nomicon/arc-and-mutex.md +++ b/src/doc/nomicon/src/arc-and-mutex.md @@ -1,4 +1,4 @@ -% Implementing Arc and Mutex +# Implementing Arc and Mutex Knowing the theory is all fine and good, but the *best* way to understand something is to use it. To better understand atomics and interior mutability, diff --git a/src/doc/nomicon/atomics.md b/src/doc/nomicon/src/atomics.md similarity index 99% rename from src/doc/nomicon/atomics.md rename to src/doc/nomicon/src/atomics.md index 7b4c44ff051..e9ed21a93e0 100644 --- a/src/doc/nomicon/atomics.md +++ b/src/doc/nomicon/src/atomics.md @@ -1,4 +1,4 @@ -% Atomics +# Atomics Rust pretty blatantly just inherits C11's memory model for atomics. This is not due to this model being particularly excellent or easy to understand. Indeed, diff --git a/src/doc/nomicon/borrow-splitting.md b/src/doc/nomicon/src/borrow-splitting.md similarity index 99% rename from src/doc/nomicon/borrow-splitting.md rename to src/doc/nomicon/src/borrow-splitting.md index cc5bc8a602d..28ddb507ae2 100644 --- a/src/doc/nomicon/borrow-splitting.md +++ b/src/doc/nomicon/src/borrow-splitting.md @@ -1,4 +1,4 @@ -% Splitting Borrows +# Splitting Borrows The mutual exclusion property of mutable references can be very limiting when working with a composite structure. The borrow checker understands some basic diff --git a/src/doc/nomicon/casts.md b/src/doc/nomicon/src/casts.md similarity index 99% rename from src/doc/nomicon/casts.md rename to src/doc/nomicon/src/casts.md index 6cc41bd9533..31b78587245 100644 --- a/src/doc/nomicon/casts.md +++ b/src/doc/nomicon/src/casts.md @@ -1,4 +1,4 @@ -% Casts +# Casts Casts are a superset of coercions: every coercion can be explicitly invoked via a cast. However some conversions require a cast. diff --git a/src/doc/nomicon/checked-uninit.md b/src/doc/nomicon/src/checked-uninit.md similarity index 98% rename from src/doc/nomicon/checked-uninit.md rename to src/doc/nomicon/src/checked-uninit.md index f7c4482a4ab..4423404fe6e 100644 --- a/src/doc/nomicon/checked-uninit.md +++ b/src/doc/nomicon/src/checked-uninit.md @@ -1,4 +1,4 @@ -% Checked Uninitialized Memory +# Checked Uninitialized Memory Like C, all stack variables in Rust are uninitialized until a value is explicitly assigned to them. Unlike C, Rust statically prevents you from ever diff --git a/src/doc/nomicon/coercions.md b/src/doc/nomicon/src/coercions.md similarity index 99% rename from src/doc/nomicon/coercions.md rename to src/doc/nomicon/src/coercions.md index b699946ceca..1a51bb5a9c6 100644 --- a/src/doc/nomicon/coercions.md +++ b/src/doc/nomicon/src/coercions.md @@ -1,4 +1,4 @@ -% Coercions +# Coercions Types can implicitly be coerced to change in certain contexts. These changes are generally just *weakening* of types, largely focused around pointers and diff --git a/src/doc/nomicon/concurrency.md b/src/doc/nomicon/src/concurrency.md similarity index 96% rename from src/doc/nomicon/concurrency.md rename to src/doc/nomicon/src/concurrency.md index b93b303f0b9..6205199bfcc 100644 --- a/src/doc/nomicon/concurrency.md +++ b/src/doc/nomicon/src/concurrency.md @@ -1,4 +1,4 @@ -% Concurrency and Parallelism +# Concurrency and Parallelism Rust as a language doesn't *really* have an opinion on how to do concurrency or parallelism. The standard library exposes OS threads and blocking sys-calls diff --git a/src/doc/nomicon/constructors.md b/src/doc/nomicon/src/constructors.md similarity index 99% rename from src/doc/nomicon/constructors.md rename to src/doc/nomicon/src/constructors.md index 97817cd1f90..b79e72dbae2 100644 --- a/src/doc/nomicon/constructors.md +++ b/src/doc/nomicon/src/constructors.md @@ -1,4 +1,4 @@ -% Constructors +# Constructors There is exactly one way to create an instance of a user-defined type: name it, and initialize all its fields at once: diff --git a/src/doc/nomicon/conversions.md b/src/doc/nomicon/src/conversions.md similarity index 98% rename from src/doc/nomicon/conversions.md rename to src/doc/nomicon/src/conversions.md index b099a789ec3..388d003d9b6 100644 --- a/src/doc/nomicon/conversions.md +++ b/src/doc/nomicon/src/conversions.md @@ -1,4 +1,4 @@ -% Type Conversions +# Type Conversions At the end of the day, everything is just a pile of bits somewhere, and type systems are just there to help us use those bits right. There are two common diff --git a/src/doc/nomicon/data.md b/src/doc/nomicon/src/data.md similarity index 87% rename from src/doc/nomicon/data.md rename to src/doc/nomicon/src/data.md index d0a796b7f0b..bf202ada08e 100644 --- a/src/doc/nomicon/data.md +++ b/src/doc/nomicon/src/data.md @@ -1,4 +1,4 @@ -% Data Representation in Rust +# Data Representation in Rust Low-level programming cares a lot about data layout. It's a big deal. It also pervasively influences the rest of the language, so we're going to start by diff --git a/src/doc/nomicon/destructors.md b/src/doc/nomicon/src/destructors.md similarity index 99% rename from src/doc/nomicon/destructors.md rename to src/doc/nomicon/src/destructors.md index be4730cf8bc..8c395fe3dc9 100644 --- a/src/doc/nomicon/destructors.md +++ b/src/doc/nomicon/src/destructors.md @@ -1,4 +1,4 @@ -% Destructors +# Destructors What the language *does* provide is full-blown automatic destructors through the `Drop` trait, which provides the following method: diff --git a/src/doc/nomicon/dot-operator.md b/src/doc/nomicon/src/dot-operator.md similarity index 93% rename from src/doc/nomicon/dot-operator.md rename to src/doc/nomicon/src/dot-operator.md index 5d2010d15a8..a1fc33bdc1e 100644 --- a/src/doc/nomicon/dot-operator.md +++ b/src/doc/nomicon/src/dot-operator.md @@ -1,4 +1,4 @@ -% The Dot Operator +# The Dot Operator The dot operator will perform a lot of magic to convert types. It will perform auto-referencing, auto-dereferencing, and coercion until types match. diff --git a/src/doc/nomicon/drop-flags.md b/src/doc/nomicon/src/drop-flags.md similarity index 99% rename from src/doc/nomicon/drop-flags.md rename to src/doc/nomicon/src/drop-flags.md index cfceafe1bdf..51fa9d0a3c0 100644 --- a/src/doc/nomicon/drop-flags.md +++ b/src/doc/nomicon/src/drop-flags.md @@ -1,4 +1,4 @@ -% Drop Flags +# Drop Flags The examples in the previous section introduce an interesting problem for Rust. We have seen that it's possible to conditionally initialize, deinitialize, and diff --git a/src/doc/nomicon/dropck.md b/src/doc/nomicon/src/dropck.md similarity index 99% rename from src/doc/nomicon/dropck.md rename to src/doc/nomicon/src/dropck.md index 6114006cbb3..39039694be6 100644 --- a/src/doc/nomicon/dropck.md +++ b/src/doc/nomicon/src/dropck.md @@ -1,4 +1,4 @@ -% Drop Check +# Drop Check We have seen how lifetimes provide us some fairly simple rules for ensuring that we never read dangling references. However up to this point we have only ever diff --git a/src/doc/nomicon/exception-safety.md b/src/doc/nomicon/src/exception-safety.md similarity index 99% rename from src/doc/nomicon/exception-safety.md rename to src/doc/nomicon/src/exception-safety.md index 74f7831a72a..80e72cd5e36 100644 --- a/src/doc/nomicon/exception-safety.md +++ b/src/doc/nomicon/src/exception-safety.md @@ -1,4 +1,4 @@ -% Exception Safety +# Exception Safety Although programs should use unwinding sparingly, there's a lot of code that *can* panic. If you unwrap a None, index out of bounds, or divide by 0, your diff --git a/src/doc/nomicon/exotic-sizes.md b/src/doc/nomicon/src/exotic-sizes.md similarity index 99% rename from src/doc/nomicon/exotic-sizes.md rename to src/doc/nomicon/src/exotic-sizes.md index 052e3c5fddc..9f858d11dbb 100644 --- a/src/doc/nomicon/exotic-sizes.md +++ b/src/doc/nomicon/src/exotic-sizes.md @@ -1,4 +1,4 @@ -% Exotically Sized Types +# Exotically Sized Types Most of the time, we think in terms of types with a fixed, positive size. This is not always the case, however. diff --git a/src/doc/nomicon/hrtb.md b/src/doc/nomicon/src/hrtb.md similarity index 98% rename from src/doc/nomicon/hrtb.md rename to src/doc/nomicon/src/hrtb.md index 8692832e2c7..645986af13a 100644 --- a/src/doc/nomicon/hrtb.md +++ b/src/doc/nomicon/src/hrtb.md @@ -1,4 +1,4 @@ -% Higher-Rank Trait Bounds (HRTBs) +# Higher-Rank Trait Bounds (HRTBs) Rust's `Fn` traits are a little bit magic. For instance, we can write the following code: diff --git a/src/doc/nomicon/leaking.md b/src/doc/nomicon/src/leaking.md similarity index 99% rename from src/doc/nomicon/leaking.md rename to src/doc/nomicon/src/leaking.md index a5d5742a4c6..38b70b85b57 100644 --- a/src/doc/nomicon/leaking.md +++ b/src/doc/nomicon/src/leaking.md @@ -1,4 +1,4 @@ -% Leaking +# Leaking Ownership-based resource management is intended to simplify composition. You acquire resources when you create the object, and you release the resources when diff --git a/src/doc/nomicon/lifetime-elision.md b/src/doc/nomicon/src/lifetime-elision.md similarity index 99% rename from src/doc/nomicon/lifetime-elision.md rename to src/doc/nomicon/src/lifetime-elision.md index bcd93a58d85..e92d735a01d 100644 --- a/src/doc/nomicon/lifetime-elision.md +++ b/src/doc/nomicon/src/lifetime-elision.md @@ -1,4 +1,4 @@ -% Lifetime Elision +# Lifetime Elision In order to make common patterns more ergonomic, Rust allows lifetimes to be *elided* in function signatures. diff --git a/src/doc/nomicon/lifetime-mismatch.md b/src/doc/nomicon/src/lifetime-mismatch.md similarity index 98% rename from src/doc/nomicon/lifetime-mismatch.md rename to src/doc/nomicon/src/lifetime-mismatch.md index 0ad8a78880e..30b4f09f903 100644 --- a/src/doc/nomicon/lifetime-mismatch.md +++ b/src/doc/nomicon/src/lifetime-mismatch.md @@ -1,4 +1,4 @@ -% Limits of Lifetimes +# Limits of Lifetimes Given the following code: diff --git a/src/doc/nomicon/lifetimes.md b/src/doc/nomicon/src/lifetimes.md similarity index 99% rename from src/doc/nomicon/lifetimes.md rename to src/doc/nomicon/src/lifetimes.md index 45eb68baeb7..e2f0cc86772 100644 --- a/src/doc/nomicon/lifetimes.md +++ b/src/doc/nomicon/src/lifetimes.md @@ -1,4 +1,4 @@ -% Lifetimes +# Lifetimes Rust enforces these rules through *lifetimes*. Lifetimes are effectively just names for scopes somewhere in the program. Each reference, diff --git a/src/doc/nomicon/meet-safe-and-unsafe.md b/src/doc/nomicon/src/meet-safe-and-unsafe.md similarity index 99% rename from src/doc/nomicon/meet-safe-and-unsafe.md rename to src/doc/nomicon/src/meet-safe-and-unsafe.md index 15d84fdbf29..d42d0b6d725 100644 --- a/src/doc/nomicon/meet-safe-and-unsafe.md +++ b/src/doc/nomicon/src/meet-safe-and-unsafe.md @@ -1,4 +1,4 @@ -% Meet Safe and Unsafe +# Meet Safe and Unsafe Programmers in safe "high-level" languages face a fundamental dilemma. On one hand, it would be *really* great to just say what you want and not worry about diff --git a/src/doc/nomicon/obrm.md b/src/doc/nomicon/src/obrm.md similarity index 93% rename from src/doc/nomicon/obrm.md rename to src/doc/nomicon/src/obrm.md index 2c495240c12..19e5ec38259 100644 --- a/src/doc/nomicon/obrm.md +++ b/src/doc/nomicon/src/obrm.md @@ -1,4 +1,4 @@ -% The Perils Of Ownership Based Resource Management (OBRM) +# The Perils Of Ownership Based Resource Management (OBRM) OBRM (AKA RAII: Resource Acquisition Is Initialization) is something you'll interact with a lot in Rust. Especially if you use the standard library. diff --git a/src/doc/nomicon/other-reprs.md b/src/doc/nomicon/src/other-reprs.md similarity index 99% rename from src/doc/nomicon/other-reprs.md rename to src/doc/nomicon/src/other-reprs.md index b124f3ffc46..02f39e3c4dd 100644 --- a/src/doc/nomicon/other-reprs.md +++ b/src/doc/nomicon/src/other-reprs.md @@ -1,4 +1,4 @@ -% Alternative representations +# Alternative representations Rust allows you to specify alternative data layout strategies from the default. diff --git a/src/doc/nomicon/ownership.md b/src/doc/nomicon/src/ownership.md similarity index 99% rename from src/doc/nomicon/ownership.md rename to src/doc/nomicon/src/ownership.md index a6ecf6ab91b..dd9e9db244a 100644 --- a/src/doc/nomicon/ownership.md +++ b/src/doc/nomicon/src/ownership.md @@ -1,4 +1,4 @@ -% Ownership and Lifetimes +# Ownership and Lifetimes Ownership is the breakout feature of Rust. It allows Rust to be completely memory-safe and efficient, while avoiding garbage collection. Before getting diff --git a/src/doc/nomicon/phantom-data.md b/src/doc/nomicon/src/phantom-data.md similarity index 99% rename from src/doc/nomicon/phantom-data.md rename to src/doc/nomicon/src/phantom-data.md index 189695716de..72fa2e2a777 100644 --- a/src/doc/nomicon/phantom-data.md +++ b/src/doc/nomicon/src/phantom-data.md @@ -1,4 +1,4 @@ -% PhantomData +# PhantomData When working with unsafe code, we can often end up in a situation where types or lifetimes are logically associated with a struct, but not actually diff --git a/src/doc/nomicon/poisoning.md b/src/doc/nomicon/src/poisoning.md similarity index 99% rename from src/doc/nomicon/poisoning.md rename to src/doc/nomicon/src/poisoning.md index 70de91af61f..9b5dec3eec3 100644 --- a/src/doc/nomicon/poisoning.md +++ b/src/doc/nomicon/src/poisoning.md @@ -1,4 +1,4 @@ -% Poisoning +# Poisoning Although all unsafe code *must* ensure it has minimal exception safety, not all types ensure *maximal* exception safety. Even if the type does, your code may diff --git a/src/doc/nomicon/races.md b/src/doc/nomicon/src/races.md similarity index 99% rename from src/doc/nomicon/races.md rename to src/doc/nomicon/src/races.md index 5145987158a..c9b8c3d01b2 100644 --- a/src/doc/nomicon/races.md +++ b/src/doc/nomicon/src/races.md @@ -1,4 +1,4 @@ -% Data Races and Race Conditions +# Data Races and Race Conditions Safe Rust guarantees an absence of data races, which are defined as: diff --git a/src/doc/nomicon/references.md b/src/doc/nomicon/src/references.md similarity index 99% rename from src/doc/nomicon/references.md rename to src/doc/nomicon/src/references.md index 3d7369eca0f..5d80f1edd96 100644 --- a/src/doc/nomicon/references.md +++ b/src/doc/nomicon/src/references.md @@ -1,4 +1,4 @@ -% References +# References This section gives a high-level view of the memory model that *all* Rust programs must satisfy to be correct. Safe code is statically verified diff --git a/src/doc/nomicon/repr-rust.md b/src/doc/nomicon/src/repr-rust.md similarity index 99% rename from src/doc/nomicon/repr-rust.md rename to src/doc/nomicon/src/repr-rust.md index effeaf872bb..c02cf44189f 100644 --- a/src/doc/nomicon/repr-rust.md +++ b/src/doc/nomicon/src/repr-rust.md @@ -1,4 +1,4 @@ -% repr(Rust) +# repr(Rust) First and foremost, all types have an alignment specified in bytes. The alignment of a type specifies what addresses are valid to store the value at. A diff --git a/src/doc/nomicon/safe-unsafe-meaning.md b/src/doc/nomicon/src/safe-unsafe-meaning.md similarity index 99% rename from src/doc/nomicon/safe-unsafe-meaning.md rename to src/doc/nomicon/src/safe-unsafe-meaning.md index adede0ec911..0a655a3f53a 100644 --- a/src/doc/nomicon/safe-unsafe-meaning.md +++ b/src/doc/nomicon/src/safe-unsafe-meaning.md @@ -1,4 +1,4 @@ -% How Safe and Unsafe Interact +# How Safe and Unsafe Interact What's the relationship between Safe Rust and Unsafe Rust? How do they interact? diff --git a/src/doc/nomicon/send-and-sync.md b/src/doc/nomicon/src/send-and-sync.md similarity index 99% rename from src/doc/nomicon/send-and-sync.md rename to src/doc/nomicon/src/send-and-sync.md index 134e47f18dc..959f870d4e6 100644 --- a/src/doc/nomicon/send-and-sync.md +++ b/src/doc/nomicon/src/send-and-sync.md @@ -1,4 +1,4 @@ -% Send and Sync +# Send and Sync Not everything obeys inherited mutability, though. Some types allow you to multiply alias a location in memory while mutating it. Unless these types use diff --git a/src/doc/nomicon/subtyping.md b/src/doc/nomicon/src/subtyping.md similarity index 99% rename from src/doc/nomicon/subtyping.md rename to src/doc/nomicon/src/subtyping.md index eb940e811a4..d771712d050 100644 --- a/src/doc/nomicon/subtyping.md +++ b/src/doc/nomicon/src/subtyping.md @@ -1,4 +1,4 @@ -% Subtyping and Variance +# Subtyping and Variance Although Rust doesn't have any notion of structural inheritance, it *does* include subtyping. In Rust, subtyping derives entirely from lifetimes. Since diff --git a/src/doc/nomicon/transmutes.md b/src/doc/nomicon/src/transmutes.md similarity index 99% rename from src/doc/nomicon/transmutes.md rename to src/doc/nomicon/src/transmutes.md index f1478b7f668..043c8fe4625 100644 --- a/src/doc/nomicon/transmutes.md +++ b/src/doc/nomicon/src/transmutes.md @@ -1,4 +1,4 @@ -% Transmutes +# Transmutes Get out of our way type system! We're going to reinterpret these bits or die trying! Even though this book is all about doing things that are unsafe, I diff --git a/src/doc/nomicon/unbounded-lifetimes.md b/src/doc/nomicon/src/unbounded-lifetimes.md similarity index 98% rename from src/doc/nomicon/unbounded-lifetimes.md rename to src/doc/nomicon/src/unbounded-lifetimes.md index 1f3693f542f..b41cf8b4ed9 100644 --- a/src/doc/nomicon/unbounded-lifetimes.md +++ b/src/doc/nomicon/src/unbounded-lifetimes.md @@ -1,4 +1,4 @@ -% Unbounded Lifetimes +# Unbounded Lifetimes Unsafe code can often end up producing references or lifetimes out of thin air. Such lifetimes come into the world as *unbounded*. The most common source of this diff --git a/src/doc/nomicon/unchecked-uninit.md b/src/doc/nomicon/src/unchecked-uninit.md similarity index 99% rename from src/doc/nomicon/unchecked-uninit.md rename to src/doc/nomicon/src/unchecked-uninit.md index c72ed8a7632..ef31a3535d6 100644 --- a/src/doc/nomicon/unchecked-uninit.md +++ b/src/doc/nomicon/src/unchecked-uninit.md @@ -1,4 +1,4 @@ -% Unchecked Uninitialized Memory +# Unchecked Uninitialized Memory One interesting exception to this rule is working with arrays. Safe Rust doesn't permit you to partially initialize an array. When you initialize an array, you diff --git a/src/doc/nomicon/uninitialized.md b/src/doc/nomicon/src/uninitialized.md similarity index 93% rename from src/doc/nomicon/uninitialized.md rename to src/doc/nomicon/src/uninitialized.md index 05615d89bec..eafc67907f2 100644 --- a/src/doc/nomicon/uninitialized.md +++ b/src/doc/nomicon/src/uninitialized.md @@ -1,4 +1,4 @@ -% Working With Uninitialized Memory +# Working With Uninitialized Memory All runtime-allocated memory in a Rust program begins its life as *uninitialized*. In this state the value of the memory is an indeterminate pile diff --git a/src/doc/nomicon/unwinding.md b/src/doc/nomicon/src/unwinding.md similarity index 99% rename from src/doc/nomicon/unwinding.md rename to src/doc/nomicon/src/unwinding.md index e81f06b83b2..6dc396d5153 100644 --- a/src/doc/nomicon/unwinding.md +++ b/src/doc/nomicon/src/unwinding.md @@ -1,4 +1,4 @@ -% Unwinding +# Unwinding Rust has a *tiered* error-handling scheme: diff --git a/src/doc/nomicon/vec-alloc.md b/src/doc/nomicon/src/vec-alloc.md similarity index 99% rename from src/doc/nomicon/vec-alloc.md rename to src/doc/nomicon/src/vec-alloc.md index bc60a577bd3..ef4c5279343 100644 --- a/src/doc/nomicon/vec-alloc.md +++ b/src/doc/nomicon/src/vec-alloc.md @@ -1,4 +1,4 @@ -% Allocating Memory +# Allocating Memory Using Unique throws a wrench in an important feature of Vec (and indeed all of the std collections): an empty Vec doesn't actually allocate at all. So if we diff --git a/src/doc/nomicon/vec-dealloc.md b/src/doc/nomicon/src/vec-dealloc.md similarity index 98% rename from src/doc/nomicon/vec-dealloc.md rename to src/doc/nomicon/src/vec-dealloc.md index 706fe680e00..83ab5b24b02 100644 --- a/src/doc/nomicon/vec-dealloc.md +++ b/src/doc/nomicon/src/vec-dealloc.md @@ -1,4 +1,4 @@ -% Deallocating +# Deallocating Next we should implement Drop so that we don't massively leak tons of resources. The easiest way is to just call `pop` until it yields None, and then deallocate diff --git a/src/doc/nomicon/vec-deref.md b/src/doc/nomicon/src/vec-deref.md similarity index 99% rename from src/doc/nomicon/vec-deref.md rename to src/doc/nomicon/src/vec-deref.md index 6460eab479b..e21542c955a 100644 --- a/src/doc/nomicon/vec-deref.md +++ b/src/doc/nomicon/src/vec-deref.md @@ -1,4 +1,4 @@ -% Deref +# Deref Alright! We've got a decent minimal stack implemented. We can push, we can pop, and we can clean up after ourselves. However there's a whole mess of diff --git a/src/doc/nomicon/vec-drain.md b/src/doc/nomicon/src/vec-drain.md similarity index 99% rename from src/doc/nomicon/vec-drain.md rename to src/doc/nomicon/src/vec-drain.md index 6e732ee1074..5bd2bf05d8c 100644 --- a/src/doc/nomicon/vec-drain.md +++ b/src/doc/nomicon/src/vec-drain.md @@ -1,4 +1,4 @@ -% Drain +# Drain Let's move on to Drain. Drain is largely the same as IntoIter, except that instead of consuming the Vec, it borrows the Vec and leaves its allocation diff --git a/src/doc/nomicon/vec-final.md b/src/doc/nomicon/src/vec-final.md similarity index 99% rename from src/doc/nomicon/vec-final.md rename to src/doc/nomicon/src/vec-final.md index 1f4377a7ca3..39746cad781 100644 --- a/src/doc/nomicon/vec-final.md +++ b/src/doc/nomicon/src/vec-final.md @@ -1,4 +1,4 @@ -% The Final Code +# The Final Code ```rust #![feature(unique)] diff --git a/src/doc/nomicon/vec-insert-remove.md b/src/doc/nomicon/src/vec-insert-remove.md similarity index 98% rename from src/doc/nomicon/vec-insert-remove.md rename to src/doc/nomicon/src/vec-insert-remove.md index bcecd78a1b7..2c14bc45227 100644 --- a/src/doc/nomicon/vec-insert-remove.md +++ b/src/doc/nomicon/src/vec-insert-remove.md @@ -1,4 +1,4 @@ -% Insert and Remove +# Insert and Remove Something *not* provided by slice is `insert` and `remove`, so let's do those next. diff --git a/src/doc/nomicon/vec-into-iter.md b/src/doc/nomicon/src/vec-into-iter.md similarity index 99% rename from src/doc/nomicon/vec-into-iter.md rename to src/doc/nomicon/src/vec-into-iter.md index ebb0a79bb65..f2f5995ec1c 100644 --- a/src/doc/nomicon/vec-into-iter.md +++ b/src/doc/nomicon/src/vec-into-iter.md @@ -1,4 +1,4 @@ -% IntoIter +# IntoIter Let's move on to writing iterators. `iter` and `iter_mut` have already been written for us thanks to The Magic of Deref. However there's two interesting diff --git a/src/doc/nomicon/vec-layout.md b/src/doc/nomicon/src/vec-layout.md similarity index 99% rename from src/doc/nomicon/vec-layout.md rename to src/doc/nomicon/src/vec-layout.md index 7ca369da0b8..1dc09aef6ad 100644 --- a/src/doc/nomicon/vec-layout.md +++ b/src/doc/nomicon/src/vec-layout.md @@ -1,4 +1,4 @@ -% Layout +# Layout First off, we need to come up with the struct layout. A Vec has three parts: a pointer to the allocation, the size of the allocation, and the number of diff --git a/src/doc/nomicon/vec-push-pop.md b/src/doc/nomicon/src/vec-push-pop.md similarity index 99% rename from src/doc/nomicon/vec-push-pop.md rename to src/doc/nomicon/src/vec-push-pop.md index 5e747a8c71d..d31a74cc308 100644 --- a/src/doc/nomicon/vec-push-pop.md +++ b/src/doc/nomicon/src/vec-push-pop.md @@ -1,4 +1,4 @@ -% Push and Pop +# Push and Pop Alright. We can initialize. We can allocate. Let's actually implement some functionality! Let's start with `push`. All it needs to do is check if we're diff --git a/src/doc/nomicon/vec-raw.md b/src/doc/nomicon/src/vec-raw.md similarity index 99% rename from src/doc/nomicon/vec-raw.md rename to src/doc/nomicon/src/vec-raw.md index 8f78462cf40..20fa8ab92c2 100644 --- a/src/doc/nomicon/vec-raw.md +++ b/src/doc/nomicon/src/vec-raw.md @@ -1,4 +1,4 @@ -% RawVec +# RawVec We've actually reached an interesting situation here: we've duplicated the logic for specifying a buffer and freeing its memory in Vec and IntoIter. Now that diff --git a/src/doc/nomicon/vec-zsts.md b/src/doc/nomicon/src/vec-zsts.md similarity index 99% rename from src/doc/nomicon/vec-zsts.md rename to src/doc/nomicon/src/vec-zsts.md index 5f3b2a81364..5ae9bdd3274 100644 --- a/src/doc/nomicon/vec-zsts.md +++ b/src/doc/nomicon/src/vec-zsts.md @@ -1,4 +1,4 @@ -% Handling Zero-Sized Types +# Handling Zero-Sized Types It's time. We're going to fight the specter that is zero-sized types. Safe Rust *never* needs to care about this, but Vec is very intensive on raw pointers and diff --git a/src/doc/nomicon/vec.md b/src/doc/nomicon/src/vec.md similarity index 97% rename from src/doc/nomicon/vec.md rename to src/doc/nomicon/src/vec.md index 691301946de..ad98e45f197 100644 --- a/src/doc/nomicon/vec.md +++ b/src/doc/nomicon/src/vec.md @@ -1,4 +1,4 @@ -% Example: Implementing Vec +# Example: Implementing Vec To bring everything together, we're going to write `std::Vec` from scratch. Because all the best tools for writing unsafe code are unstable, this diff --git a/src/doc/nomicon/working-with-unsafe.md b/src/doc/nomicon/src/working-with-unsafe.md similarity index 99% rename from src/doc/nomicon/working-with-unsafe.md rename to src/doc/nomicon/src/working-with-unsafe.md index b20dff72e1c..5724f3d09a3 100644 --- a/src/doc/nomicon/working-with-unsafe.md +++ b/src/doc/nomicon/src/working-with-unsafe.md @@ -1,4 +1,4 @@ -% Working with Unsafe +# Working with Unsafe Rust generally only gives us the tools to talk about Unsafe Rust in a scoped and binary manner. Unfortunately, reality is significantly more complicated than From 2b2c62bc5b92163d53722f1d5dcda3b2496b78b5 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Fri, 10 Feb 2017 11:27:34 -0500 Subject: [PATCH 4/8] fix gitattributes for vendor --- .gitattributes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index e2d04142766..e737c7946ef 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,4 +6,4 @@ *.rs rust src/etc/installer/gfx/* binary *.woff binary -src/vendor/* binary +src/vendor/** -text From 626cf3a263dcac94c88910a6a67018e82b564c75 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Fri, 10 Feb 2017 11:47:58 -0500 Subject: [PATCH 5/8] include everything in the vendor directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8b141416e4f..d82e279e012 100644 --- a/.gitignore +++ b/.gitignore @@ -100,3 +100,4 @@ version.md version.ml version.texi .cargo +!src/vendor/** From 775726092eaa4d0e0e397e9032467c2d1d06ed37 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 9 Feb 2017 14:44:39 -0500 Subject: [PATCH 6/8] Add exceptions to tidy We've decided that these deps are okay. --- src/tools/rustbook/src/main.rs | 25 ++++++++++++++++++------- src/tools/tidy/src/deps.rs | 26 ++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/tools/rustbook/src/main.rs b/src/tools/rustbook/src/main.rs index 837c934934a..b77baed5326 100644 --- a/src/tools/rustbook/src/main.rs +++ b/src/tools/rustbook/src/main.rs @@ -1,3 +1,13 @@ +// Copyright 2016 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. +// extern crate mdbook; #[macro_use] extern crate clap; @@ -11,19 +21,21 @@ use clap::{App, ArgMatches, SubCommand, AppSettings}; use mdbook::MDBook; -const NAME: &'static str = "rustbook"; - fn main() { - // Create a list of valid arguments and sub-commands - let matches = App::new(NAME) + let d_message = "-d, --dest-dir=[dest-dir] +'The output directory for your book{n}(Defaults to ./book when omitted)'"; + let dir_message = "[dir] +'A directory for your book{n}(Defaults to Current Directory when omitted)'"; + + let matches = App::new("rustbook") .about("Build a book with mdBook") .author("Steve Klabnik ") .version(&*format!("v{}", crate_version!())) .setting(AppSettings::SubcommandRequired) .subcommand(SubCommand::with_name("build") .about("Build the book from the markdown files") - .arg_from_usage("-d, --dest-dir=[dest-dir] 'The output directory for your book{n}(Defaults to ./book when omitted)'") - .arg_from_usage("[dir] 'A directory for your book{n}(Defaults to Current Directory when omitted)'")) + .arg_from_usage(d_message) + .arg_from_usage(dir_message)) .get_matches(); // Check which subcomamnd the user ran... @@ -76,4 +88,3 @@ fn get_book_dir(args: &ArgMatches) -> PathBuf { env::current_dir().unwrap() } } - diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 7592c09a913..e1c44a20e97 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -15,16 +15,38 @@ use std::io::Read; use std::path::Path; static LICENSES: &'static [&'static str] = &[ - "MIT/Apache-2.0" + "MIT/Apache-2.0", + "Apache-2.0/MIT", + "MIT OR Apache-2.0", + "MIT", + "Unlicense/MIT", +]; + +/// These MPL licensed projects are acceptable, but only these. +static EXCEPTIONS: &'static [&'static str] = &[ + "mdbook", + "pest", + "thread-id", ]; pub fn check(path: &Path, bad: &mut bool) { let path = path.join("vendor"); assert!(path.exists(), "vendor directory missing"); let mut saw_dir = false; - for dir in t!(path.read_dir()) { + 'next_path: for dir in t!(path.read_dir()) { saw_dir = true; let dir = t!(dir); + + // skip our exceptions + for exception in EXCEPTIONS { + if dir.path() + .to_str() + .unwrap() + .contains(&format!("src/vendor/{}", exception)) { + continue 'next_path; + } + } + let toml = dir.path().join("Cargo.toml"); if !check_license(&toml) { *bad = true; From 7f1d1c6d9a7be5e427bace30e740b16b25f25c92 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Fri, 10 Feb 2017 15:12:59 -0500 Subject: [PATCH 7/8] Fix up links mdbook and rustdoc generate links differently, so we need to change all these links. --- src/doc/book/src/casting-between-types.md | 2 +- src/doc/book/src/closures.md | 2 +- src/doc/book/src/compiler-plugins.md | 2 +- src/doc/book/src/concurrency.md | 4 +- src/doc/book/src/error-handling.md | 72 +++++++++++------------ src/doc/book/src/ffi.md | 2 +- src/doc/book/src/getting-started.md | 2 +- src/doc/book/src/glossary.md | 6 +- src/doc/book/src/guessing-game.md | 4 +- src/doc/book/src/lifetimes.md | 2 +- src/doc/book/src/macros.md | 2 +- src/doc/book/src/mutability.md | 2 +- src/doc/book/src/ownership.md | 8 +-- src/doc/book/src/primitive-types.md | 2 +- src/doc/book/src/syntax-index.md | 50 ++++++++-------- src/doc/book/src/traits.md | 2 +- src/doc/book/src/type-aliases.md | 2 +- src/doc/book/src/vectors.md | 2 +- src/doc/nomicon/src/lifetime-mismatch.md | 2 +- src/doc/nomicon/src/repr-rust.md | 2 +- src/doc/reference.md | 6 +- src/liballoc/arc.rs | 2 +- src/liballoc/rc.rs | 2 +- src/libcore/mem.rs | 2 +- src/libcore/raw.rs | 2 +- src/libstd/lib.rs | 4 +- src/libstd/primitive_docs.rs | 2 +- 27 files changed, 96 insertions(+), 96 deletions(-) diff --git a/src/doc/book/src/casting-between-types.md b/src/doc/book/src/casting-between-types.md index 853fb1ec254..2f6730be665 100644 --- a/src/doc/book/src/casting-between-types.md +++ b/src/doc/book/src/casting-between-types.md @@ -8,7 +8,7 @@ most dangerous features of Rust! # Coercion Coercion between types is implicit and has no syntax of its own, but can -be spelled out with [`as`](#explicit-coercions). +be spelled out with [`as`](#Explicit%20coercions). Coercion occurs in `let`, `const`, and `static` statements; in function call arguments; in field values in struct initialization; and in a diff --git a/src/doc/book/src/closures.md b/src/doc/book/src/closures.md index 5426ed0ff4c..2f6d5039f4d 100644 --- a/src/doc/book/src/closures.md +++ b/src/doc/book/src/closures.md @@ -463,7 +463,7 @@ fn factory() -> &(Fn(i32) -> i32) { Right. Because we have a reference, we need to give it a lifetime. But our `factory()` function takes no arguments, so -[elision](lifetimes.html#lifetime-elision) doesn’t kick in here. Then what +[elision](lifetimes.html#Lifetime%20Elision) doesn’t kick in here. Then what choices do we have? Try `'static`: ```rust,ignore diff --git a/src/doc/book/src/compiler-plugins.md b/src/doc/book/src/compiler-plugins.md index 1b7ce678982..47c5e5c8291 100644 --- a/src/doc/book/src/compiler-plugins.md +++ b/src/doc/book/src/compiler-plugins.md @@ -127,7 +127,7 @@ enum. For a more involved macro example, see ## Tips and tricks -Some of the [macro debugging tips](macros.html#debugging-macro-code) are applicable. +Some of the [macro debugging tips](macros.html#Debugging%20macro%20code) are applicable. You can use `syntax::parse` to turn token trees into higher-level syntax elements like expressions: diff --git a/src/doc/book/src/concurrency.md b/src/doc/book/src/concurrency.md index a64178c26f2..e5bc7ecdd0b 100644 --- a/src/doc/book/src/concurrency.md +++ b/src/doc/book/src/concurrency.md @@ -55,7 +55,7 @@ For sharing references across threads, Rust provides a wrapper type called `Arc`. `Arc` implements `Send` and `Sync` if and only if `T` implements both `Send` and `Sync`. For example, an object of type `Arc>` cannot be transferred across threads because -[`RefCell`](choosing-your-guarantees.html#refcellt) does not implement +[`RefCell`](choosing-your-guarantees.html#RefCell%3CT%3E) does not implement `Sync`, consequently `Arc>` would not implement `Send`. These two traits allow you to use the type system to make strong guarantees @@ -126,7 +126,7 @@ closure only captures a _reference to `x`_. This is a problem, because the thread may outlive the scope of `x`, leading to a dangling pointer. To fix this, we use a `move` closure as mentioned in the error message. `move` -closures are explained in depth [here](closures.html#move-closures); basically +closures are explained in depth [here](closures.html#move%20closures); basically they move variables from their environment into themselves. ```rust diff --git a/src/doc/book/src/error-handling.md b/src/doc/book/src/error-handling.md index c823c32a135..1b0d2453275 100644 --- a/src/doc/book/src/error-handling.md +++ b/src/doc/book/src/error-handling.md @@ -21,35 +21,35 @@ sum types and combinators, and try to motivate the way Rust does error handling incrementally. As such, programmers with experience in other expressive type systems may want to jump around. -* [The Basics](#the-basics) - * [Unwrapping explained](#unwrapping-explained) - * [The `Option` type](#the-option-type) - * [Composing `Option` values](#composing-optiont-values) - * [The `Result` type](#the-result-type) - * [Parsing integers](#parsing-integers) - * [The `Result` type alias idiom](#the-result-type-alias-idiom) - * [A brief interlude: unwrapping isn't evil](#a-brief-interlude-unwrapping-isnt-evil) -* [Working with multiple error types](#working-with-multiple-error-types) - * [Composing `Option` and `Result`](#composing-option-and-result) - * [The limits of combinators](#the-limits-of-combinators) - * [Early returns](#early-returns) - * [The `try!` macro](#the-try-macro) - * [Defining your own error type](#defining-your-own-error-type) -* [Standard library traits used for error handling](#standard-library-traits-used-for-error-handling) - * [The `Error` trait](#the-error-trait) - * [The `From` trait](#the-from-trait) - * [The real `try!` macro](#the-real-try-macro) - * [Composing custom error types](#composing-custom-error-types) - * [Advice for library writers](#advice-for-library-writers) -* [Case study: A program to read population data](#case-study-a-program-to-read-population-data) - * [Initial setup](#initial-setup) - * [Argument parsing](#argument-parsing) - * [Writing the logic](#writing-the-logic) - * [Error handling with `Box`](#error-handling-with-boxerror) - * [Reading from stdin](#reading-from-stdin) - * [Error handling with a custom type](#error-handling-with-a-custom-type) - * [Adding functionality](#adding-functionality) -* [The short story](#the-short-story) +* [The Basics](#The%20Basics) + * [Unwrapping explained](#Unwrapping%20explained) + * [The `Option` type](#The%20Option%20type) + * [Composing `Option` values](#Composing%20Option%3CT%3E%20values) + * [The `Result` type](#The%20Result%20type) + * [Parsing integers](#Parsing%20integers) + * [The `Result` type alias idiom](#The%20Result%20type%20alias%20idiom) + * [A brief interlude: unwrapping isn't evil](#A%20brief%20interlude:%20unwrapping%20isnt%20evil) +* [Working with multiple error types](#Working%20with%20multiple%20error%20types) + * [Composing `Option` and `Result`](#Composing%20Option%20and%20Result) + * [The limits of combinators](#The%20limits%20of%20combinators) + * [Early returns](#Early%20returns) + * [The `try!` macro](#The%20try%20macro) + * [Defining your own error type](#Defining%20your%20own%20error%20type) +* [Standard library traits used for error handling](#Standard%20library%20traits%20used%20for%20error%20handling) + * [The `Error` trait](#The%20Error%20trait) + * [The `From` trait](#The%20From%20trait) + * [The real `try!` macro](#The%20real%20try%20macro) + * [Composing custom error types](#Composing%20custom%20error%20types) + * [Advice for library writers](#Advice%20for%20library%20writers) +* [Case study: A program to read population data](#Case%20study:%20A%20program%20to%20read%20population%20data) + * [Initial setup](#Initial%20setup) + * [Argument parsing](#Argument%20parsing) + * [Writing the logic](#Writing%20the%20logic) + * [Error handling with `Box`](#Error%20handling%20with%20Box%3CError%3E) + * [Reading from stdin](#Reading%20from%20stdin) + * [Error handling with a custom type](#Error%20handling%20with%20a%20custom%20type) + * [Adding functionality](#Adding%20functionality) +* [The short story](#The%20short%20story) # The Basics @@ -796,7 +796,7 @@ because of the return types of [`std::fs::File::open`](../std/fs/struct.File.html#method.open) and [`std::io::Read::read_to_string`](../std/io/trait.Read.html#method.read_to_string). (Note that they both use the [`Result` type alias -idiom](#the-result-type-alias-idiom) described previously. If you +idiom](#The%20Result%20type%20alias%20idiom) described previously. If you click on the `Result` type, you'll [see the type alias](../std/io/type.Result.html), and consequently, the underlying `io::Error` type.) The third problem is described by the @@ -1120,7 +1120,7 @@ returns an `&Error`, which is itself a trait object. We'll revisit the For now, it suffices to show an example implementing the `Error` trait. Let's use the error type we defined in the -[previous section](#defining-your-own-error-type): +[previous section](#Defining%20your%20own%20error%20type): ```rust use std::io; @@ -1493,19 +1493,19 @@ representation. But certainly, this will vary depending on use cases. At a minimum, you should probably implement the [`Error`](../std/error/trait.Error.html) trait. This will give users of your library some minimum flexibility for -[composing errors](#the-real-try-macro). Implementing the `Error` trait also +[composing errors](#The%20real%20try%20macro). Implementing the `Error` trait also means that users are guaranteed the ability to obtain a string representation of an error (because it requires impls for both `fmt::Debug` and `fmt::Display`). Beyond that, it can also be useful to provide implementations of `From` on your error types. This allows you (the library author) and your users to -[compose more detailed errors](#composing-custom-error-types). For example, +[compose more detailed errors](#Composing%20custom%20error%20types). For example, [`csv::Error`](http://burntsushi.net/rustdoc/csv/enum.Error.html) provides `From` impls for both `io::Error` and `byteorder::Error`. Finally, depending on your tastes, you may also want to define a -[`Result` type alias](#the-result-type-alias-idiom), particularly if your +[`Result` type alias](#The%20Result%20type%20alias%20idiom), particularly if your library defines a single error type. This is used in the standard library for [`io::Result`](../std/io/type.Result.html) and [`fmt::Result`](../std/fmt/type.Result.html). @@ -1538,7 +1538,7 @@ and [`rustc-serialize`](https://crates.io/crates/rustc-serialize) crates. We're not going to spend a lot of time on setting up a project with Cargo because it is already covered well in [the Cargo -section](getting-started.html#hello-cargo) and [Cargo's documentation][14]. +section](getting-started.html#Hello%20Cargo) and [Cargo's documentation][14]. To get started from scratch, run `cargo new --bin city-pop` and make sure your `Cargo.toml` looks something like this: @@ -1729,7 +1729,7 @@ error types and you don't need any `From` implementations. The downside is that since `Box` is a trait object, it *erases the type*, which means the compiler can no longer reason about its underlying type. -[Previously](#the-limits-of-combinators) we started refactoring our code by +[Previously](#The%20limits%20of%20combinators) we started refactoring our code by changing the type of our function from `T` to `Result`. In this case, `OurErrorType` is only `Box`. But what's `T`? And can we add a return type to `main`? diff --git a/src/doc/book/src/ffi.md b/src/doc/book/src/ffi.md index cccefd8dfe7..b2994d2a29c 100644 --- a/src/doc/book/src/ffi.md +++ b/src/doc/book/src/ffi.md @@ -680,7 +680,7 @@ pub extern fn hello_rust() -> *const u8 { The `extern` makes this function adhere to the C calling convention, as discussed above in "[Foreign Calling -Conventions](ffi.html#foreign-calling-conventions)". The `no_mangle` +Conventions](ffi.html#Foreign%20calling%20conventions)". The `no_mangle` attribute turns off Rust's name mangling, so that it is easier to link to. # FFI and panics diff --git a/src/doc/book/src/getting-started.md b/src/doc/book/src/getting-started.md index 6208b1f4c12..93846644c39 100644 --- a/src/doc/book/src/getting-started.md +++ b/src/doc/book/src/getting-started.md @@ -236,7 +236,7 @@ language]*, which means that most things are expressions, rather than statements. The `;` indicates that this expression is over, and the next one is ready to begin. Most lines of Rust code end with a `;`. -[expression-oriented language]: glossary.html#expression-oriented-language +[expression-oriented language]: glossary.html#Expression-Oriented%20Language ## Compiling and Running Are Separate Steps diff --git a/src/doc/book/src/glossary.md b/src/doc/book/src/glossary.md index b17b89633f3..49821d86a92 100644 --- a/src/doc/book/src/glossary.md +++ b/src/doc/book/src/glossary.md @@ -56,7 +56,7 @@ They can be used to manage control flow in a modular fashion. A type without a statically known size or alignment. ([more info][link]) -[link]: ../nomicon/exotic-sizes.html#dynamically-sized-types-dsts +[link]: ../nomicon/exotic-sizes.html#Dynamically%20Sized%20Types%20(DSTs) ### Expression @@ -76,8 +76,8 @@ In an expression-oriented language, (nearly) every statement is an expression and therefore returns a value. Consequently, these expression statements can themselves form part of larger expressions. -[expression]: glossary.html#expression -[statement]: glossary.html#statement +[expression]: glossary.html#Expression +[statement]: glossary.html#Statement ### Statement diff --git a/src/doc/book/src/guessing-game.md b/src/doc/book/src/guessing-game.md index 7368d2184e5..216db25cd95 100644 --- a/src/doc/book/src/guessing-game.md +++ b/src/doc/book/src/guessing-game.md @@ -119,7 +119,7 @@ there are no arguments, and `{` starts the body of the function. Because we didn’t include a return type, it’s assumed to be `()`, an empty [tuple][tuples]. -[tuples]: primitive-types.html#tuples +[tuples]: primitive-types.html#Tuples ```rust,ignore println!("Guess the number!"); @@ -727,7 +727,7 @@ thirty-two bit integer. Rust has [a number of built-in number types][number], but we’ve chosen `u32`. It’s a good default choice for a small positive number. [parse]: ../std/primitive.str.html#method.parse -[number]: primitive-types.html#numeric-types +[number]: primitive-types.html#Numeric%20types Just like `read_line()`, our call to `parse()` could cause an error. What if our string contained `A👍%`? There’d be no way to convert that to a number. As diff --git a/src/doc/book/src/lifetimes.md b/src/doc/book/src/lifetimes.md index 8bca13c28f0..c00815f49c7 100644 --- a/src/doc/book/src/lifetimes.md +++ b/src/doc/book/src/lifetimes.md @@ -139,7 +139,7 @@ associated with it, but the compiler lets you elide (i.e. omit, see ["Lifetime Elision"][lifetime-elision] below) them in common cases. Before we get to that, though, let’s look at a short example with explicit lifetimes: -[lifetime-elision]: #lifetime-elision +[lifetime-elision]: #Lifetime%20Elision ```rust,ignore fn bar<'a>(...) diff --git a/src/doc/book/src/macros.md b/src/doc/book/src/macros.md index 22d53779bb9..3ccbeb05f01 100644 --- a/src/doc/book/src/macros.md +++ b/src/doc/book/src/macros.md @@ -432,7 +432,7 @@ Even when Rust code contains un-expanded macros, it can be parsed as a full tools that process code. It also has a few consequences for the design of Rust’s macro system. -[ast]: glossary.html#abstract-syntax-tree +[ast]: glossary.html#Abstract%20Syntax%20Tree One consequence is that Rust must determine, when it parses a macro invocation, whether the macro stands in for diff --git a/src/doc/book/src/mutability.md b/src/doc/book/src/mutability.md index fa7a259392a..7e96849220a 100644 --- a/src/doc/book/src/mutability.md +++ b/src/doc/book/src/mutability.md @@ -89,7 +89,7 @@ philosophy, memory safety, and the mechanism by which Rust guarantees it, the > * exactly one mutable reference (`&mut T`). [ownership]: ownership.html -[borrowing]: references-and-borrowing.html#borrowing +[borrowing]: references-and-borrowing.html#Borrowing So, that’s the real definition of ‘immutability’: is this safe to have two pointers to? In `Arc`’s case, yes: the mutation is entirely contained inside diff --git a/src/doc/book/src/ownership.md b/src/doc/book/src/ownership.md index 21ebd6333f7..e7bf3cec55e 100644 --- a/src/doc/book/src/ownership.md +++ b/src/doc/book/src/ownership.md @@ -65,10 +65,10 @@ elements onto them. Vectors have a [generic type][generics] `Vec`, so in this example `v` will have type `Vec`. We'll cover [generics] in detail in a later chapter. -[arrays]: primitive-types.html#arrays +[arrays]: primitive-types.html#Arrays [vectors]: vectors.html -[heap]: the-stack-and-the-heap.html#the-heap -[stack]: the-stack-and-the-heap.html#the-stack +[heap]: the-stack-and-the-heap.html#The%20Heap +[stack]: the-stack-and-the-heap.html#The%20Stack [bindings]: variable-bindings.html [generics]: generics.html @@ -136,7 +136,7 @@ Rust allocates memory for an integer [i32] on the [stack][sh], copies the bit pattern representing the value of 10 to the allocated memory and binds the variable name x to this memory region for future reference. -[i32]: primitive-types.html#numeric-types +[i32]: primitive-types.html#Numeric%20types Now consider the following code fragment: diff --git a/src/doc/book/src/primitive-types.md b/src/doc/book/src/primitive-types.md index 8fd3d17c15e..67d71ceba0c 100644 --- a/src/doc/book/src/primitive-types.md +++ b/src/doc/book/src/primitive-types.md @@ -232,7 +232,7 @@ soon. You can assign one tuple into another, if they have the same contained types and [arity]. Tuples have the same arity when they have the same length. -[arity]: glossary.html#arity +[arity]: glossary.html#Arity ```rust let mut x = (1, 2); // x: (i32, i32) diff --git a/src/doc/book/src/syntax-index.md b/src/doc/book/src/syntax-index.md index d8bb4fadc0b..1e1d811a1d8 100644 --- a/src/doc/book/src/syntax-index.md +++ b/src/doc/book/src/syntax-index.md @@ -196,18 +196,18 @@ [Associated Types]: associated-types.html [Attributes]: attributes.html [Casting Between Types (`as`)]: casting-between-types.html#as -[Closures (`move` closures)]: closures.html#move-closures +[Closures (`move` closures)]: closures.html#move%20closures [Closures]: closures.html [Comments]: comments.html -[Crates and Modules (Defining Modules)]: crates-and-modules.html#defining-modules -[Crates and Modules (Exporting a Public Interface)]: crates-and-modules.html#exporting-a-public-interface -[Crates and Modules (Importing External Crates)]: crates-and-modules.html#importing-external-crates -[Crates and Modules (Importing Modules with `use`)]: crates-and-modules.html#importing-modules-with-use -[Crates and Modules (Re-exporting with `pub use`)]: crates-and-modules.html#re-exporting-with-pub-use -[Diverging Functions]: functions.html#diverging-functions +[Crates and Modules (Defining Modules)]: crates-and-modules.html#Defining%20modules +[Crates and Modules (Exporting a Public Interface)]: crates-and-modules.html#Exporting%20a%20public%20interface +[Crates and Modules (Importing External Crates)]: crates-and-modules.html#Importing%20external%20crates +[Crates and Modules (Importing Modules with `use`)]: crates-and-modules.html#Importing%20modules%20with%20use +[Crates and Modules (Re-exporting with `pub use`)]: crates-and-modules.html#Re-exporting%20with%20pub%20use +[Diverging Functions]: functions.html#Diverging%20functions [Enums]: enums.html [Foreign Function Interface]: ffi.html -[Functions (Early Returns)]: functions.html#early-returns +[Functions (Early Returns)]: functions.html#Early%20returns [Functions]: functions.html [Generics]: generics.html [Iterators]: iterators.html @@ -216,24 +216,24 @@ [Loops (`for`)]: loops.html#for [Loops (`loop`)]: loops.html#loop [Loops (`while`)]: loops.html#while -[Loops (Ending Iteration Early)]: loops.html#ending-iteration-early -[Loops (Loops Labels)]: loops.html#loop-labels +[Loops (Ending Iteration Early)]: loops.html#Ending%20iteration%20early +[Loops (Loops Labels)]: loops.html#Loop%20labels [Macros]: macros.html [Match]: match.html -[Method Syntax (Method Calls)]: method-syntax.html#method-calls +[Method Syntax (Method Calls)]: method-syntax.html#Method%20calls [Method Syntax]: method-syntax.html [Mutability]: mutability.html [Operators and Overloading]: operators-and-overloading.html -[Patterns (`ref` and `ref mut`)]: patterns.html#ref-and-ref-mut -[Patterns (Bindings)]: patterns.html#bindings -[Patterns (Ignoring bindings)]: patterns.html#ignoring-bindings -[Patterns (Multiple patterns)]: patterns.html#multiple-patterns -[Patterns (Ranges)]: patterns.html#ranges +[Patterns (`ref` and `ref mut`)]: patterns.html#ref%20and%20ref%20mut +[Patterns (Bindings)]: patterns.html#Bindings +[Patterns (Ignoring bindings)]: patterns.html#Ignoring%20bindings +[Patterns (Multiple patterns)]: patterns.html#Multiple%20patterns +[Patterns (Ranges)]: patterns.html#Ranges [Primitive Types (`char`)]: primitive-types.html#char -[Primitive Types (Arrays)]: primitive-types.html#arrays -[Primitive Types (Booleans)]: primitive-types.html#booleans -[Primitive Types (Tuple Indexing)]: primitive-types.html#tuple-indexing -[Primitive Types (Tuples)]: primitive-types.html#tuples +[Primitive Types (Arrays)]: primitive-types.html#Arrays +[Primitive Types (Booleans)]: primitive-types.html#Booleans +[Primitive Types (Tuple Indexing)]: primitive-types.html#Tuple%20indexing +[Primitive Types (Tuples)]: primitive-types.html#Tuples [Raw Pointers]: raw-pointers.html [Reference (Byte String Literals)]: ../reference.html#byte-string-literals [Reference (Integer literals)]: ../reference.html#integer-literals @@ -241,13 +241,13 @@ [Reference (Raw String Literals)]: ../reference.html#raw-string-literals [References and Borrowing]: references-and-borrowing.html [Strings]: strings.html -[Structs (Update syntax)]: structs.html#update-syntax +[Structs (Update syntax)]: structs.html#Update%20syntax [Structs]: structs.html -[Traits (`where` clause)]: traits.html#where-clause -[Traits (Multiple Trait Bounds)]: traits.html#multiple-trait-bounds +[Traits (`where` clause)]: traits.html#Where%20clause +[Traits (Multiple Trait Bounds)]: traits.html#Multiple%20trait%20bounds [Traits]: traits.html [Universal Function Call Syntax]: ufcs.html -[Universal Function Call Syntax (Angle-bracket Form)]: ufcs.html#angle-bracket-form +[Universal Function Call Syntax (Angle-bracket Form)]: ufcs.html#Angle-bracket%20Form [Unsafe]: unsafe.html -[Unsized Types (`?Sized`)]: unsized-types.html#sized +[Unsized Types (`?Sized`)]: unsized-types.html#Sized [Variable Bindings]: variable-bindings.html diff --git a/src/doc/book/src/traits.md b/src/doc/book/src/traits.md index 19a133f84b0..a6d1c3d1d23 100644 --- a/src/doc/book/src/traits.md +++ b/src/doc/book/src/traits.md @@ -81,7 +81,7 @@ Traits are useful because they allow a type to make certain promises about its behavior. Generic functions can exploit this to constrain, or [bound][bounds], the types they accept. Consider this function, which does not compile: -[bounds]: glossary.html#bounds +[bounds]: glossary.html#Bounds ```rust,ignore fn print_area(shape: T) { diff --git a/src/doc/book/src/type-aliases.md b/src/doc/book/src/type-aliases.md index 1bd0f78e368..b1ce0685283 100644 --- a/src/doc/book/src/type-aliases.md +++ b/src/doc/book/src/type-aliases.md @@ -55,7 +55,7 @@ if x == y { This compiles without error. Values of a `Num` type are the same as a value of type `i32`, in every way. You can use [tuple struct] to really get a new type. -[tuple struct]: structs.html#tuple-structs +[tuple struct]: structs.html#Tuple%20structs You can also use type aliases with generics: diff --git a/src/doc/book/src/vectors.md b/src/doc/book/src/vectors.md index aff078718df..9b293880cdc 100644 --- a/src/doc/book/src/vectors.md +++ b/src/doc/book/src/vectors.md @@ -151,6 +151,6 @@ API documentation][vec]. [vec]: ../std/vec/index.html [box]: ../std/boxed/index.html [generic]: generics.html -[panic]: concurrency.html#panics +[panic]: concurrency.html#Panics [get]: ../std/vec/struct.Vec.html#method.get [get_mut]: ../std/vec/struct.Vec.html#method.get_mut diff --git a/src/doc/nomicon/src/lifetime-mismatch.md b/src/doc/nomicon/src/lifetime-mismatch.md index 30b4f09f903..08627130590 100644 --- a/src/doc/nomicon/src/lifetime-mismatch.md +++ b/src/doc/nomicon/src/lifetime-mismatch.md @@ -78,4 +78,4 @@ TODO: other common problems? SEME regions stuff, mostly? -[ex2]: lifetimes.html#example-aliasing-a-mutable-reference +[ex2]: lifetimes.html#Example%3A%20aliasing%20a%20mutable%20reference diff --git a/src/doc/nomicon/src/repr-rust.md b/src/doc/nomicon/src/repr-rust.md index c02cf44189f..98411e041be 100644 --- a/src/doc/nomicon/src/repr-rust.md +++ b/src/doc/nomicon/src/repr-rust.md @@ -151,4 +151,4 @@ use fairly elaborate algorithms to cache bits throughout nested types with special constrained representations. As such it is *especially* desirable that we leave enum layout unspecified today. -[dst]: exotic-sizes.html#dynamically-sized-types-dsts +[dst]: exotic-sizes.html#Dynamically%20Sized%20Types%20(DSTs) diff --git a/src/doc/reference.md b/src/doc/reference.md index ab4da862033..7155641e2c2 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2108,7 +2108,7 @@ On `struct`s: list of names `#[macro_use(foo, bar)]` restricts the import to just those macros named. The `extern crate` must appear at the crate root, not inside `mod`, which ensures proper function of the [`$crate` macro - variable](book/macros.html#the-variable-crate). + variable](book/macros.html#The%20variable%20%24crate). - `macro_reexport` on an `extern crate` — re-export the named macros. @@ -2118,7 +2118,7 @@ On `struct`s: link it into the output. See the [macros section of the -book](book/macros.html#scoping-and-macro-importexport) for more information on +book](book/macros.html#Scoping%20and%20macro%20import%2Fexport) for more information on macro scope. @@ -2277,7 +2277,7 @@ For any lint check `C`: The lint checks supported by the compiler can be found via `rustc -W help`, along with their default settings. [Compiler -plugins](book/compiler-plugins.html#lint-plugins) can provide additional lint checks. +plugins](book/compiler-plugins.html#Lint%20plugins) can provide additional lint checks. ```{.ignore} pub mod m1 { diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 38d843263ff..210917b68a2 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -102,7 +102,7 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize; /// [downgrade]: struct.Arc.html#method.downgrade /// [upgrade]: struct.Weak.html#method.upgrade /// [`None`]: ../../std/option/enum.Option.html#variant.None -/// [assoc]: ../../book/method-syntax.html#associated-functions +/// [assoc]: ../../book/method-syntax.html#Associated%20functions /// /// # Examples /// diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 6108a06634b..a874e938a40 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -215,7 +215,7 @@ //! [downgrade]: struct.Rc.html#method.downgrade //! [upgrade]: struct.Weak.html#method.upgrade //! [`None`]: ../../std/option/enum.Option.html#variant.None -//! [assoc]: ../../book/method-syntax.html#associated-functions +//! [assoc]: ../../book/method-syntax.html#Associated%20functions //! [mutability]: ../../std/cell/index.html#introducing-mutability-inside-of-something-immutable #![stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 209107ef92c..5655fd06604 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -525,7 +525,7 @@ pub fn replace(dest: &mut T, mut src: T) -> T { /// it will not release any borrows, as borrows are based on lexical scope. /// /// This effectively does nothing for -/// [types which implement `Copy`](../../book/ownership.html#copy-types), +/// [types which implement `Copy`](../../book/ownership.html#Copy%20types), /// e.g. integers. Such values are copied and _then_ moved into the function, /// so the value persists after this function call. /// diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index a7d0d3899b1..652b139f1e6 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -25,7 +25,7 @@ /// Book][moreinfo] contains more details about the precise nature of /// these internals. /// -/// [moreinfo]: ../../book/trait-objects.html#representation +/// [moreinfo]: ../../book/trait-objects.html#Representation /// /// `TraitObject` is guaranteed to match layouts, but it is not the /// type of trait objects (e.g. the fields are not directly accessible diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 070690773b6..88c2310a86e 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -189,8 +189,8 @@ //! [`sync`]: sync/index.html //! [`thread`]: thread/index.html //! [`use std::env`]: env/index.html -//! [`use`]: ../book/crates-and-modules.html#importing-modules-with-use -//! [crate root]: ../book/crates-and-modules.html#basic-terminology-crates-and-modules +//! [`use`]: ../book/crates-and-modules.html#Importing%20Modules%20with%20use +//! [crate root]: ../book/crates-and-modules.html#Basic%20terminology%3A%20Crates%20and%20Modules //! [crates.io]: https://crates.io //! [deref coercions]: ../book/deref-coercions.html //! [files]: fs/struct.File.html diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index 11197db98a3..1b3e17c300e 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -490,7 +490,7 @@ mod prim_str { } /// assert_eq!(tuple.2, 'c'); /// ``` /// -/// For more about tuples, see [the book](../book/primitive-types.html#tuples). +/// For more about tuples, see [the book](../book/primitive-types.html#Tuples). /// /// # Trait implementations /// From cacb3bc9c741a7d41a1085af850cd3ff852307f5 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Fri, 10 Feb 2017 16:38:20 -0500 Subject: [PATCH 8/8] fix up linkchecker 1. skip png files 2. skip fragments for the book and nomicon, as these are added by JS 3. Actually print the filename for errors --- src/tools/linkchecker/main.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs index f84d685127b..304c722bbe5 100644 --- a/src/tools/linkchecker/main.rs +++ b/src/tools/linkchecker/main.rs @@ -171,6 +171,13 @@ fn check(cache: &mut Cache, } } + if let Some(extension) = path.extension() { + // don't check these files + if extension == "png" { + return; + } + } + // Alright, if we've found a file name then this file had better // exist! If it doesn't then we register and print an error. if path.exists() { @@ -188,7 +195,9 @@ fn check(cache: &mut Cache, let res = load_file(cache, root, path.clone(), FromRedirect(false)); let (pretty_path, contents) = match res { Ok(res) => res, - Err(LoadError::IOError(err)) => panic!(format!("{}", err)), + Err(LoadError::IOError(err)) => { + panic!(format!("error loading {}: {}", path.display(), err)); + } Err(LoadError::BrokenRedirect(target, _)) => { *errors = true; println!("{}:{}: broken redirect to {}", @@ -200,6 +209,13 @@ fn check(cache: &mut Cache, Err(LoadError::IsRedirect) => unreachable!(), }; + // we don't check the book for fragments because they're added via JS + for book in ["book/", "nomicon/"].iter() { + if !pretty_path.to_str().unwrap().starts_with(book) { + return; + } + } + if let Some(ref fragment) = fragment { // Fragments like `#1-6` are most likely line numbers to be // interpreted by javascript, so we're ignoring these