Skip to content

Commit

Permalink
Enforce dashes in the unstable book file names
Browse files Browse the repository at this point in the history
Also rename the existing underscore using files to use dashes.

Fixes #47394.
  • Loading branch information
est31 committed Jan 13, 2018
1 parent ca09293 commit 38e2667
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/tools/tidy/src/unstable_book.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand All @@ -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()
}

Expand Down
15 changes: 9 additions & 6 deletions src/tools/unstable-book-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 38e2667

Please sign in to comment.