aboutsummaryrefslogtreecommitdiff
path: root/xtask
diff options
context:
space:
mode:
Diffstat (limited to 'xtask')
-rw-r--r--xtask/src/codegen/gen_feature_docs.rs25
1 files changed, 20 insertions, 5 deletions
diff --git a/xtask/src/codegen/gen_feature_docs.rs b/xtask/src/codegen/gen_feature_docs.rs
index 583185648..170a3e889 100644
--- a/xtask/src/codegen/gen_feature_docs.rs
+++ b/xtask/src/codegen/gen_feature_docs.rs
@@ -38,11 +38,7 @@ impl Feature {
38 38
39 for block in comment_blocks { 39 for block in comment_blocks {
40 let id = block.id; 40 let id = block.id;
41 assert!( 41 assert!(is_valid_feature_name(&id), "invalid feature name: {:?}", id);
42 id.split_ascii_whitespace().all(|it| it.starts_with(char::is_uppercase)),
43 "bad feature: {}",
44 id
45 );
46 let doc = block.contents.join("\n"); 42 let doc = block.contents.join("\n");
47 acc.push(Feature { id, path: path.clone(), doc }) 43 acc.push(Feature { id, path: path.clone(), doc })
48 } 44 }
@@ -52,6 +48,25 @@ impl Feature {
52 } 48 }
53} 49}
54 50
51fn is_valid_feature_name(feature: &str) -> bool {
52 'word: for word in feature.split_whitespace() {
53 for &short in ["to"].iter() {
54 if word == short {
55 continue 'word;
56 }
57 }
58 for &short in ["To"].iter() {
59 if word == short {
60 return false;
61 }
62 }
63 if !word.starts_with(char::is_uppercase) {
64 return false;
65 }
66 }
67 true
68}
69
55impl fmt::Display for Feature { 70impl fmt::Display for Feature {
56 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 71 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
57 writeln!(f, "=== {}", self.id)?; 72 writeln!(f, "=== {}", self.id)?;