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,52 +46,55 @@ fn report_undocumented_functions_in_path(opt Options, path string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
collect(path, mut files, collect_fn)
|
collect(path, mut files, collect_fn)
|
||||||
for f in files {
|
for file in files {
|
||||||
contents := os.read_file(f) or { panic(err) }
|
if file.ends_with('_test.v') {
|
||||||
lines := contents.split('\n')
|
|
||||||
// Skip test files
|
|
||||||
if f.ends_with('_test.v') {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
mut info := []UndocumentedFN{}
|
report_undocumented_functions_in_file(opt, file)
|
||||||
for i, line in lines {
|
}
|
||||||
if line.starts_with('pub fn') ||
|
}
|
||||||
(line.starts_with('fn ') && !(line.starts_with('fn C.') || line.starts_with('fn main'))) {
|
|
||||||
// println('Match: $line')
|
fn report_undocumented_functions_in_file(opt Options, file string) {
|
||||||
if i > 0 && lines.len > 0 {
|
contents := os.read_file(file) or { panic(err) }
|
||||||
mut line_above := lines[i - 1]
|
lines := contents.split('\n')
|
||||||
if !line_above.starts_with('//') {
|
mut info := []UndocumentedFN{}
|
||||||
mut tags := []string{}
|
for i, line in lines {
|
||||||
mut grab := true
|
if line.starts_with('pub fn') ||
|
||||||
for j := i - 1; j >= 0; j-- {
|
(line.starts_with('fn ') && !(line.starts_with('fn C.') || line.starts_with('fn main'))) {
|
||||||
prev_line := lines[j]
|
// println('Match: $line')
|
||||||
if prev_line.contains('}') { // We've looked back to the above scope, stop here
|
if i > 0 && lines.len > 0 {
|
||||||
break
|
mut line_above := lines[i - 1]
|
||||||
} else if prev_line.starts_with('[') {
|
if !line_above.starts_with('//') {
|
||||||
tags << collect_tags(prev_line)
|
mut tags := []string{}
|
||||||
continue
|
mut grab := true
|
||||||
} else if prev_line.starts_with('//') { // Single-line comment
|
for j := i - 1; j >= 0; j-- {
|
||||||
grab = false
|
prev_line := lines[j]
|
||||||
break
|
if prev_line.contains('}') { // We've looked back to the above scope, stop here
|
||||||
}
|
break
|
||||||
}
|
} else if prev_line.starts_with('[') {
|
||||||
if grab {
|
tags << collect_tags(prev_line)
|
||||||
clean_line := line.all_before_last(' {')
|
continue
|
||||||
info << UndocumentedFN{i + 1, clean_line, tags}
|
} else if prev_line.starts_with('//') { // Single-line comment
|
||||||
|
grab = false
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if grab {
|
||||||
|
clean_line := line.all_before_last(' {')
|
||||||
|
info << UndocumentedFN{i + 1, clean_line, tags}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if info.len > 0 {
|
}
|
||||||
for undocumented_fn in info {
|
if info.len > 0 {
|
||||||
tags_str := if opt.collect_tags && undocumented_fn.tags.len > 0 { '$undocumented_fn.tags' } else { '' }
|
for undocumented_fn in info {
|
||||||
if opt.deprecated {
|
tags_str := if opt.collect_tags && undocumented_fn.tags.len > 0 { '$undocumented_fn.tags' } else { '' }
|
||||||
println('$f:$undocumented_fn.line:0:$undocumented_fn.signature $tags_str')
|
if opt.deprecated {
|
||||||
} else {
|
println('$file:$undocumented_fn.line:0:$undocumented_fn.signature $tags_str')
|
||||||
if 'deprecated' !in undocumented_fn.tags {
|
} else {
|
||||||
println('$f:$undocumented_fn.line:0:$undocumented_fn.signature $tags_str')
|
if 'deprecated' !in undocumented_fn.tags {
|
||||||
}
|
println('$file:$undocumented_fn.line:0:$undocumented_fn.signature $tags_str')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,6 +128,10 @@ fn main() {
|
|||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
for path in os.args[1..] {
|
for path in os.args[1..] {
|
||||||
report_undocumented_functions_in_path(opt, path)
|
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