mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
gen_assists_docs skip hidden files
This commit is contained in:
parent
5e827bd948
commit
90c66470f9
3 changed files with 21 additions and 26 deletions
|
@ -17,6 +17,7 @@ use std::{
|
|||
path::{Path, PathBuf},
|
||||
process::{Command, Stdio},
|
||||
};
|
||||
use walkdir::{DirEntry, WalkDir};
|
||||
|
||||
use crate::{
|
||||
codegen::Mode,
|
||||
|
@ -37,6 +38,21 @@ pub fn project_root() -> PathBuf {
|
|||
.to_path_buf()
|
||||
}
|
||||
|
||||
pub fn rust_files(path: &Path) -> impl Iterator<Item = PathBuf> {
|
||||
let iter = WalkDir::new(path);
|
||||
return iter
|
||||
.into_iter()
|
||||
.filter_entry(|e| !is_hidden(e))
|
||||
.map(|e| e.unwrap())
|
||||
.filter(|e| !e.file_type().is_dir())
|
||||
.map(|e| e.into_path())
|
||||
.filter(|path| path.extension().map(|it| it == "rs").unwrap_or(false));
|
||||
|
||||
fn is_hidden(entry: &DirEntry) -> bool {
|
||||
entry.file_name().to_str().map(|s| s.starts_with('.')).unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run_rustfmt(mode: Mode) -> Result<()> {
|
||||
let _dir = pushd(project_root());
|
||||
ensure_rustfmt()?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue