mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-31 07:37:30 +00:00
generate more assists docs
This commit is contained in:
parent
e6cb06d285
commit
d385438bcc
11 changed files with 419 additions and 114 deletions
|
@ -74,6 +74,14 @@ fn reformat(text: impl std::fmt::Display) -> Result<String> {
|
|||
}
|
||||
|
||||
fn extract_comment_blocks(text: &str) -> Vec<Vec<String>> {
|
||||
do_extract_comment_blocks(text, false)
|
||||
}
|
||||
|
||||
fn extract_comment_blocks_with_empty_lines(text: &str) -> Vec<Vec<String>> {
|
||||
do_extract_comment_blocks(text, true)
|
||||
}
|
||||
|
||||
fn do_extract_comment_blocks(text: &str, allow_blocks_with_empty_lins: bool) -> Vec<Vec<String>> {
|
||||
let mut res = Vec::new();
|
||||
|
||||
let prefix = "// ";
|
||||
|
@ -81,6 +89,11 @@ fn extract_comment_blocks(text: &str) -> Vec<Vec<String>> {
|
|||
|
||||
let mut block = vec![];
|
||||
for line in lines {
|
||||
if line == "//" && allow_blocks_with_empty_lins {
|
||||
block.push(String::new());
|
||||
continue;
|
||||
}
|
||||
|
||||
let is_comment = line.starts_with(prefix);
|
||||
if is_comment {
|
||||
block.push(line[prefix.len()..].to_string());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue