Skip to content

Commit

Permalink
Rollup merge of rust-lang#59747 - gruberb:copy-book-toml-unstable-boo…
Browse files Browse the repository at this point in the history
…k, r=ehuss

Copy book.toml unstable book generator

Solves rust-lang#59554 and adds a book title to the unstable book.

I assume that [copy_recursive](https://github.com/rust-lang/rust/blob/acd8dd6a50d505057a7d7ad8d0d7a4c2bd274200/src/tools/unstable-book-gen/src/main.rs#L105) will take files regardless of their type (`.md` or `.toml`).

Although I had a hard time time testing it. A second pair of eyes is definitely needed.
  • Loading branch information
Centril committed Apr 13, 2019
2 parents 056c02e + 34c1572 commit d34ebb4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/doc/unstable-book/book.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[book]
title = "The Rust Unstable Book"
author = "The Rust Community"
8 changes: 4 additions & 4 deletions src/tools/tidy/src/unstable_book.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use std::fs;
use std::path;
use crate::features::{collect_lang_features, collect_lib_features, Features, Status};

pub const PATH_STR: &str = "doc/unstable-book/src";
pub const PATH_STR: &str = "doc/unstable-book";

pub const COMPILER_FLAGS_DIR: &str = "compiler-flags";
pub const COMPILER_FLAGS_DIR: &str = "src/compiler-flags";

pub const LANG_FEATURES_DIR: &str = "language-features";
pub const LANG_FEATURES_DIR: &str = "src/language-features";

pub const LIB_FEATURES_DIR: &str = "library-features";
pub const LIB_FEATURES_DIR: &str = "src/library-features";

/// Builds the path to the Unstable Book source directory from the Rust 'src' directory.
pub fn unstable_book_path(base_src_path: &path::Path) -> path::PathBuf {
Expand Down
14 changes: 7 additions & 7 deletions src/tools/unstable-book-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn set_to_summary_str(set: &BTreeSet<String>, dir: &str

fn generate_summary(path: &Path, lang_features: &Features, lib_features: &Features) {
let compiler_flags = collect_unstable_book_section_file_names(
&path.join("compiler-flags"));
&path.join("src/compiler-flags"));

let compiler_flags_str = set_to_summary_str(&compiler_flags,
"compiler-flags");
Expand All @@ -61,11 +61,11 @@ fn generate_summary(path: &Path, lang_features: &Features, lib_features: &Featur
let unstable_lib_features = collect_unstable_feature_names(&lib_features);

let lang_features_str = set_to_summary_str(&unstable_lang_features,
LANG_FEATURES_DIR);
"language-features");
let lib_features_str = set_to_summary_str(&unstable_lib_features,
LIB_FEATURES_DIR);
"library-features");

let mut file = t!(File::create(&path.join("SUMMARY.md")));
let mut file = t!(File::create(&path.join("src/SUMMARY.md")));
t!(file.write_fmt(format_args!(include_str!("SUMMARY.md"),
compiler_flags = compiler_flags_str,
language_features = lang_features_str,
Expand Down Expand Up @@ -102,8 +102,8 @@ fn generate_unstable_book_files(src :&Path, out: &Path, features :&Features) {
}
}

fn copy_recursive(path: &Path, to: &Path) {
for entry in t!(fs::read_dir(path)) {
fn copy_recursive(from: &Path, to: &Path) {
for entry in t!(fs::read_dir(from)) {
let e = t!(entry);
let t = t!(e.metadata());
let dest = &to.join(e.file_name());
Expand All @@ -120,7 +120,7 @@ fn main() {
let src_path_str = env::args_os().skip(1).next().expect("source path required");
let dest_path_str = env::args_os().skip(2).next().expect("destination path required");
let src_path = Path::new(&src_path_str);
let dest_path = Path::new(&dest_path_str).join("src");
let dest_path = Path::new(&dest_path_str);

let lang_features = collect_lang_features(src_path, &mut false);
let lib_features = collect_lib_features(src_path).into_iter().filter(|&(ref name, _)| {
Expand Down

0 comments on commit d34ebb4

Please sign in to comment.