diff options
author | Aleksey Kladov <[email protected]> | 2020-05-30 23:33:37 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-05-30 23:33:37 +0100 |
commit | 383247a9ae8202f20ce6f01d1429c1cd2a11d516 (patch) | |
tree | d1861a269d940a9369f26a95021eafaad62d66de /xtask/src/codegen.rs | |
parent | e1829d8959d9f48302fec42d64216c158db13744 (diff) |
Generalize
Diffstat (limited to 'xtask/src/codegen.rs')
-rw-r--r-- | xtask/src/codegen.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs index b4907f4b2..2e8fd3494 100644 --- a/xtask/src/codegen.rs +++ b/xtask/src/codegen.rs | |||
@@ -61,8 +61,24 @@ fn extract_comment_blocks(text: &str) -> Vec<Vec<String>> { | |||
61 | do_extract_comment_blocks(text, false) | 61 | do_extract_comment_blocks(text, false) |
62 | } | 62 | } |
63 | 63 | ||
64 | fn extract_comment_blocks_with_empty_lines(text: &str) -> Vec<Vec<String>> { | 64 | fn extract_comment_blocks_with_empty_lines(tag: &str, text: &str) -> Vec<CommentBlock> { |
65 | do_extract_comment_blocks(text, true) | 65 | assert!(tag.starts_with(char::is_uppercase)); |
66 | let tag = format!("{}:", tag); | ||
67 | let mut res = Vec::new(); | ||
68 | for mut block in do_extract_comment_blocks(text, true) { | ||
69 | let first = block.remove(0); | ||
70 | if first.starts_with(&tag) { | ||
71 | let id = first[tag.len()..].trim().to_string(); | ||
72 | let block = CommentBlock { id, contents: block }; | ||
73 | res.push(block); | ||
74 | } | ||
75 | } | ||
76 | res | ||
77 | } | ||
78 | |||
79 | struct CommentBlock { | ||
80 | id: String, | ||
81 | contents: Vec<String>, | ||
66 | } | 82 | } |
67 | 83 | ||
68 | fn do_extract_comment_blocks(text: &str, allow_blocks_with_empty_lines: bool) -> Vec<Vec<String>> { | 84 | fn do_extract_comment_blocks(text: &str, allow_blocks_with_empty_lines: bool) -> Vec<Vec<String>> { |