diff --git a/2018-edition/Cargo.lock b/2018-edition/Cargo.lock deleted file mode 100644 index 928f6b1244..0000000000 --- a/2018-edition/Cargo.lock +++ /dev/null @@ -1,142 +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 = "docopt" -version = "0.6.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 0.2.10 (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.24 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.5.2 (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.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.33" -source = "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.33 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[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 = "rust-book" -version = "0.0.1" -dependencies = [ - "docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.10 (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.24 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc-serialize" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "strsim" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[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.33 (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 = "utf8-ranges" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "walkdir" -version = "0.1.8" -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)", - "winapi 0.2.8 (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 docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)" = "4a7ef30445607f6fc8720f0a0a2c7442284b629cf0d049286860fae23e71c4d9" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum lazy_static 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "236eb37a62591d4a41a89b7763d7de3e06ca02d5ab2815446a8bae5d2f8c2d57" -"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2" -"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" -"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.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" -"checksum strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "67f84c44fbb2f91db7fef94554e6b2ac05909c9c0b0bc23bb98d3a1aebfe7f7c" -"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 utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" -"checksum walkdir 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c66c0b9792f0a765345452775f3adbd28dde9d33f30d13e5dcc5ae17cf6f3780" -"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/2018-edition/Cargo.toml b/2018-edition/Cargo.toml deleted file mode 100644 index bb6763509f..0000000000 --- a/2018-edition/Cargo.toml +++ /dev/null @@ -1,36 +0,0 @@ -[package] -name = "rust-book" -version = "0.0.1" -authors = ["Steve Klabnik "] -description = "The Rust Book" - -[[bin]] -name = "concat_chapters" -path = "tools/src/bin/concat_chapters.rs" - -[[bin]] -name = "lfp" -path = "tools/src/bin/lfp.rs" - -[[bin]] -name = "link2print" -path = "tools/src/bin/link2print.rs" - -[[bin]] -name = "remove_links" -path = "tools/src/bin/remove_links.rs" - -[[bin]] -name = "remove_markup" -path = "tools/src/bin/remove_markup.rs" - -[[bin]] -name = "convert_quotes" -path = "tools/src/bin/convert_quotes.rs" - -[dependencies] -walkdir = "0.1.5" -docopt = "0.6.82" -rustc-serialize = "0.3.19" -regex = "0.1.73" -lazy_static = "0.2.1" diff --git a/2018-edition/LICENSE-APACHE b/2018-edition/LICENSE-APACHE deleted file mode 100644 index 96e9f0458b..0000000000 --- a/2018-edition/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright 2010-2017 The Rust Project Developers - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/2018-edition/LICENSE-MIT b/2018-edition/LICENSE-MIT deleted file mode 100644 index 5a56e6e8ed..0000000000 --- a/2018-edition/LICENSE-MIT +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2010-2017 The Rust Project Developers - -Permission is hereby granted, free of charge, to any -person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the -Software without restriction, including without -limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/2018-edition/convert-quotes.sh b/2018-edition/convert-quotes.sh deleted file mode 100755 index aa51dcbddf..0000000000 --- a/2018-edition/convert-quotes.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -set -eu - -dir=$1 - -mkdir -p "tmp/$dir" - -for f in $dir/*.md -do - cat "$f" | cargo run --bin convert_quotes > "tmp/$f" - mv "tmp/$f" "$f" -done diff --git a/2018-edition/nostarch.sh b/2018-edition/nostarch.sh deleted file mode 100755 index 6c4173a01c..0000000000 --- a/2018-edition/nostarch.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -set -eu - -cargo build --release - -mkdir -p tmp -rm -rf tmp/*.md - -# Get all the Markdown files in the src dir, -ls src/${1:-""}*.md | \ -# except for `SUMMARY.md`. -grep -v SUMMARY.md | \ -# Extract just the filename so we can reuse it easily. -xargs -n 1 basename | \ -# Remove all links followed by ```, then -# Change all remaining links from Markdown to italicized inline text. -while IFS= read -r filename; do - < "src/$filename" ./target/release/remove_links \ - | ./target/release/link2print \ - | ./target/release/remove_markup > "tmp/$filename" -done -# Concatenate the files into the `nostarch` dir. -./target/release/concat_chapters tmp nostarch diff --git a/2018-edition/style-guide.md b/2018-edition/style-guide.md deleted file mode 100644 index 56677811f4..0000000000 --- a/2018-edition/style-guide.md +++ /dev/null @@ -1,34 +0,0 @@ -# Style Guide - -## Prose - -* Prefer title case for chapter/section headings, ex: `## Generating a Secret - Number` rather than `## Generating a secret number`. -* Prefer italics over single quotes when calling out a term, ex: `is an - *associated function* of` rather than `is an ‘associated function’ of`. -* When talking about a method in prose, DO NOT include the parentheses, ex: - `read_line` rather than `read_line()`. -* Hard wrap at 80 chars -* Prefer not mixing code and not-code in one word, ex: ``Remember when we wrote - `use std::io`?`` rather than ``Remember when we `use`d `std::io`?`` - -## Code - -* Add the file name before markdown blocks to make it clear which file we're - talking about, when applicable. -* When making changes to code, make it clear which parts of the code changed - and which stayed the same... not sure how to do this yet -* Split up long lines as appropriate to keep them under 80 chars if possible -* Use `bash` syntax highlighting for command line output code blocks - -## Links - -Once all the scripts are done: - -* If a link shouldn't be printed, mark it to be ignored - * This includes all "Chapter XX" intra-book links, which *should* be links - for the HTML version -* Make intra-book links and stdlib API doc links relative so they work whether - the book is read offline or on docs.rust-lang.org -* Use markdown links and keep in mind that they will be changed into `text at - *url*` in print, so word them in a way that it reads well in that format diff --git a/2018-edition/tools/docx-to-md.xsl b/2018-edition/tools/docx-to-md.xsl deleted file mode 100644 index 3b60bc34e4..0000000000 --- a/2018-edition/tools/docx-to-md.xsl +++ /dev/null @@ -1,218 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - [TOC] - # - - - - - - ## - - - - - - ### - - - - - - #### - - - - - - ### - - - - - - 1. - - - - - - 1. - - - - - - * - - - - - - * - - - - - - * - - - - - - - - - - - - - ``` - - - - - - - - - - - - - - - - - - - - - ``` - - - - ``` - - ``` - - - - - - - - - - - - - - > - - - - - - > - - - - - - > - - - - - -Unmatched: - - - - - - - - - - - - - - - ` - - ` - - - - - - - - - - - - - - - - - ** - - ** - - - - - - - - - - - - - - - - - * - - * - - - - - - - - - - - - - - diff --git a/2018-edition/tools/src/bin/concat_chapters.rs b/2018-edition/tools/src/bin/concat_chapters.rs deleted file mode 100644 index da02dd34b4..0000000000 --- a/2018-edition/tools/src/bin/concat_chapters.rs +++ /dev/null @@ -1,104 +0,0 @@ -#[macro_use] extern crate lazy_static; -extern crate regex; - -use std::env; -use std::io; -use std::io::{Read, Write}; -use std::process::exit; -use std::fs::{create_dir, read_dir, File}; -use std::path::{Path, PathBuf}; -use std::collections::BTreeMap; - -use regex::Regex; - -static PATTERNS: &'static [(&'static str, &'static str)] = &[ - (r"ch(\d\d)-\d\d-.*\.md", "chapter$1.md"), - (r"appendix-(\d\d).*\.md", "appendix.md"), -]; - -lazy_static! { - static ref MATCHERS: Vec<(Regex, &'static str)> = { - PATTERNS.iter() - .map(|&(expr, repl)| (Regex::new(expr).unwrap(), repl)) - .collect() - }; -} - -fn main() { - let args: Vec = env::args().collect(); - - if args.len() < 3 { - println!("Usage: {} ", args[0]); - exit(1); - } - - let source_dir = ensure_dir_exists(&args[1]).unwrap(); - let target_dir = ensure_dir_exists(&args[2]).unwrap(); - - let mut matched_files = match_files(source_dir, target_dir); - matched_files.sort(); - - for (target_path, source_paths) in group_by_target(matched_files) { - concat_files(source_paths, target_path).unwrap(); - } -} - -fn match_files(source_dir: &Path, target_dir: &Path) -> Vec<(PathBuf, PathBuf)> { - read_dir(source_dir) - .expect("Unable to read source directory") - .filter_map(|maybe_entry| maybe_entry.ok()) - .filter_map(|entry| { - let source_filename = entry.file_name(); - let source_filename = &source_filename.to_string_lossy().into_owned(); - for &(ref regex, replacement) in MATCHERS.iter() { - if regex.is_match(source_filename) { - let target_filename = regex.replace_all(source_filename, replacement); - let source_path = entry.path(); - let mut target_path = PathBuf::from(&target_dir); - target_path.push(target_filename); - return Some((source_path, target_path)); - } - } - None - }) - .collect() -} - -fn group_by_target(matched_files: Vec<(PathBuf, PathBuf)>) -> BTreeMap> { - let mut grouped: BTreeMap> = BTreeMap::new(); - for (source, target) in matched_files { - if let Some(source_paths) = grouped.get_mut(&target) { - source_paths.push(source); - continue; - } - let source_paths = vec![source]; - grouped.insert(target.clone(), source_paths); - } - grouped -} - -fn concat_files(source_paths: Vec, target_path: PathBuf) -> io::Result<()> { - println!("Concatenating into {}:", target_path.to_string_lossy()); - let mut target = try!(File::create(target_path)); - try!(target.write_all(b"\n[TOC]\n")); - - for path in source_paths { - println!(" {}", path.to_string_lossy()); - let mut source = try!(File::open(path)); - let mut contents: Vec = Vec::new(); - try!(source.read_to_end(&mut contents)); - - try!(target.write_all(b"\n")); - try!(target.write_all(&contents)); - try!(target.write_all(b"\n")); - } - Ok(()) -} - -fn ensure_dir_exists(dir_string: &str) -> io::Result<&Path> { - let path = Path::new(dir_string); - if !path.exists() { - try!(create_dir(path)); - } - Ok(&path) -} diff --git a/2018-edition/tools/src/bin/convert_quotes.rs b/2018-edition/tools/src/bin/convert_quotes.rs deleted file mode 100644 index b151ae7e9f..0000000000 --- a/2018-edition/tools/src/bin/convert_quotes.rs +++ /dev/null @@ -1,73 +0,0 @@ -use std::io; -use std::io::{Read, Write}; - -fn main() { - let mut is_in_code_block = false; - let mut is_in_inline_code = false; - let mut is_in_html_tag = false; - - let mut buffer = String::new(); - if let Err(e) = io::stdin().read_to_string(&mut buffer) { - panic!(e); - } - - for line in buffer.lines() { - if line.is_empty() { - is_in_inline_code = false; - } - if line.starts_with("```") { - is_in_code_block = !is_in_code_block; - } - if is_in_code_block { - is_in_inline_code = false; - is_in_html_tag = false; - write!(io::stdout(), "{}\n", line).unwrap(); - } else { - let mut modified_line = &mut String::new(); - let mut previous_char = std::char::REPLACEMENT_CHARACTER; - let mut chars_in_line = line.chars(); - - while let Some(possible_match) = chars_in_line.next() { - // check if inside inline code - if possible_match == '`' { - is_in_inline_code = !is_in_inline_code; - } - // check if inside html tag - if possible_match == '<' && !is_in_inline_code { - is_in_html_tag = true; - } - if possible_match == '>' && !is_in_inline_code { - is_in_html_tag = false; - } - - // replace with right/left apostrophe/quote - let char_to_push = - if possible_match == '\'' && !is_in_inline_code && !is_in_html_tag { - if (previous_char != std::char::REPLACEMENT_CHARACTER && - !previous_char.is_whitespace()) || - previous_char == '‘' - { - '’' - } else { - '‘' - } - } else if possible_match == '"' && !is_in_inline_code && !is_in_html_tag { - if (previous_char != std::char::REPLACEMENT_CHARACTER && - !previous_char.is_whitespace()) || - previous_char == '“' - { - '”' - } else { - '“' - } - } else { - // leave untouched - possible_match - }; - modified_line.push(char_to_push); - previous_char = char_to_push; - } - write!(io::stdout(), "{}\n", modified_line).unwrap(); - } - } -} diff --git a/2018-edition/tools/src/bin/lfp.rs b/2018-edition/tools/src/bin/lfp.rs deleted file mode 100644 index 32b2ab2975..0000000000 --- a/2018-edition/tools/src/bin/lfp.rs +++ /dev/null @@ -1,243 +0,0 @@ -// We have some long regex literals, so: -// ignore-tidy-linelength - -extern crate docopt; -extern crate rustc_serialize; -extern crate walkdir; - -use docopt::Docopt; -use std::{path, fs, io}; -use std::io::BufRead; - -fn main () { - let args: Args = Docopt::new(USAGE) - .and_then(|d| d.decode()) - .unwrap_or_else(|e| e.exit()); - - let src_dir = &path::Path::new(&args.arg_src_dir); - let found_errs = walkdir::WalkDir::new(src_dir) - .min_depth(1) - .into_iter() - .map(|entry| { - match entry { - Ok(entry) => entry, - Err(err) => { - eprintln!("{:?}", err); - std::process::exit(911) - }, - } - }) - .map(|entry| { - let path = entry.path(); - if is_file_of_interest(path) { - let err_vec = lint_file(path); - for err in &err_vec { - match *err { - LintingError::LineOfInterest(line_num, ref line) => - eprintln!("{}:{}\t{}", path.display(), line_num, line), - LintingError::UnableToOpenFile => - eprintln!("Unable to open {}.", path.display()), - } - } - !err_vec.is_empty() - } else { - false - } - }) - .collect::>() - .iter() - .any(|result| *result); - - if found_errs { - std::process::exit(1) - } else { - std::process::exit(0) - } -} - -const USAGE: &'static str = " -counter -Usage: - lfp - lfp (-h | --help) -Options: - -h --help Show this screen. -"; - -#[derive(Debug, RustcDecodable)] -struct Args { - arg_src_dir: String, -} - -fn lint_file(path: &path::Path) -> Vec { - match fs::File::open(path) { - Ok(file) => lint_lines(io::BufReader::new(&file).lines()), - Err(_) => vec![LintingError::UnableToOpenFile], - } -} - -fn lint_lines(lines: I) -> Vec - where I: Iterator> { - lines - .enumerate() - .map(|(line_num, line)| { - let raw_line = line.unwrap(); - if is_line_of_interest(&raw_line) { - Err(LintingError::LineOfInterest(line_num, raw_line)) - } else { - Ok(()) - } - }) - .filter(|result| result.is_err()) - .map(|result| result.unwrap_err()) - .collect() -} - -fn is_file_of_interest(path: &path::Path) -> bool { - path.extension() - .map_or(false, |ext| ext == "md") -} - -fn is_line_of_interest(line: &str) -> bool { - !line.split_whitespace() - .filter(|sub_string| - sub_string.contains("file://") && - !sub_string.contains("file:///projects/") - ) - .collect::>() - .is_empty() -} - -#[derive(Debug)] -enum LintingError { - UnableToOpenFile, - LineOfInterest(usize, String) -} - -#[cfg(test)] -mod tests { - - use std::path; - - #[test] - fn lint_file_returns_a_vec_with_errs_when_lines_of_interest_are_found() { - let string = r#" - $ cargo run - Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game) - Running `target/guessing_game` - Guess the number! - The secret number is: 61 - Please input your guess. - 10 - You guessed: 10 - Too small! - Please input your guess. - 99 - You guessed: 99 - Too big! - Please input your guess. - foo - Please input your guess. - 61 - You guessed: 61 - You win! - $ cargo run - Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game) - Running `target/debug/guessing_game` - Guess the number! - The secret number is: 7 - Please input your guess. - 4 - You guessed: 4 - $ cargo run - Running `target/debug/guessing_game` - Guess the number! - The secret number is: 83 - Please input your guess. - 5 - $ cargo run - Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game) - Running `target/debug/guessing_game` - Hello, world! - "#; - - let raw_lines = string.to_string(); - let lines = raw_lines.lines().map(|line| { - Ok(line.to_string()) - }); - - let result_vec = super::lint_lines(lines); - - assert!(!result_vec.is_empty()); - assert_eq!(3, result_vec.len()); - } - - #[test] - fn lint_file_returns_an_empty_vec_when_no_lines_of_interest_are_found() { - let string = r#" - $ cargo run - Compiling guessing_game v0.1.0 (file:///projects/guessing_game) - Running `target/guessing_game` - Guess the number! - The secret number is: 61 - Please input your guess. - 10 - You guessed: 10 - Too small! - Please input your guess. - 99 - You guessed: 99 - Too big! - Please input your guess. - foo - Please input your guess. - 61 - You guessed: 61 - You win! - "#; - - let raw_lines = string.to_string(); - let lines = raw_lines.lines().map(|line| { - Ok(line.to_string()) - }); - - let result_vec = super::lint_lines(lines); - - assert!(result_vec.is_empty()); - } - - #[test] - fn is_file_of_interest_returns_false_when_the_path_is_a_directory() { - let uninteresting_fn = "src/img"; - - assert!(!super::is_file_of_interest(path::Path::new(uninteresting_fn))); - } - - #[test] - fn is_file_of_interest_returns_false_when_the_filename_does_not_have_the_md_extension() { - let uninteresting_fn = "src/img/foo1.png"; - - assert!(!super::is_file_of_interest(path::Path::new(uninteresting_fn))); - } - - #[test] - fn is_file_of_interest_returns_true_when_the_filename_has_the_md_extension() { - let interesting_fn = "src/ch01-00-introduction.md"; - - assert!(super::is_file_of_interest(path::Path::new(interesting_fn))); - } - - #[test] - fn is_line_of_interest_does_not_report_a_line_if_the_line_contains_a_file_url_which_is_directly_followed_by_the_project_path() { - let sample_line = "Compiling guessing_game v0.1.0 (file:///projects/guessing_game)"; - - assert!(!super::is_line_of_interest(sample_line)); - } - - #[test] - fn is_line_of_interest_reports_a_line_if_the_line_contains_a_file_url_which_is_not_directly_followed_by_the_project_path() { - let sample_line = "Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)"; - - assert!(super::is_line_of_interest(sample_line)); - } -} diff --git a/2018-edition/tools/src/bin/link2print.rs b/2018-edition/tools/src/bin/link2print.rs deleted file mode 100644 index 4fe4477b10..0000000000 --- a/2018-edition/tools/src/bin/link2print.rs +++ /dev/null @@ -1,406 +0,0 @@ -// FIXME: we have some long lines that could be refactored, but it's not a big deal. -// ignore-tidy-linelength - -extern crate regex; - -use std::collections::HashMap; -use std::io; -use std::io::{Read, Write}; -use regex::{Regex, Captures}; - -fn main() { - write_md(parse_links(parse_references(read_md()))); -} - -fn read_md() -> String { - let mut buffer = String::new(); - match io::stdin().read_to_string(&mut buffer) { - Ok(_) => buffer, - Err(error) => panic!(error), - } -} - -fn write_md(output: String) { - write!(io::stdout(), "{}", output).unwrap(); -} - -fn parse_references(buffer: String) -> (String, HashMap) { - let mut ref_map = HashMap::new(); - // FIXME: currently doesn't handle "title" in following line. - let re = Regex::new(r###"(?m)\n?^ {0,3}\[([^]]+)\]:[[:blank:]]*(.*)$"###).unwrap(); - let output = re.replace_all(&buffer, |caps: &Captures| { - let key = caps.at(1).unwrap().to_owned().to_uppercase(); - let val = caps.at(2).unwrap().to_owned(); - if ref_map.insert(key, val).is_some() { - panic!("Did not expect markdown page to have duplicate reference"); - } - "".to_string() - }); - (output, ref_map) -} - -fn parse_links((buffer, ref_map): (String, HashMap)) -> String { - // FIXME: check which punctuation is allowed by spec. - let re = Regex::new(r###"(?:(?P
(?:```(?:[^`]|`[^`])*`?\n```\n)|(?:[^[]`[^`\n]+[\n]?[^`\n]*`))|(?:\[(?P[^]]+)\](?:(?:\([[:blank:]]*(?P[^")]*[^ ])(?:[[:blank:]]*"[^"]*")?\))|(?:\[(?P[^]]*)\]))?))"###).expect("could not create regex");
-    let error_code = Regex::new(r###"^E\d{4}$"###).expect("could not create regex");
-    let output = re.replace_all(&buffer, |caps: &Captures| {
-        match caps.name("pre") {
-            Some(pre_section) => format!("{}", pre_section.to_owned()),
-            None => {
-                let name = caps.name("name").expect("could not get name").to_owned();
-                // Really we should ignore text inside code blocks,
-                // this is a hack to not try to treat `#[derive()]`,
-                // `[profile]`, `[test]`, or `[E\d\d\d\d]` like a link.
-                if name.starts_with("derive(") ||
-                   name.starts_with("profile") ||
-                   name.starts_with("test") ||
-                   error_code.is_match(&name) {
-                    return name
-                }
-
-                let val = match caps.name("val") {
-                    // `[name](link)`
-                    Some(value) => value.to_owned(),
-                    None => {
-                        match caps.name("key") {
-                            Some(key) => {
-                                match key {
-                                    // `[name][]`
-                                    "" => format!("{}", ref_map.get(&name.to_uppercase()).expect(&format!("could not find url for the link text `{}`", name))),
-                                    // `[name][reference]`
-                                    _ => format!("{}", ref_map.get(&key.to_uppercase()).expect(&format!("could not find url for the link text `{}`", key))),
-                                }
-                            }
-                            // `[name]` as reference
-                            None => format!("{}", ref_map.get(&name.to_uppercase()).expect(&format!("could not find url for the link text `{}`", name))),
-                        }
-                    }
-                };
-                format!("{} at *{}*", name, val)
-            }
-        }
-    });
-    output
-}
-
-#[cfg(test)]
-mod tests {
-    fn parse(source: String) -> String {
-        super::parse_links(super::parse_references(source))
-    }
-
-    #[test]
-    fn parses_inline_link() {
-        let source = r"This is a [link](http://google.com) that should be expanded".to_string();
-        let target = r"This is a link at *http://google.com* that should be expanded".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_multiline_links() {
-        let source = r"This is a [link](http://google.com) that
-should appear expanded. Another [location](/here/) and [another](http://gogogo)"
-            .to_string();
-        let target = r"This is a link at *http://google.com* that
-should appear expanded. Another location at */here/* and another at *http://gogogo*"
-            .to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_reference() {
-        let source = r"This is a [link][theref].
-[theref]: http://example.com/foo
-more text"
-            .to_string();
-        let target = r"This is a link at *http://example.com/foo*.
-more text"
-            .to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_implicit_link() {
-        let source = r"This is an [implicit][] link.
-[implicit]: /The Link/"
-            .to_string();
-        let target = r"This is an implicit at */The Link/* link.".to_string();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn parses_refs_with_one_space_indentation() {
-        let source = r"This is a [link][ref]
- [ref]: The link"
-            .to_string();
-        let target = r"This is a link at *The link*".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_refs_with_two_space_indentation() {
-        let source = r"This is a [link][ref]
-  [ref]: The link"
-            .to_string();
-        let target = r"This is a link at *The link*".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_refs_with_three_space_indentation() {
-        let source = r"This is a [link][ref]
-   [ref]: The link"
-            .to_string();
-        let target = r"This is a link at *The link*".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    #[should_panic]
-    fn rejects_refs_with_four_space_indentation() {
-        let source = r"This is a [link][ref]
-    [ref]: The link"
-            .to_string();
-        let target = r"This is a link at *The link*".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn ignores_optional_inline_title() {
-        let source = r###"This is a titled [link](http://example.com "My title")."###.to_string();
-        let target = r"This is a titled link at *http://example.com*.".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_title_with_puctuation() {
-        let source = r###"[link](http://example.com "It's Title")"###.to_string();
-        let target = r"link at *http://example.com*".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_name_with_punctuation() {
-        let source = r###"[I'm here](there)"###.to_string();
-        let target = r###"I'm here at *there*"###.to_string();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn parses_name_with_utf8() {
-        let source = r###"[user’s forum](the user’s forum)"###.to_string();
-        let target = r###"user’s forum at *the user’s forum*"###.to_string();
-        assert_eq!(parse(source), target);
-    }
-
-
-    #[test]
-    fn parses_reference_with_punctuation() {
-        let source = r###"[link][the ref-ref]
-[the ref-ref]:http://example.com/ref-ref"###
-            .to_string();
-        let target = r###"link at *http://example.com/ref-ref*"###.to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_reference_case_insensitively() {
-        let source = r"[link][Ref]
-[ref]: The reference"
-            .to_string();
-        let target = r"link at *The reference*".to_string();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn parses_link_as_reference_when_reference_is_empty() {
-        let source = r"[link as reference][]
-[link as reference]: the actual reference"
-            .to_string();
-        let target = r"link as reference at *the actual reference*".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_link_without_reference_as_reference() {
-        let source = r"[link] is alone
-[link]: The contents"
-            .to_string();
-        let target = r"link at *The contents* is alone".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    #[ignore]
-    fn parses_link_without_reference_as_reference_with_asterisks() {
-        let source = r"*[link]* is alone
-[link]: The contents"
-            .to_string();
-        let target = r"*link* at *The contents* is alone".to_string();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn ignores_links_in_pre_sections() {
-        let source = r###"```toml
-[package]
-name = "hello_cargo"
-version = "0.1.0"
-authors = ["Your Name "]
-
-[dependencies]
-```
-"###
-            .to_string();
-        let target = source.clone();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn ignores_links_in_quoted_sections() {
-        let source = r###"do not change `[package]`."###.to_string();
-        let target = source.clone();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn ignores_links_in_quoted_sections_containing_newlines() {
-        let source = r"do not change `this [package]
-is still here` [link](ref)"
-            .to_string();
-        let target = r"do not change `this [package]
-is still here` link at *ref*"
-            .to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn ignores_links_in_pre_sections_while_still_handling_links() {
-        let source = r###"```toml
-[package]
-name = "hello_cargo"
-version = "0.1.0"
-authors = ["Your Name "]
-
-[dependencies]
-```
-Another [link]
-more text
-[link]: http://gohere
-"###
-            .to_string();
-        let target = r###"```toml
-[package]
-name = "hello_cargo"
-version = "0.1.0"
-authors = ["Your Name "]
-
-[dependencies]
-```
-Another link at *http://gohere*
-more text
-"###
-            .to_string();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn ignores_quotes_in_pre_sections() {
-        let source = r###"```bash
-$ cargo build
-   Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
-src/main.rs:23:21: 23:35 error: mismatched types [E0308]
-src/main.rs:23     match guess.cmp(&secret_number) {
-                                   ^~~~~~~~~~~~~~
-src/main.rs:23:21: 23:35 help: run `rustc --explain E0308` to see a detailed explanation
-src/main.rs:23:21: 23:35 note: expected type `&std::string::String`
-src/main.rs:23:21: 23:35 note:    found type `&_`
-error: aborting due to previous error
-Could not compile `guessing_game`.
-```
-"###
-            .to_string();
-        let target = source.clone();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn ignores_short_quotes() {
-        let source = r"to `1` at index `[0]` i".to_string();
-        let target = source.clone();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn ignores_pre_sections_with_final_quote() {
-        let source = r###"```bash
-$ cargo run
-   Compiling points v0.1.0 (file:///projects/points)
-error: the trait bound `Point: std::fmt::Display` is not satisfied [--explain E0277]
- --> src/main.rs:8:29
-8 |>     println!("Point 1: {}", p1);
-  |>                             ^^
-:2:27: 2:58: note: in this expansion of format_args!
-:3:1: 3:54: note: in this expansion of print! (defined in )
-src/main.rs:8:5: 8:33: note: in this expansion of println! (defined in )
-note: `Point` cannot be formatted with the default formatter; try using `:?` instead if you are using a format string
-note: required by `std::fmt::Display::fmt`
-```
-`here` is another [link](the ref)
-"###.to_string();
-        let target = r###"```bash
-$ cargo run
-   Compiling points v0.1.0 (file:///projects/points)
-error: the trait bound `Point: std::fmt::Display` is not satisfied [--explain E0277]
- --> src/main.rs:8:29
-8 |>     println!("Point 1: {}", p1);
-  |>                             ^^
-:2:27: 2:58: note: in this expansion of format_args!
-:3:1: 3:54: note: in this expansion of print! (defined in )
-src/main.rs:8:5: 8:33: note: in this expansion of println! (defined in )
-note: `Point` cannot be formatted with the default formatter; try using `:?` instead if you are using a format string
-note: required by `std::fmt::Display::fmt`
-```
-`here` is another link at *the ref*
-"###.to_string();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn parses_adam_p_cheatsheet() {
-        let source = r###"[I'm an inline-style link](https://www.google.com)
-
-[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
-
-[I'm a reference-style link][Arbitrary case-insensitive reference text]
-
-[I'm a relative reference to a repository file](../blob/master/LICENSE)
-
-[You can use numbers for reference-style link definitions][1]
-
-Or leave it empty and use the [link text itself][].
-
-URLs and URLs in angle brackets will automatically get turned into links.
-http://www.example.com or  and sometimes
-example.com (but not on Github, for example).
-
-Some text to show that the reference links can follow later.
-
-[arbitrary case-insensitive reference text]: https://www.mozilla.org
-[1]: http://slashdot.org
-[link text itself]: http://www.reddit.com"###
-            .to_string();
-
-        let target = r###"I'm an inline-style link at *https://www.google.com*
-
-I'm an inline-style link with title at *https://www.google.com*
-
-I'm a reference-style link at *https://www.mozilla.org*
-
-I'm a relative reference to a repository file at *../blob/master/LICENSE*
-
-You can use numbers for reference-style link definitions at *http://slashdot.org*
-
-Or leave it empty and use the link text itself at *http://www.reddit.com*.
-
-URLs and URLs in angle brackets will automatically get turned into links.
-http://www.example.com or  and sometimes
-example.com (but not on Github, for example).
-
-Some text to show that the reference links can follow later.
-"###
-            .to_string();
-        assert_eq!(parse(source), target);
-    }
-}
diff --git a/2018-edition/tools/src/bin/remove_links.rs b/2018-edition/tools/src/bin/remove_links.rs
deleted file mode 100644
index 71c386106f..0000000000
--- a/2018-edition/tools/src/bin/remove_links.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-extern crate regex;
-
-use std::collections::HashSet;
-use std::io;
-use std::io::{Read, Write};
-use regex::{Regex, Captures};
-
-fn main () {
-    let mut buffer = String::new();
-    if let Err(e) = io::stdin().read_to_string(&mut buffer) {
-        panic!(e);
-    }
-
-    let mut refs = HashSet::new();
-
-    // Capture all links and link references.
-    let regex = r"\[([^\]]+)\](?:(?:\[([^\]]+)\])|(?:\([^\)]+\)))(?i)";
-    let link_regex = Regex::new(regex).unwrap();
-    let first_pass = link_regex.replace_all(&buffer, |caps: &Captures| {
-
-        // Save the link reference we want to delete.
-        if let Some(reference) = caps.at(2) {
-            refs.insert(reference.to_owned());
-        }
-
-        // Put the link title back.
-        caps.at(1).unwrap().to_owned()
-    });
-
-    // Search for the references we need to delete.
-    let ref_regex = Regex::new(r"\n\[([^\]]+)\]:\s.*\n").unwrap();
-    let out = ref_regex.replace_all(&first_pass, |caps: &Captures| {
-        let capture = caps.at(1).unwrap().to_owned();
-
-        // Check if we've marked this reference for deletion ...
-        if refs.contains(capture.as_str()) {
-            return "".to_string();
-        }
-
-        // ... else we put back everything we captured.
-        caps.at(0).unwrap().to_owned()
-    });
-
-    write!(io::stdout(), "{}", out).unwrap();
-}
diff --git a/2018-edition/tools/src/bin/remove_markup.rs b/2018-edition/tools/src/bin/remove_markup.rs
deleted file mode 100644
index be444bfd9a..0000000000
--- a/2018-edition/tools/src/bin/remove_markup.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-extern crate regex;
-
-use std::io;
-use std::io::{Read, Write};
-use regex::{Regex, Captures};
-
-fn main() {
-    write_md(remove_markup(read_md()));
-}
-
-fn read_md() -> String {
-    let mut buffer = String::new();
-    match io::stdin().read_to_string(&mut buffer) {
-        Ok(_) => buffer,
-        Err(error) => panic!(error),
-    }
-}
-
-fn write_md(output: String) {
-    write!(io::stdout(), "{}", output).unwrap();
-}
-
-fn remove_markup(input: String) -> String {
-    let filename_regex = Regex::new(r#"\A(.*)\z"#).unwrap();
-    // Captions sometimes take up multiple lines.
-    let caption_start_regex = Regex::new(r#"\A(.*)\z"#).unwrap();
-    let caption_end_regex = Regex::new(r#"(.*)\z"#).unwrap();
-    let regexen = vec![filename_regex, caption_start_regex, caption_end_regex];
-
-    let lines: Vec<_> = input.lines().flat_map(|line| {
-        // Remove our figure and caption markup.
-        if line == "
" || - line == "
" || - line == "
" || - line == "
" - { - None - // Remove our syntax highlighting and rustdoc markers. - } else if line.starts_with("```") { - Some(String::from("```")) - // Remove the span around filenames and captions. - } else { - let result = regexen.iter().fold(line.to_string(), |result, regex| { - regex.replace_all(&result, |caps: &Captures| { - caps.at(1).unwrap().to_owned() - }) - }); - Some(result) - } - }).collect(); - lines.join("\n") -} diff --git a/second-edition/Cargo.lock b/second-edition/Cargo.lock deleted file mode 100644 index 928f6b1244..0000000000 --- a/second-edition/Cargo.lock +++ /dev/null @@ -1,142 +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 = "docopt" -version = "0.6.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 0.2.10 (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.24 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.5.2 (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.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.33" -source = "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.33 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[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 = "rust-book" -version = "0.0.1" -dependencies = [ - "docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.10 (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.24 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc-serialize" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "strsim" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[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.33 (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 = "utf8-ranges" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "walkdir" -version = "0.1.8" -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)", - "winapi 0.2.8 (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 docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)" = "4a7ef30445607f6fc8720f0a0a2c7442284b629cf0d049286860fae23e71c4d9" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum lazy_static 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "236eb37a62591d4a41a89b7763d7de3e06ca02d5ab2815446a8bae5d2f8c2d57" -"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2" -"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" -"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.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" -"checksum strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "67f84c44fbb2f91db7fef94554e6b2ac05909c9c0b0bc23bb98d3a1aebfe7f7c" -"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 utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" -"checksum walkdir 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c66c0b9792f0a765345452775f3adbd28dde9d33f30d13e5dcc5ae17cf6f3780" -"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/second-edition/Cargo.toml b/second-edition/Cargo.toml deleted file mode 100644 index bb6763509f..0000000000 --- a/second-edition/Cargo.toml +++ /dev/null @@ -1,36 +0,0 @@ -[package] -name = "rust-book" -version = "0.0.1" -authors = ["Steve Klabnik "] -description = "The Rust Book" - -[[bin]] -name = "concat_chapters" -path = "tools/src/bin/concat_chapters.rs" - -[[bin]] -name = "lfp" -path = "tools/src/bin/lfp.rs" - -[[bin]] -name = "link2print" -path = "tools/src/bin/link2print.rs" - -[[bin]] -name = "remove_links" -path = "tools/src/bin/remove_links.rs" - -[[bin]] -name = "remove_markup" -path = "tools/src/bin/remove_markup.rs" - -[[bin]] -name = "convert_quotes" -path = "tools/src/bin/convert_quotes.rs" - -[dependencies] -walkdir = "0.1.5" -docopt = "0.6.82" -rustc-serialize = "0.3.19" -regex = "0.1.73" -lazy_static = "0.2.1" diff --git a/second-edition/LICENSE-APACHE b/second-edition/LICENSE-APACHE deleted file mode 100644 index 96e9f0458b..0000000000 --- a/second-edition/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright 2010-2017 The Rust Project Developers - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/second-edition/LICENSE-MIT b/second-edition/LICENSE-MIT deleted file mode 100644 index 5a56e6e8ed..0000000000 --- a/second-edition/LICENSE-MIT +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2010-2017 The Rust Project Developers - -Permission is hereby granted, free of charge, to any -person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the -Software without restriction, including without -limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/second-edition/convert-quotes.sh b/second-edition/convert-quotes.sh deleted file mode 100644 index aa51dcbddf..0000000000 --- a/second-edition/convert-quotes.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -set -eu - -dir=$1 - -mkdir -p "tmp/$dir" - -for f in $dir/*.md -do - cat "$f" | cargo run --bin convert_quotes > "tmp/$f" - mv "tmp/$f" "$f" -done diff --git a/second-edition/doc-to-md.sh b/second-edition/doc-to-md.sh deleted file mode 100644 index 170727db9f..0000000000 --- a/second-edition/doc-to-md.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -set -eu - -# Get all the docx files in the tmp dir. -ls tmp/*.docx | \ -# Extract just the filename so we can reuse it easily. -xargs -n 1 basename -s .docx | \ -while IFS= read -r filename; do - # Make a directory to put the XML in. - mkdir -p "tmp/$filename" - # Unzip the docx to get at the XML. - unzip -o "tmp/$filename.docx" -d "tmp/$filename" - # Convert to markdown with XSL. - xsltproc tools/docx-to-md.xsl "tmp/$filename/word/document.xml" | \ - # Hard wrap at 80 chars at word bourdaries. - fold -w 80 -s | \ - # Remove trailing whitespace and save in the `nostarch` dir for comparison. - sed -e "s/ *$//" > "nostarch/$filename.md" -done diff --git a/second-edition/nostarch.sh b/second-edition/nostarch.sh deleted file mode 100644 index 6c4173a01c..0000000000 --- a/second-edition/nostarch.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -set -eu - -cargo build --release - -mkdir -p tmp -rm -rf tmp/*.md - -# Get all the Markdown files in the src dir, -ls src/${1:-""}*.md | \ -# except for `SUMMARY.md`. -grep -v SUMMARY.md | \ -# Extract just the filename so we can reuse it easily. -xargs -n 1 basename | \ -# Remove all links followed by ```, then -# Change all remaining links from Markdown to italicized inline text. -while IFS= read -r filename; do - < "src/$filename" ./target/release/remove_links \ - | ./target/release/link2print \ - | ./target/release/remove_markup > "tmp/$filename" -done -# Concatenate the files into the `nostarch` dir. -./target/release/concat_chapters tmp nostarch diff --git a/second-edition/style-guide.md b/second-edition/style-guide.md deleted file mode 100644 index 56677811f4..0000000000 --- a/second-edition/style-guide.md +++ /dev/null @@ -1,34 +0,0 @@ -# Style Guide - -## Prose - -* Prefer title case for chapter/section headings, ex: `## Generating a Secret - Number` rather than `## Generating a secret number`. -* Prefer italics over single quotes when calling out a term, ex: `is an - *associated function* of` rather than `is an ‘associated function’ of`. -* When talking about a method in prose, DO NOT include the parentheses, ex: - `read_line` rather than `read_line()`. -* Hard wrap at 80 chars -* Prefer not mixing code and not-code in one word, ex: ``Remember when we wrote - `use std::io`?`` rather than ``Remember when we `use`d `std::io`?`` - -## Code - -* Add the file name before markdown blocks to make it clear which file we're - talking about, when applicable. -* When making changes to code, make it clear which parts of the code changed - and which stayed the same... not sure how to do this yet -* Split up long lines as appropriate to keep them under 80 chars if possible -* Use `bash` syntax highlighting for command line output code blocks - -## Links - -Once all the scripts are done: - -* If a link shouldn't be printed, mark it to be ignored - * This includes all "Chapter XX" intra-book links, which *should* be links - for the HTML version -* Make intra-book links and stdlib API doc links relative so they work whether - the book is read offline or on docs.rust-lang.org -* Use markdown links and keep in mind that they will be changed into `text at - *url*` in print, so word them in a way that it reads well in that format diff --git a/second-edition/tools/docx-to-md.xsl b/second-edition/tools/docx-to-md.xsl deleted file mode 100644 index 3b60bc34e4..0000000000 --- a/second-edition/tools/docx-to-md.xsl +++ /dev/null @@ -1,218 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - [TOC] - # - - - - - - ## - - - - - - ### - - - - - - #### - - - - - - ### - - - - - - 1. - - - - - - 1. - - - - - - * - - - - - - * - - - - - - * - - - - - - - - - - - - - ``` - - - - - - - - - - - - - - - - - - - - - ``` - - - - ``` - - ``` - - - - - - - - - - - - - - > - - - - - - > - - - - - - > - - - - - -Unmatched: - - - - - - - - - - - - - - - ` - - ` - - - - - - - - - - - - - - - - - ** - - ** - - - - - - - - - - - - - - - - - * - - * - - - - - - - - - - - - - - diff --git a/second-edition/tools/src/bin/concat_chapters.rs b/second-edition/tools/src/bin/concat_chapters.rs deleted file mode 100644 index da02dd34b4..0000000000 --- a/second-edition/tools/src/bin/concat_chapters.rs +++ /dev/null @@ -1,104 +0,0 @@ -#[macro_use] extern crate lazy_static; -extern crate regex; - -use std::env; -use std::io; -use std::io::{Read, Write}; -use std::process::exit; -use std::fs::{create_dir, read_dir, File}; -use std::path::{Path, PathBuf}; -use std::collections::BTreeMap; - -use regex::Regex; - -static PATTERNS: &'static [(&'static str, &'static str)] = &[ - (r"ch(\d\d)-\d\d-.*\.md", "chapter$1.md"), - (r"appendix-(\d\d).*\.md", "appendix.md"), -]; - -lazy_static! { - static ref MATCHERS: Vec<(Regex, &'static str)> = { - PATTERNS.iter() - .map(|&(expr, repl)| (Regex::new(expr).unwrap(), repl)) - .collect() - }; -} - -fn main() { - let args: Vec = env::args().collect(); - - if args.len() < 3 { - println!("Usage: {} ", args[0]); - exit(1); - } - - let source_dir = ensure_dir_exists(&args[1]).unwrap(); - let target_dir = ensure_dir_exists(&args[2]).unwrap(); - - let mut matched_files = match_files(source_dir, target_dir); - matched_files.sort(); - - for (target_path, source_paths) in group_by_target(matched_files) { - concat_files(source_paths, target_path).unwrap(); - } -} - -fn match_files(source_dir: &Path, target_dir: &Path) -> Vec<(PathBuf, PathBuf)> { - read_dir(source_dir) - .expect("Unable to read source directory") - .filter_map(|maybe_entry| maybe_entry.ok()) - .filter_map(|entry| { - let source_filename = entry.file_name(); - let source_filename = &source_filename.to_string_lossy().into_owned(); - for &(ref regex, replacement) in MATCHERS.iter() { - if regex.is_match(source_filename) { - let target_filename = regex.replace_all(source_filename, replacement); - let source_path = entry.path(); - let mut target_path = PathBuf::from(&target_dir); - target_path.push(target_filename); - return Some((source_path, target_path)); - } - } - None - }) - .collect() -} - -fn group_by_target(matched_files: Vec<(PathBuf, PathBuf)>) -> BTreeMap> { - let mut grouped: BTreeMap> = BTreeMap::new(); - for (source, target) in matched_files { - if let Some(source_paths) = grouped.get_mut(&target) { - source_paths.push(source); - continue; - } - let source_paths = vec![source]; - grouped.insert(target.clone(), source_paths); - } - grouped -} - -fn concat_files(source_paths: Vec, target_path: PathBuf) -> io::Result<()> { - println!("Concatenating into {}:", target_path.to_string_lossy()); - let mut target = try!(File::create(target_path)); - try!(target.write_all(b"\n[TOC]\n")); - - for path in source_paths { - println!(" {}", path.to_string_lossy()); - let mut source = try!(File::open(path)); - let mut contents: Vec = Vec::new(); - try!(source.read_to_end(&mut contents)); - - try!(target.write_all(b"\n")); - try!(target.write_all(&contents)); - try!(target.write_all(b"\n")); - } - Ok(()) -} - -fn ensure_dir_exists(dir_string: &str) -> io::Result<&Path> { - let path = Path::new(dir_string); - if !path.exists() { - try!(create_dir(path)); - } - Ok(&path) -} diff --git a/second-edition/tools/src/bin/convert_quotes.rs b/second-edition/tools/src/bin/convert_quotes.rs deleted file mode 100644 index c1e38dac87..0000000000 --- a/second-edition/tools/src/bin/convert_quotes.rs +++ /dev/null @@ -1,73 +0,0 @@ -use std::io; -use std::io::{Read, Write}; - -fn main() { - let mut is_in_code_block = false; - let mut is_in_inline_code = false; - let mut is_in_html_tag = false; - - let mut buffer = String::new(); - if let Err(e) = io::stdin().read_to_string(&mut buffer) { - panic!(e); - } - - for line in buffer.lines() { - if line.is_empty() { - is_in_inline_code = false; - } - if line.starts_with("```") { - is_in_code_block = !is_in_code_block; - } - if is_in_code_block { - is_in_inline_code = false; - is_in_html_tag = false; - write!(io::stdout(), "{}\n", line).unwrap(); - } else { - let mut modified_line = &mut String::new(); - let mut previous_char = std::char::REPLACEMENT_CHARACTER; - let mut chars_in_line = line.chars(); - - while let Some(possible_match) = chars_in_line.next() { - // Check if inside inline code. - if possible_match == '`' { - is_in_inline_code = !is_in_inline_code; - } - // Check if inside HTML tag. - if possible_match == '<' && !is_in_inline_code { - is_in_html_tag = true; - } - if possible_match == '>' && !is_in_inline_code { - is_in_html_tag = false; - } - - // Replace with right/left apostrophe/quote. - let char_to_push = - if possible_match == '\'' && !is_in_inline_code && !is_in_html_tag { - if (previous_char != std::char::REPLACEMENT_CHARACTER && - !previous_char.is_whitespace()) || - previous_char == '‘' - { - '’' - } else { - '‘' - } - } else if possible_match == '"' && !is_in_inline_code && !is_in_html_tag { - if (previous_char != std::char::REPLACEMENT_CHARACTER && - !previous_char.is_whitespace()) || - previous_char == '“' - { - '”' - } else { - '“' - } - } else { - // Leave untouched. - possible_match - }; - modified_line.push(char_to_push); - previous_char = char_to_push; - } - write!(io::stdout(), "{}\n", modified_line).unwrap(); - } - } -} diff --git a/second-edition/tools/src/bin/lfp.rs b/second-edition/tools/src/bin/lfp.rs deleted file mode 100644 index e5ee356944..0000000000 --- a/second-edition/tools/src/bin/lfp.rs +++ /dev/null @@ -1,242 +0,0 @@ -// We have some long regex literals, so: -// ignore-tidy-linelength - -extern crate rustc_serialize; -extern crate docopt; -use docopt::Docopt; -extern crate walkdir; -use std::{path, fs, io}; -use std::io::{BufRead, Write}; - -fn main () { - let args: Args = Docopt::new(USAGE) - .and_then(|d| d.decode()) - .unwrap_or_else(|e| e.exit()); - - let src_dir = &path::Path::new(&args.arg_src_dir); - let found_errs = walkdir::WalkDir::new(src_dir) - .min_depth(1) - .into_iter() - .map(|entry| { - match entry { - Ok(entry) => entry, - Err(err) => { - eprintln!("{:?}", err); - std::process::exit(911) - }, - } - }) - .map(|entry| { - let path = entry.path(); - if is_file_of_interest(path) { - let err_vec = lint_file(path); - for err in &err_vec { - match *err { - LintingError::LineOfInterest(line_num, ref line) => - eprintln!("{}:{}\t{}", path.display(), line_num, line), - LintingError::UnableToOpenFile => - eprintln!("Unable to open {}.", path.display()), - } - } - !err_vec.is_empty() - } else { - false - } - }) - .collect::>() - .iter() - .any(|result| *result); - - if found_errs { - std::process::exit(1) - } else { - std::process::exit(0) - } -} - -const USAGE: &'static str = " -counter -Usage: - lfp - lfp (-h | --help) -Options: - -h --help Show this screen. -"; - -#[derive(Debug, RustcDecodable)] -struct Args { - arg_src_dir: String, -} - -fn lint_file(path: &path::Path) -> Vec { - match fs::File::open(path) { - Ok(file) => lint_lines(io::BufReader::new(&file).lines()), - Err(_) => vec![LintingError::UnableToOpenFile], - } -} - -fn lint_lines(lines: I) -> Vec - where I: Iterator> { - lines - .enumerate() - .map(|(line_num, line)| { - let raw_line = line.unwrap(); - if is_line_of_interest(&raw_line) { - Err(LintingError::LineOfInterest(line_num, raw_line)) - } else { - Ok(()) - } - }) - .filter(|result| result.is_err()) - .map(|result| result.unwrap_err()) - .collect() -} - -fn is_file_of_interest(path: &path::Path) -> bool { - path.extension() - .map_or(false, |ext| ext == "md") -} - -fn is_line_of_interest(line: &str) -> bool { - !line.split_whitespace() - .filter(|sub_string| - sub_string.contains("file://") && - !sub_string.contains("file:///projects/") - ) - .collect::>() - .is_empty() -} - -#[derive(Debug)] -enum LintingError { - UnableToOpenFile, - LineOfInterest(usize, String) -} - -#[cfg(test)] -mod tests { - - use std::path; - - #[test] - fn lint_file_returns_a_vec_with_errs_when_lines_of_interest_are_found() { - let string = r#" - $ cargo run - Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game) - Running `target/guessing_game` - Guess the number! - The secret number is: 61 - Please input your guess. - 10 - You guessed: 10 - Too small! - Please input your guess. - 99 - You guessed: 99 - Too big! - Please input your guess. - foo - Please input your guess. - 61 - You guessed: 61 - You win! - $ cargo run - Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game) - Running `target/debug/guessing_game` - Guess the number! - The secret number is: 7 - Please input your guess. - 4 - You guessed: 4 - $ cargo run - Running `target/debug/guessing_game` - Guess the number! - The secret number is: 83 - Please input your guess. - 5 - $ cargo run - Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game) - Running `target/debug/guessing_game` - Hello, world! - "#; - - let raw_lines = string.to_string(); - let lines = raw_lines.lines().map(|line| { - Ok(line.to_string()) - }); - - let result_vec = super::lint_lines(lines); - - assert!(!result_vec.is_empty()); - assert_eq!(3, result_vec.len()); - } - - #[test] - fn lint_file_returns_an_empty_vec_when_no_lines_of_interest_are_found() { - let string = r#" - $ cargo run - Compiling guessing_game v0.1.0 (file:///projects/guessing_game) - Running `target/guessing_game` - Guess the number! - The secret number is: 61 - Please input your guess. - 10 - You guessed: 10 - Too small! - Please input your guess. - 99 - You guessed: 99 - Too big! - Please input your guess. - foo - Please input your guess. - 61 - You guessed: 61 - You win! - "#; - - let raw_lines = string.to_string(); - let lines = raw_lines.lines().map(|line| { - Ok(line.to_string()) - }); - - let result_vec = super::lint_lines(lines); - - assert!(result_vec.is_empty()); - } - - #[test] - fn is_file_of_interest_returns_false_when_the_path_is_a_directory() { - let uninteresting_fn = "src/img"; - - assert!(!super::is_file_of_interest(path::Path::new(uninteresting_fn))); - } - - #[test] - fn is_file_of_interest_returns_false_when_the_filename_does_not_have_the_md_extension() { - let uninteresting_fn = "src/img/foo1.png"; - - assert!(!super::is_file_of_interest(path::Path::new(uninteresting_fn))); - } - - #[test] - fn is_file_of_interest_returns_true_when_the_filename_has_the_md_extension() { - let interesting_fn = "src/ch01-00-introduction.md"; - - assert!(super::is_file_of_interest(path::Path::new(interesting_fn))); - } - - #[test] - fn is_line_of_interest_does_not_report_a_line_if_the_line_contains_a_file_url_which_is_directly_followed_by_the_project_path() { - let sample_line = "Compiling guessing_game v0.1.0 (file:///projects/guessing_game)"; - - assert!(!super::is_line_of_interest(sample_line)); - } - - #[test] - fn is_line_of_interest_reports_a_line_if_the_line_contains_a_file_url_which_is_not_directly_followed_by_the_project_path() { - let sample_line = "Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)"; - - assert!(super::is_line_of_interest(sample_line)); - } -} diff --git a/second-edition/tools/src/bin/link2print.rs b/second-edition/tools/src/bin/link2print.rs deleted file mode 100644 index 26f40c84b4..0000000000 --- a/second-edition/tools/src/bin/link2print.rs +++ /dev/null @@ -1,406 +0,0 @@ -// FIXME: we have some long lines that could be refactored, but it's not a big deal. -// ignore-tidy-linelength - -extern crate regex; - -use std::collections::HashMap; -use std::io; -use std::io::{Read, Write}; -use regex::{Regex, Captures}; - -fn main() { - write_md(parse_links(parse_references(read_md()))); -} - -fn read_md() -> String { - let mut buffer = String::new(); - match io::stdin().read_to_string(&mut buffer) { - Ok(_) => buffer, - Err(error) => panic!(error), - } -} - -fn write_md(output: String) { - write!(io::stdout(), "{}", output).unwrap(); -} - -fn parse_references(buffer: String) -> (String, HashMap) { - let mut ref_map = HashMap::new(); - // FIXME: currently doesn't handle "title" in following line. - let re = Regex::new(r###"(?m)\n?^ {0,3}\[([^]]+)\]:[[:blank:]]*(.*)$"###).unwrap(); - let output = re.replace_all(&buffer, |caps: &Captures| { - let key = caps.at(1).unwrap().to_owned().to_uppercase(); - let val = caps.at(2).unwrap().to_owned(); - if ref_map.insert(key, val).is_some() { - panic!("Did not expect markdown page to have duplicate reference"); - } - "".to_string() - }); - (output, ref_map) -} - -fn parse_links((buffer, ref_map): (String, HashMap)) -> String { - // FIXME: check which punctuation is allowed by spec. - let re = Regex::new(r###"(?:(?P
(?:```(?:[^`]|`[^`])*`?\n```\n)|(?:[^[]`[^`\n]+[\n]?[^`\n]*`))|(?:\[(?P[^]]+)\](?:(?:\([[:blank:]]*(?P[^")]*[^ ])(?:[[:blank:]]*"[^"]*")?\))|(?:\[(?P[^]]*)\]))?))"###).expect("could not create regex");
-    let error_code = Regex::new(r###"^E\d{4}$"###).expect("could not create regex");
-    let output = re.replace_all(&buffer, |caps: &Captures| {
-        match caps.name("pre") {
-            Some(pre_section) => format!("{}", pre_section.to_owned()),
-            None => {
-                let name = caps.name("name").expect("could not get name").to_owned();
-                // Really we should ignore text inside code blocks,
-                // this is a hack to not try to treat `#[derive()]`,
-                // `[profile]`, `[test]`, or `[E\d\d\d\d]` like a link.
-                if name.starts_with("derive(") ||
-                   name.starts_with("profile") ||
-                   name.starts_with("test") ||
-                   error_code.is_match(&name) {
-                    return name
-                }
-
-                let val = match caps.name("val") {
-                    // `[name](link)`
-                    Some(value) => value.to_owned(),
-                    None => {
-                        match caps.name("key") {
-                            Some(key) => {
-                                match key {
-                                    // [name][]
-                                    "" => format!("{}", ref_map.get(&name.to_uppercase()).expect(&format!("could not find url for the link text `{}`", name))),
-                                    // [name][reference]
-                                    _ => format!("{}", ref_map.get(&key.to_uppercase()).expect(&format!("could not find url for the link text `{}`", key))),
-                                }
-                            }
-                            // `[name]` as reference
-                            None => format!("{}", ref_map.get(&name.to_uppercase()).expect(&format!("could not find url for the link text `{}`", name))),
-                        }
-                    }
-                };
-                format!("{} at *{}*", name, val)
-            }
-        }
-    });
-    output
-}
-
-#[cfg(test)]
-mod tests {
-    fn parse(source: String) -> String {
-        super::parse_links(super::parse_references(source))
-    }
-
-    #[test]
-    fn parses_inline_link() {
-        let source = r"This is a [link](http://google.com) that should be expanded".to_string();
-        let target = r"This is a link at *http://google.com* that should be expanded".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_multiline_links() {
-        let source = r"This is a [link](http://google.com) that
-should appear expanded. Another [location](/here/) and [another](http://gogogo)"
-            .to_string();
-        let target = r"This is a link at *http://google.com* that
-should appear expanded. Another location at */here/* and another at *http://gogogo*"
-            .to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_reference() {
-        let source = r"This is a [link][theref].
-[theref]: http://example.com/foo
-more text"
-            .to_string();
-        let target = r"This is a link at *http://example.com/foo*.
-more text"
-            .to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_implicit_link() {
-        let source = r"This is an [implicit][] link.
-[implicit]: /The Link/"
-            .to_string();
-        let target = r"This is an implicit at */The Link/* link.".to_string();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn parses_refs_with_one_space_indentation() {
-        let source = r"This is a [link][ref]
- [ref]: The link"
-            .to_string();
-        let target = r"This is a link at *The link*".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_refs_with_two_space_indentation() {
-        let source = r"This is a [link][ref]
-  [ref]: The link"
-            .to_string();
-        let target = r"This is a link at *The link*".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_refs_with_three_space_indentation() {
-        let source = r"This is a [link][ref]
-   [ref]: The link"
-            .to_string();
-        let target = r"This is a link at *The link*".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    #[should_panic]
-    fn rejects_refs_with_four_space_indentation() {
-        let source = r"This is a [link][ref]
-    [ref]: The link"
-            .to_string();
-        let target = r"This is a link at *The link*".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn ignores_optional_inline_title() {
-        let source = r###"This is a titled [link](http://example.com "My title")."###.to_string();
-        let target = r"This is a titled link at *http://example.com*.".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_title_with_puctuation() {
-        let source = r###"[link](http://example.com "It's Title")"###.to_string();
-        let target = r"link at *http://example.com*".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_name_with_punctuation() {
-        let source = r###"[I'm here](there)"###.to_string();
-        let target = r###"I'm here at *there*"###.to_string();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn parses_name_with_utf8() {
-        let source = r###"[user’s forum](the user’s forum)"###.to_string();
-        let target = r###"user’s forum at *the user’s forum*"###.to_string();
-        assert_eq!(parse(source), target);
-    }
-
-
-    #[test]
-    fn parses_reference_with_punctuation() {
-        let source = r###"[link][the ref-ref]
-[the ref-ref]:http://example.com/ref-ref"###
-            .to_string();
-        let target = r###"link at *http://example.com/ref-ref*"###.to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_reference_case_insensitively() {
-        let source = r"[link][Ref]
-[ref]: The reference"
-            .to_string();
-        let target = r"link at *The reference*".to_string();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn parses_link_as_reference_when_reference_is_empty() {
-        let source = r"[link as reference][]
-[link as reference]: the actual reference"
-            .to_string();
-        let target = r"link as reference at *the actual reference*".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn parses_link_without_reference_as_reference() {
-        let source = r"[link] is alone
-[link]: The contents"
-            .to_string();
-        let target = r"link at *The contents* is alone".to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    #[ignore]
-    fn parses_link_without_reference_as_reference_with_asterisks() {
-        let source = r"*[link]* is alone
-[link]: The contents"
-            .to_string();
-        let target = r"*link* at *The contents* is alone".to_string();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn ignores_links_in_pre_sections() {
-        let source = r###"```toml
-[package]
-name = "hello_cargo"
-version = "0.1.0"
-authors = ["Your Name "]
-
-[dependencies]
-```
-"###
-            .to_string();
-        let target = source.clone();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn ignores_links_in_quoted_sections() {
-        let source = r###"do not change `[package]`."###.to_string();
-        let target = source.clone();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn ignores_links_in_quoted_sections_containing_newlines() {
-        let source = r"do not change `this [package]
-is still here` [link](ref)"
-            .to_string();
-        let target = r"do not change `this [package]
-is still here` link at *ref*"
-            .to_string();
-        assert_eq!(parse(source), target);
-    }
-
-    #[test]
-    fn ignores_links_in_pre_sections_while_still_handling_links() {
-        let source = r###"```toml
-[package]
-name = "hello_cargo"
-version = "0.1.0"
-authors = ["Your Name "]
-
-[dependencies]
-```
-Another [link]
-more text
-[link]: http://gohere
-"###
-            .to_string();
-        let target = r###"```toml
-[package]
-name = "hello_cargo"
-version = "0.1.0"
-authors = ["Your Name "]
-
-[dependencies]
-```
-Another link at *http://gohere*
-more text
-"###
-            .to_string();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn ignores_quotes_in_pre_sections() {
-        let source = r###"```bash
-$ cargo build
-   Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
-src/main.rs:23:21: 23:35 error: mismatched types [E0308]
-src/main.rs:23     match guess.cmp(&secret_number) {
-                                   ^~~~~~~~~~~~~~
-src/main.rs:23:21: 23:35 help: run `rustc --explain E0308` to see a detailed explanation
-src/main.rs:23:21: 23:35 note: expected type `&std::string::String`
-src/main.rs:23:21: 23:35 note:    found type `&_`
-error: aborting due to previous error
-Could not compile `guessing_game`.
-```
-"###
-            .to_string();
-        let target = source.clone();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn ignores_short_quotes() {
-        let source = r"to `1` at index `[0]` i".to_string();
-        let target = source.clone();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn ignores_pre_sections_with_final_quote() {
-        let source = r###"```bash
-$ cargo run
-   Compiling points v0.1.0 (file:///projects/points)
-error: the trait bound `Point: std::fmt::Display` is not satisfied [--explain E0277]
- --> src/main.rs:8:29
-8 |>     println!("Point 1: {}", p1);
-  |>                             ^^
-:2:27: 2:58: note: in this expansion of format_args!
-:3:1: 3:54: note: in this expansion of print! (defined in )
-src/main.rs:8:5: 8:33: note: in this expansion of println! (defined in )
-note: `Point` cannot be formatted with the default formatter; try using `:?` instead if you are using a format string
-note: required by `std::fmt::Display::fmt`
-```
-`here` is another [link](the ref)
-"###.to_string();
-        let target = r###"```bash
-$ cargo run
-   Compiling points v0.1.0 (file:///projects/points)
-error: the trait bound `Point: std::fmt::Display` is not satisfied [--explain E0277]
- --> src/main.rs:8:29
-8 |>     println!("Point 1: {}", p1);
-  |>                             ^^
-:2:27: 2:58: note: in this expansion of format_args!
-:3:1: 3:54: note: in this expansion of print! (defined in )
-src/main.rs:8:5: 8:33: note: in this expansion of println! (defined in )
-note: `Point` cannot be formatted with the default formatter; try using `:?` instead if you are using a format string
-note: required by `std::fmt::Display::fmt`
-```
-`here` is another link at *the ref*
-"###.to_string();
-        assert_eq!(parse(source), target);
-    }
-    #[test]
-    fn parses_adam_p_cheatsheet() {
-        let source = r###"[I'm an inline-style link](https://www.google.com)
-
-[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
-
-[I'm a reference-style link][Arbitrary case-insensitive reference text]
-
-[I'm a relative reference to a repository file](../blob/master/LICENSE)
-
-[You can use numbers for reference-style link definitions][1]
-
-Or leave it empty and use the [link text itself][].
-
-URLs and URLs in angle brackets will automatically get turned into links.
-http://www.example.com or  and sometimes
-example.com (but not on Github, for example).
-
-Some text to show that the reference links can follow later.
-
-[arbitrary case-insensitive reference text]: https://www.mozilla.org
-[1]: http://slashdot.org
-[link text itself]: http://www.reddit.com"###
-            .to_string();
-
-        let target = r###"I'm an inline-style link at *https://www.google.com*
-
-I'm an inline-style link with title at *https://www.google.com*
-
-I'm a reference-style link at *https://www.mozilla.org*
-
-I'm a relative reference to a repository file at *../blob/master/LICENSE*
-
-You can use numbers for reference-style link definitions at *http://slashdot.org*
-
-Or leave it empty and use the link text itself at *http://www.reddit.com*.
-
-URLs and URLs in angle brackets will automatically get turned into links.
-http://www.example.com or  and sometimes
-example.com (but not on Github, for example).
-
-Some text to show that the reference links can follow later.
-"###
-            .to_string();
-        assert_eq!(parse(source), target);
-    }
-}
diff --git a/second-edition/tools/src/bin/remove_links.rs b/second-edition/tools/src/bin/remove_links.rs
deleted file mode 100644
index 0ea88639a8..0000000000
--- a/second-edition/tools/src/bin/remove_links.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-extern crate regex;
-
-use std::io;
-use std::io::{Read, Write};
-use regex::{Regex, Captures};
-use std::collections::HashSet;
-
-fn main () {
-    let mut buffer = String::new();
-    if let Err(e) = io::stdin().read_to_string(&mut buffer) {
-        panic!(e);
-    }
-
-    let mut refs = HashSet::new();
-
-    // Capture all links and link references.
-    let regex = r"\[([^\]]+)\](?:(?:\[([^\]]+)\])|(?:\([^\)]+\)))(?i)";
-    let link_regex = Regex::new(regex).unwrap();
-    let first_pass = link_regex.replace_all(&buffer, |caps: &Captures| {
-
-        // Save the link reference we want to delete.
-        if let Some(reference) = caps.at(2) {
-            refs.insert(reference.to_owned());
-        }
-
-        // Put the link title back.
-        caps.at(1).unwrap().to_owned()
-    });
-
-    // Search for the references we need to delete.
-    let ref_regex = Regex::new(r"\n\[([^\]]+)\]:\s.*\n").unwrap();
-    let out = ref_regex.replace_all(&first_pass, |caps: &Captures| {
-        let capture = caps.at(1).unwrap().to_owned();
-
-        // Check if we've marked this reference for deletion ...
-        if refs.contains(capture.as_str()) {
-            return "".to_string();
-        }
-
-        // ... else we put back everything we captured.
-        caps.at(0).unwrap().to_owned()
-    });
-
-    write!(io::stdout(), "{}", out).unwrap();
-}
diff --git a/second-edition/tools/src/bin/remove_markup.rs b/second-edition/tools/src/bin/remove_markup.rs
deleted file mode 100644
index be444bfd9a..0000000000
--- a/second-edition/tools/src/bin/remove_markup.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-extern crate regex;
-
-use std::io;
-use std::io::{Read, Write};
-use regex::{Regex, Captures};
-
-fn main() {
-    write_md(remove_markup(read_md()));
-}
-
-fn read_md() -> String {
-    let mut buffer = String::new();
-    match io::stdin().read_to_string(&mut buffer) {
-        Ok(_) => buffer,
-        Err(error) => panic!(error),
-    }
-}
-
-fn write_md(output: String) {
-    write!(io::stdout(), "{}", output).unwrap();
-}
-
-fn remove_markup(input: String) -> String {
-    let filename_regex = Regex::new(r#"\A(.*)\z"#).unwrap();
-    // Captions sometimes take up multiple lines.
-    let caption_start_regex = Regex::new(r#"\A(.*)\z"#).unwrap();
-    let caption_end_regex = Regex::new(r#"(.*)\z"#).unwrap();
-    let regexen = vec![filename_regex, caption_start_regex, caption_end_regex];
-
-    let lines: Vec<_> = input.lines().flat_map(|line| {
-        // Remove our figure and caption markup.
-        if line == "
" || - line == "
" || - line == "
" || - line == "
" - { - None - // Remove our syntax highlighting and rustdoc markers. - } else if line.starts_with("```") { - Some(String::from("```")) - // Remove the span around filenames and captions. - } else { - let result = regexen.iter().fold(line.to_string(), |result, regex| { - regex.replace_all(&result, |caps: &Captures| { - caps.at(1).unwrap().to_owned() - }) - }); - Some(result) - } - }).collect(); - lines.join("\n") -}