Rollup merge of #47414 - est31:master, r=alexcrichton

Enforce dashes in the unstable book file names

Also rename the existing underscore using files to use dashes.

Fixes #47394.
This commit is contained in:
kennytm 2018-01-15 16:55:34 +08:00
commit 63f4285247
No known key found for this signature in database
GPG key ID: FEF6C8051D0E013C
6 changed files with 11 additions and 8 deletions

View file

@ -49,7 +49,7 @@ pub fn collect_unstable_feature_names(features: &Features) -> BTreeSet<String> {
features
.iter()
.filter(|&(_, ref f)| f.level == Status::Unstable)
.map(|(name, _)| name.to_owned())
.map(|(name, _)| name.replace('_', "-"))
.collect()
}
@ -60,7 +60,7 @@ pub fn collect_unstable_book_section_file_names(dir: &path::Path) -> BTreeSet<St
.map(|entry| entry.expect("could not read directory entry"))
.filter(dir_entry_is_file)
.map(|entry| entry.file_name().into_string().unwrap())
.map(|n| n.trim_right_matches(".md").replace('-', "_"))
.map(|n| n.trim_right_matches(".md").to_owned())
.collect()
}

View file

@ -53,9 +53,9 @@ fn set_to_summary_str(set: &BTreeSet<String>, dir: &str
set
.iter()
.map(|ref n| format!(" - [{}]({}/{}.md)",
n,
n.replace('-', "_"),
dir,
n.replace('_', "-")))
n))
.fold("".to_owned(), |s, a| s + &a + "\n")
}
@ -96,14 +96,17 @@ fn generate_unstable_book_files(src :&Path, out: &Path, features :&Features) {
let unstable_section_file_names = collect_unstable_book_section_file_names(src);
t!(fs::create_dir_all(&out));
for feature_name in &unstable_features - &unstable_section_file_names {
let file_name = format!("{}.md", feature_name.replace('_', "-"));
let feature_name_underscore = feature_name.replace('-', "_");
let file_name = format!("{}.md", feature_name);
let out_file_path = out.join(&file_name);
let feature = &features[&feature_name];
let feature = &features[&feature_name_underscore];
if has_valid_tracking_issue(&feature) {
generate_stub_issue(&out_file_path, &feature_name, feature.tracking_issue.unwrap());
generate_stub_issue(&out_file_path,
&feature_name_underscore,
feature.tracking_issue.unwrap());
} else {
generate_stub_no_issue(&out_file_path, &feature_name);
generate_stub_no_issue(&out_file_path, &feature_name_underscore);
}
}
}