diff options
Diffstat (limited to 'xtask/src')
-rw-r--r-- | xtask/src/codegen/gen_feature_docs.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/xtask/src/codegen/gen_feature_docs.rs b/xtask/src/codegen/gen_feature_docs.rs index 3f0013e82..341e67c73 100644 --- a/xtask/src/codegen/gen_feature_docs.rs +++ b/xtask/src/codegen/gen_feature_docs.rs | |||
@@ -38,7 +38,9 @@ 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!(is_valid_feature_name(&id), "invalid feature name: {:?}", id); | 41 | if let Err(msg) = is_valid_feature_name(&id) { |
42 | panic!("invalid feature name: {:?}:\n {}", id, msg) | ||
43 | } | ||
42 | let doc = block.contents.join("\n"); | 44 | let doc = block.contents.join("\n"); |
43 | let location = Location::new(path.clone(), block.line); | 45 | let location = Location::new(path.clone(), block.line); |
44 | acc.push(Feature { id, location, doc }) | 46 | acc.push(Feature { id, location, doc }) |
@@ -49,7 +51,7 @@ impl Feature { | |||
49 | } | 51 | } |
50 | } | 52 | } |
51 | 53 | ||
52 | fn is_valid_feature_name(feature: &str) -> bool { | 54 | fn is_valid_feature_name(feature: &str) -> Result<(), String> { |
53 | 'word: for word in feature.split_whitespace() { | 55 | 'word: for word in feature.split_whitespace() { |
54 | for &short in ["to", "and"].iter() { | 56 | for &short in ["to", "and"].iter() { |
55 | if word == short { | 57 | if word == short { |
@@ -58,14 +60,14 @@ fn is_valid_feature_name(feature: &str) -> bool { | |||
58 | } | 60 | } |
59 | for &short in ["To", "And"].iter() { | 61 | for &short in ["To", "And"].iter() { |
60 | if word == short { | 62 | if word == short { |
61 | return false; | 63 | return Err(format!("Don't capitalize {:?}", word)); |
62 | } | 64 | } |
63 | } | 65 | } |
64 | if !word.starts_with(char::is_uppercase) { | 66 | if !word.starts_with(char::is_uppercase) { |
65 | return false; | 67 | return Err(format!("Capitalize {:?}", word)); |
66 | } | 68 | } |
67 | } | 69 | } |
68 | true | 70 | Ok(()) |
69 | } | 71 | } |
70 | 72 | ||
71 | impl fmt::Display for Feature { | 73 | impl fmt::Display for Feature { |