mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
missdoc: add support for single files as arguments (#7894)
This commit is contained in:
parent
5841d5d8e1
commit
2aea11e607
@ -46,13 +46,17 @@ fn report_undocumented_functions_in_path(opt Options, path string) {
|
||||
}
|
||||
}
|
||||
collect(path, mut files, collect_fn)
|
||||
for f in files {
|
||||
contents := os.read_file(f) or { panic(err) }
|
||||
lines := contents.split('\n')
|
||||
// Skip test files
|
||||
if f.ends_with('_test.v') {
|
||||
for file in files {
|
||||
if file.ends_with('_test.v') {
|
||||
continue
|
||||
}
|
||||
report_undocumented_functions_in_file(opt, file)
|
||||
}
|
||||
}
|
||||
|
||||
fn report_undocumented_functions_in_file(opt Options, file string) {
|
||||
contents := os.read_file(file) or { panic(err) }
|
||||
lines := contents.split('\n')
|
||||
mut info := []UndocumentedFN{}
|
||||
for i, line in lines {
|
||||
if line.starts_with('pub fn') ||
|
||||
@ -87,11 +91,10 @@ fn report_undocumented_functions_in_path(opt Options, path string) {
|
||||
for undocumented_fn in info {
|
||||
tags_str := if opt.collect_tags && undocumented_fn.tags.len > 0 { '$undocumented_fn.tags' } else { '' }
|
||||
if opt.deprecated {
|
||||
println('$f:$undocumented_fn.line:0:$undocumented_fn.signature $tags_str')
|
||||
println('$file:$undocumented_fn.line:0:$undocumented_fn.signature $tags_str')
|
||||
} else {
|
||||
if 'deprecated' !in undocumented_fn.tags {
|
||||
println('$f:$undocumented_fn.line:0:$undocumented_fn.signature $tags_str')
|
||||
}
|
||||
println('$file:$undocumented_fn.line:0:$undocumented_fn.signature $tags_str')
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -125,6 +128,10 @@ fn main() {
|
||||
exit(0)
|
||||
}
|
||||
for path in os.args[1..] {
|
||||
if os.is_file(path) {
|
||||
report_undocumented_functions_in_file(opt, path)
|
||||
} else {
|
||||
report_undocumented_functions_in_path(opt, path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user