From 383247a9ae8202f20ce6f01d1429c1cd2a11d516 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 31 May 2020 00:33:37 +0200 Subject: Generalize --- xtask/src/codegen/gen_assists_docs.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'xtask/src/codegen') 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 { fn collect_file(acc: &mut Vec, path: &Path) -> Result<()> { let text = fs::read_to_string(path)?; - let comment_blocks = extract_comment_blocks_with_empty_lines(&text); + let comment_blocks = extract_comment_blocks_with_empty_lines("Assist", &text); for block in comment_blocks { // FIXME: doesn't support blank lines yet, need to tweak // `extract_comment_blocks` for that. - let mut lines = block.iter(); - let first_line = lines.next().unwrap(); - if !first_line.starts_with("Assist: ") { - continue; - } - let id = first_line["Assist: ".len()..].to_string(); + let id = block.id; assert!( id.chars().all(|it| it.is_ascii_lowercase() || it == '_'), "invalid assist id: {:?}", id ); + let mut lines = block.contents.iter(); let doc = take_until(lines.by_ref(), "```").trim().to_string(); assert!( -- cgit v1.2.3