diff options
author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2020-05-30 23:33:37 +0100 |
---|---|---|
committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2020-05-30 23:33:37 +0100 |
commit | 383247a9ae8202f20ce6f01d1429c1cd2a11d516 (patch) | |
tree | d1861a269d940a9369f26a95021eafaad62d66de /xtask/src/codegen | |
parent | e1829d8959d9f48302fec42d64216c158db13744 (diff) |
Generalize
Diffstat (limited to 'xtask/src/codegen')
-rw-r--r-- | xtask/src/codegen/gen_assists_docs.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/xtask/src/codegen/gen_assists_docs.rs b/xtask/src/codegen/gen_assists_docs.rs index 20dcde820..6ebeb8aea 100644 --- a/xtask/src/codegen/gen_assists_docs.rs +++ b/xtask/src/codegen/gen_assists_docs.rs | |||
@@ -33,22 +33,18 @@ impl Assist { | |||
33 | 33 | ||
34 | fn collect_file(acc: &mut Vec<Assist>, path: &Path) -> Result<()> { | 34 | fn collect_file(acc: &mut Vec<Assist>, path: &Path) -> Result<()> { |
35 | let text = fs::read_to_string(path)?; | 35 | let text = fs::read_to_string(path)?; |
36 | let comment_blocks = extract_comment_blocks_with_empty_lines(&text); | 36 | let comment_blocks = extract_comment_blocks_with_empty_lines("Assist", &text); |
37 | 37 | ||
38 | for block in comment_blocks { | 38 | for block in comment_blocks { |
39 | // FIXME: doesn't support blank lines yet, need to tweak | 39 | // FIXME: doesn't support blank lines yet, need to tweak |
40 | // `extract_comment_blocks` for that. | 40 | // `extract_comment_blocks` for that. |
41 | let mut lines = block.iter(); | 41 | let id = block.id; |
42 | let first_line = lines.next().unwrap(); | ||
43 | if !first_line.starts_with("Assist: ") { | ||
44 | continue; | ||
45 | } | ||
46 | let id = first_line["Assist: ".len()..].to_string(); | ||
47 | assert!( | 42 | assert!( |
48 | id.chars().all(|it| it.is_ascii_lowercase() || it == '_'), | 43 | id.chars().all(|it| it.is_ascii_lowercase() || it == '_'), |
49 | "invalid assist id: {:?}", | 44 | "invalid assist id: {:?}", |
50 | id | 45 | id |
51 | ); | 46 | ); |
47 | let mut lines = block.contents.iter(); | ||
52 | 48 | ||
53 | let doc = take_until(lines.by_ref(), "```").trim().to_string(); | 49 | let doc = take_until(lines.by_ref(), "```").trim().to_string(); |
54 | assert!( | 50 | assert!( |