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
|
||||
}
|
||||
|
||||
fn get_modules_list(path string, ignore_paths2 []string) []string {
|
||||
files := os.ls(path) or { return []string{} }
|
||||
fn get_modules_list(opath string, ignore_paths2 []string) []string {
|
||||
path := opath.trim_right('/\\')
|
||||
names := os.ls(path) or { return [] }
|
||||
mut ignore_paths := get_ignore_paths(path) or { []string{} }
|
||||
ignore_paths << ignore_paths2
|
||||
mut dirs := []string{}
|
||||
for file in files {
|
||||
fpath := os.join_path(path, file)
|
||||
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
|
||||
mut dirs := map[string]int{}
|
||||
for name in names {
|
||||
if name == 'testdata' {
|
||||
continue
|
||||
}
|
||||
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]++
|
||||
}
|
||||
dirs << path
|
||||
continue
|
||||
}
|
||||
if fpath.ends_with('.v') && !fpath.ends_with('_test.v') {
|
||||
dirs[path]++
|
||||
continue
|
||||
}
|
||||
}
|
||||
dirs.sort()
|
||||
return dirs
|
||||
mut res := dirs.keys()
|
||||
res.sort()
|
||||
return res
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue