Sort entries of SUMMARY.md alphabetically

This commit is contained in:
est31 2017-06-17 21:54:09 +02:00
parent 9f6fb8e88f
commit 696085faee
2 changed files with 14 additions and 14 deletions

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::collections::HashSet;
use std::collections::BTreeSet;
use std::fs;
use std::path;
use features::{collect_lang_features, collect_lib_features, Features, Status};
@ -45,7 +45,7 @@ fn dir_entry_is_file(dir_entry: &fs::DirEntry) -> bool {
}
/// Retrieve names of all unstable features
pub fn collect_unstable_feature_names(features: &Features) -> HashSet<String> {
pub fn collect_unstable_feature_names(features: &Features) -> BTreeSet<String> {
features
.iter()
.filter(|&(_, ref f)| f.level == Status::Unstable)
@ -53,7 +53,7 @@ pub fn collect_unstable_feature_names(features: &Features) -> HashSet<String> {
.collect()
}
pub fn collect_unstable_book_section_file_names(dir: &path::Path) -> HashSet<String> {
pub fn collect_unstable_book_section_file_names(dir: &path::Path) -> BTreeSet<String> {
fs::read_dir(dir)
.expect("could not read directory")
.into_iter()
@ -69,7 +69,7 @@ pub fn collect_unstable_book_section_file_names(dir: &path::Path) -> HashSet<Str
/// * hyphens replaced by underscores
/// * the markdown suffix ('.md') removed
fn collect_unstable_book_lang_features_section_file_names(base_src_path: &path::Path)
-> HashSet<String> {
-> BTreeSet<String> {
collect_unstable_book_section_file_names(&unstable_book_lang_features_path(base_src_path))
}
@ -78,7 +78,7 @@ fn collect_unstable_book_lang_features_section_file_names(base_src_path: &path::
/// * hyphens replaced by underscores
/// * the markdown suffix ('.md') removed
fn collect_unstable_book_lib_features_section_file_names(base_src_path: &path::Path)
-> HashSet<String> {
-> BTreeSet<String> {
collect_unstable_book_section_file_names(&unstable_book_lib_features_path(base_src_path))
}

View file

@ -17,7 +17,7 @@
use tidy::features::{Feature, Features, collect_lib_features, collect_lang_features};
use tidy::unstable_book::{collect_unstable_feature_names, collect_unstable_book_section_file_names,
PATH_STR, LANG_FEATURES_DIR, LIB_FEATURES_DIR};
use std::collections::HashSet;
use std::collections::BTreeSet;
use std::io::Write;
use std::fs::{self, File};
use std::env;
@ -48,9 +48,9 @@ fn generate_stub_no_issue(path: &Path, name: &str) {
name = name)));
}
fn hset_to_summary_str(hset: HashSet<String>, dir: &str
fn set_to_summary_str(set: &BTreeSet<String>, dir: &str
) -> String {
hset
set
.iter()
.map(|ref n| format!(" - [{}]({}/{}.md)",
n,
@ -63,16 +63,16 @@ fn generate_summary(path: &Path, lang_features: &Features, lib_features: &Featur
let compiler_flags = collect_unstable_book_section_file_names(
&path.join("compiler-flags"));
let compiler_flags_str = hset_to_summary_str(compiler_flags,
"compiler-flags");
let compiler_flags_str = set_to_summary_str(&compiler_flags,
"compiler-flags");
let unstable_lang_features = collect_unstable_feature_names(&lang_features);
let unstable_lib_features = collect_unstable_feature_names(&lib_features);
let lang_features_str = hset_to_summary_str(unstable_lang_features,
LANG_FEATURES_DIR);
let lib_features_str = hset_to_summary_str(unstable_lib_features,
LIB_FEATURES_DIR);
let lang_features_str = set_to_summary_str(&unstable_lang_features,
LANG_FEATURES_DIR);
let lib_features_str = set_to_summary_str(&unstable_lib_features,
LIB_FEATURES_DIR);
let mut file = t!(File::create(&path.join("SUMMARY.md")));
t!(file.write_fmt(format_args!(include_str!("SUMMARY.md"),