aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/codegen.rs
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/src/codegen.rs')
-rw-r--r--xtask/src/codegen.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs
index 44729cd57..4ec8ab75a 100644
--- a/xtask/src/codegen.rs
+++ b/xtask/src/codegen.rs
@@ -74,6 +74,14 @@ fn reformat(text: impl std::fmt::Display) -> Result<String> {
74} 74}
75 75
76fn extract_comment_blocks(text: &str) -> Vec<Vec<String>> { 76fn extract_comment_blocks(text: &str) -> Vec<Vec<String>> {
77 do_extract_comment_blocks(text, false)
78}
79
80fn extract_comment_blocks_with_empty_lines(text: &str) -> Vec<Vec<String>> {
81 do_extract_comment_blocks(text, true)
82}
83
84fn do_extract_comment_blocks(text: &str, allow_blocks_with_empty_lins: bool) -> Vec<Vec<String>> {
77 let mut res = Vec::new(); 85 let mut res = Vec::new();
78 86
79 let prefix = "// "; 87 let prefix = "// ";
@@ -81,6 +89,11 @@ fn extract_comment_blocks(text: &str) -> Vec<Vec<String>> {
81 89
82 let mut block = vec![]; 90 let mut block = vec![];
83 for line in lines { 91 for line in lines {
92 if line == "//" && allow_blocks_with_empty_lins {
93 block.push(String::new());
94 continue;
95 }
96
84 let is_comment = line.starts_with(prefix); 97 let is_comment = line.starts_with(prefix);
85 if is_comment { 98 if is_comment {
86 block.push(line[prefix.len()..].to_string()); 99 block.push(line[prefix.len()..].to_string());