mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 15:14:32 +00:00
Merge #4662
4662: minor r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
5f7225446e
1 changed files with 73 additions and 71 deletions
|
@ -8,7 +8,7 @@ use crate::{
|
|||
};
|
||||
|
||||
pub fn generate_assists_docs(mode: Mode) -> Result<()> {
|
||||
let assists = collect_assists()?;
|
||||
let assists = Assist::collect()?;
|
||||
generate_tests(&assists, mode)?;
|
||||
generate_docs(&assists, mode)?;
|
||||
Ok(())
|
||||
|
@ -22,29 +22,8 @@ struct Assist {
|
|||
after: String,
|
||||
}
|
||||
|
||||
fn hide_hash_comments(text: &str) -> String {
|
||||
text.split('\n') // want final newline
|
||||
.filter(|&it| !(it.starts_with("# ") || it == "#"))
|
||||
.map(|it| format!("{}\n", it))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn reveal_hash_comments(text: &str) -> String {
|
||||
text.split('\n') // want final newline
|
||||
.map(|it| {
|
||||
if it.starts_with("# ") {
|
||||
&it[2..]
|
||||
} else if it == "#" {
|
||||
""
|
||||
} else {
|
||||
it
|
||||
}
|
||||
})
|
||||
.map(|it| format!("{}\n", it))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn collect_assists() -> Result<Vec<Assist>> {
|
||||
impl Assist {
|
||||
fn collect() -> Result<Vec<Assist>> {
|
||||
let mut res = Vec::new();
|
||||
for path in rust_files(&project_root().join(codegen::ASSISTS_DIR)) {
|
||||
collect_file(&mut res, path.as_path())?;
|
||||
|
@ -98,6 +77,7 @@ fn collect_assists() -> Result<Vec<Assist>> {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_tests(assists: &[Assist], mode: Mode) -> Result<()> {
|
||||
|
@ -157,3 +137,25 @@ fn generate_docs(assists: &[Assist], mode: Mode) -> Result<()> {
|
|||
|
||||
codegen::update(&project_root().join(codegen::ASSISTS_DOCS), &buf, mode)
|
||||
}
|
||||
|
||||
fn hide_hash_comments(text: &str) -> String {
|
||||
text.split('\n') // want final newline
|
||||
.filter(|&it| !(it.starts_with("# ") || it == "#"))
|
||||
.map(|it| format!("{}\n", it))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn reveal_hash_comments(text: &str) -> String {
|
||||
text.split('\n') // want final newline
|
||||
.map(|it| {
|
||||
if it.starts_with("# ") {
|
||||
&it[2..]
|
||||
} else if it == "#" {
|
||||
""
|
||||
} else {
|
||||
it
|
||||
}
|
||||
})
|
||||
.map(|it| format!("{}\n", it))
|
||||
.collect()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue