mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-11 07:21:51 +00:00
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:
parent
ca092937aa
commit
38e2667584
@ -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()
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user