Skip to content
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

Enforce dashes in the unstable book file names #47414

Merged
merged 1 commit into from
Jan 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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