mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
vdoc: filter testdata and tests folders by default, reduce filesystem stats calls
This commit is contained in:
parent
23ed1e9ae8
commit
818744e381
1 changed files with 25 additions and 13 deletions
|
@ -39,22 +39,34 @@ fn is_included(path string, ignore_paths []string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_modules_list(path string, ignore_paths2 []string) []string {
|
fn get_modules_list(opath string, ignore_paths2 []string) []string {
|
||||||
files := os.ls(path) or { return []string{} }
|
path := opath.trim_right('/\\')
|
||||||
|
names := os.ls(path) or { return [] }
|
||||||
mut ignore_paths := get_ignore_paths(path) or { []string{} }
|
mut ignore_paths := get_ignore_paths(path) or { []string{} }
|
||||||
ignore_paths << ignore_paths2
|
ignore_paths << ignore_paths2
|
||||||
mut dirs := []string{}
|
mut dirs := map[string]int{}
|
||||||
for file in files {
|
for name in names {
|
||||||
fpath := os.join_path(path, file)
|
if name == 'testdata' {
|
||||||
if os.is_dir(fpath) && is_included(fpath, ignore_paths) && !os.is_link(path) {
|
|
||||||
dirs << get_modules_list(fpath, ignore_paths.filter(it.starts_with(fpath)))
|
|
||||||
} else if fpath.ends_with('.v') && !fpath.ends_with('_test.v') {
|
|
||||||
if path in dirs {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
dirs << path
|
if name == 'tests' {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fpath := os.join_path(path, name)
|
||||||
|
fmeta := os.inode(fpath)
|
||||||
|
if fmeta.typ == .directory && is_included(fpath, ignore_paths) {
|
||||||
|
current_ignore_paths := ignore_paths.filter(it.starts_with(fpath))
|
||||||
|
for k in get_modules_list(fpath, current_ignore_paths) {
|
||||||
|
dirs[k]++
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if fpath.ends_with('.v') && !fpath.ends_with('_test.v') {
|
||||||
|
dirs[path]++
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dirs.sort()
|
mut res := dirs.keys()
|
||||||
return dirs
|
res.sort()
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue