diff options
author | Aleksey Kladov <[email protected]> | 2020-05-31 08:45:41 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-05-31 08:45:41 +0100 |
commit | f593393ebb9bfa515caf168a9f037324eeb6edfe (patch) | |
tree | 7bb131eb52b9eaf457ac80760000ca5544fc0626 /xtask | |
parent | c1161718792a1841841a51bc8450d37c4f1ff535 (diff) |
Specify actions
Diffstat (limited to 'xtask')
-rw-r--r-- | xtask/src/codegen/gen_feature_docs.rs | 25 |
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 | ||
51 | fn 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 | |||
55 | impl fmt::Display for Feature { | 70 | impl 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)?; |