1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

Fix: vet false warning on brackets in documentation (#17767)

This commit is contained in:
Artem Yurchenko 2023-03-25 20:51:45 +01:00 committed by GitHub
parent db97630117
commit 713c95fcc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 12 deletions

View File

@ -0,0 +1,9 @@
// normalize_vector Normalizes a vector
//
// Example:
// ```v
// vector := Vector{3, 4}
// normalize_vector(vector) // Vector{0.6, 0.8}
// ```
pub fn normalize_vector(vector f32) {}

View File

@ -187,23 +187,28 @@ fn (mut vt Vet) vet_fn_documentation(lines []string, line string, lnumber int) {
prev_prev_line = lines[j - 1]
}
prev_line := lines[j]
if prev_line.starts_with('//') {
if prev_line.starts_with('// ${fn_name} ') {
grab = false
break
} else if prev_line.starts_with('// ${fn_name}')
&& !prev_prev_line.starts_with('//') {
grab = false
clean_line := line.all_before_last('{').trim(' ')
vt.warn('The documentation for "${clean_line}" seems incomplete.',
lnumber, .doc)
break
}
continue
}
if prev_line.contains('}') { // We've looked back to the above scope, stop here
break
} else if prev_line.starts_with('// ${fn_name} ') {
grab = false
break
} else if prev_line.starts_with('// ${fn_name}')
&& !prev_prev_line.starts_with('//') {
grab = false
clean_line := line.all_before_last('{').trim(' ')
vt.warn('The documentation for "${clean_line}" seems incomplete.',
lnumber, .doc)
break
} else if prev_line.starts_with('[') {
tags << collect_tags(prev_line)
continue
} else if prev_line.starts_with('//') { // Single-line comment
continue
}
}
if grab {