Skip to content

Extract code into external files #1949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
69ce10e
Set cargo new config vars to placeholders for example projects
carols10cents Apr 23, 2019
d3adad7
Extract code listings to separate files
carols10cents Mar 26, 2019
2ccaaa5
DO NOT MERGE POINTS TO MY MDBOOK FORK
carols10cents Aug 26, 2019
f3ad37d
Script to generate release artifact of just the listings
carols10cents Sep 25, 2019
e676364
Document that the code listings are available on the releases tab
carols10cents Sep 29, 2019
6c79ebc
Remove code that handles figure/figcaption markup; we don't use that …
carols10cents Sep 29, 2019
8b16a0b
Remove unused import
carols10cents Sep 29, 2019
25108e8
Alphabetize bins
carols10cents Sep 29, 2019
6e14a3c
Include code without hidden lines for nostarch files
carols10cents Sep 30, 2019
a7bce94
Merge remote-tracking branch 'origin/master' into extract-files
carols10cents Sep 30, 2019
5314c4b
Correct path to mdbook binary
carols10cents Sep 30, 2019
6adf9d5
Renumber some listings already 😂
carols10cents Oct 1, 2019
28a41b0
Include output in listings and have a script for regenerating
carols10cents Oct 1, 2019
4881c2a
Renumber listings again
carols10cents Oct 5, 2019
3180d42
Extract more output, include the command used
carols10cents Oct 5, 2019
9bcb587
Handle case where existing output might not have a compile time
carols10cents Oct 5, 2019
1b62fa2
Update some output
carols10cents Oct 5, 2019
d359ec5
Do some manual regeneration for examples with user input
carols10cents Oct 6, 2019
96caa31
Merge remote-tracking branch 'origin/master' into extract-files
carols10cents Oct 6, 2019
cba6778
poop
carols10cents Oct 6, 2019
4f7928e
Merge remote-tracking branch 'origin/master' into extract-files
carols10cents Oct 6, 2019
f0d503c
Remove a command that's included in the output file now
carols10cents Oct 6, 2019
a131562
Leave a note to remind me of a thought later
carols10cents Oct 6, 2019
1a896c2
Regenerate some output manually and save instructions
carols10cents Oct 6, 2019
2cdb18b
Extract more output and handle unsuccessful commands
carols10cents Oct 6, 2019
7fb88da
Do some more manual regeneration
carols10cents Oct 6, 2019
894ec2f
Suppress output of cd -
carols10cents Oct 7, 2019
2be4ade
More extracting and updating of output
carols10cents Oct 7, 2019
11aa1de
Don't remove directory in tmp after generating listings
carols10cents Oct 7, 2019
0b05811
Don't include the output files I'm adding in the listings artifact
carols10cents Oct 7, 2019
2ef9fae
Use release artifacts to build output so anchor comments are excluded
carols10cents Oct 7, 2019
d4e40fe
Extract and update more output
carols10cents Oct 7, 2019
f7784e6
Create a new kind of listing only used to generate output
carols10cents Oct 10, 2019
cf433f9
Extract and update more output
carols10cents Oct 10, 2019
49d0a35
Extract even more output
carols10cents Oct 21, 2019
6a87335
Unignoring an example that works now
carols10cents Oct 23, 2019
c6fc22c
Project names can contain hyphens and numbers too
carols10cents Oct 28, 2019
339d04c
Extract even more and more output
carols10cents Oct 23, 2019
095dfcf
Merge remote-tracking branch 'origin/master' into extract-files
carols10cents Jan 6, 2020
c92d591
Allow dead_code to reduce warnings in automated output
carols10cents Jan 8, 2020
9fec2cf
Make test output more predictable by only using one thread
carols10cents Jan 8, 2020
46d02a4
Extract even more output
carols10cents Jan 6, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[cargo-new]
name = "Your Name"
email = "[email protected]"
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ addons:
- aspell
- aspell-en
before_script:
- (cargo install mdbook --vers 0.2.3 --force || true)
- (cargo install mdbook --git https://github.com/integer32llc/mdBook.git --branch rustdoc_include --force || true)
script:
- bash ci/build.sh
121 changes: 121 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ edition = "2018"
name = "concat_chapters"
path = "tools/src/bin/concat_chapters.rs"

[[bin]]
name = "convert_quotes"
path = "tools/src/bin/convert_quotes.rs"

[[bin]]
name = "lfp"
path = "tools/src/bin/lfp.rs"
Expand All @@ -17,6 +21,14 @@ path = "tools/src/bin/lfp.rs"
name = "link2print"
path = "tools/src/bin/link2print.rs"

[[bin]]
name = "release_listings"
path = "tools/src/bin/release_listings.rs"

[[bin]]
name = "remove_hidden_lines"
path = "tools/src/bin/remove_hidden_lines.rs"

[[bin]]
name = "remove_links"
path = "tools/src/bin/remove_links.rs"
Expand All @@ -25,13 +37,11 @@ path = "tools/src/bin/remove_links.rs"
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"
flate2 = "1.0"
tar = "0.4.16"
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This repository contains the source of "The Rust Programming Language" book.

[The book is available in dead-tree form from No Starch Press][nostarch]
[The book is available in dead-tree form from No Starch Press][nostarch].

[nostarch]: https://nostarch.com/rust

Expand All @@ -17,6 +17,10 @@ releases are updated less frequently.
[beta]: https://doc.rust-lang.org/beta/book/
[nightly]: https://doc.rust-lang.org/nightly/book/

See the [releases] to download just the code of all the code listings that appear in the book.

[releases]: https://github.com/rust-lang/book/releases

## Requirements

Building the book requires [mdBook], ideally the same 0.3.x version that
Expand Down
6 changes: 6 additions & 0 deletions listings/ch02-guessing-game-tutorial/listing-02-01/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions listings/ch02-guessing-game-tutorial/listing-02-01/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "guessing_game"
version = "0.1.0"
authors = ["Your Name <[email protected]>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
14 changes: 14 additions & 0 deletions listings/ch02-guessing-game-tutorial/listing-02-01/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::io;

fn main() {
println!("Guess the number!");

println!("Please input your guess.");

let mut guess = String::new();

io::stdin().read_line(&mut guess)
.expect("Failed to read line");

println!("You guessed: {}", guess);
}
87 changes: 87 additions & 0 deletions listings/ch02-guessing-game-tutorial/listing-02-02/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions listings/ch02-guessing-game-tutorial/listing-02-02/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "guessing_game"
version = "0.1.0"
authors = ["Your Name <[email protected]>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rand = "0.5.5"
Loading