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

tools/vcheck-md: add -skip_line_length_check flag and fix vmod handling in '```vmod' (#17997)

This commit is contained in:
Petr Makhnev 2023-04-21 20:42:21 +04:00 committed by GitHub
parent 95d1beb008
commit d48aa15514
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,6 +50,7 @@ fn main() {
println('´-all´ flag is deprecated. Please use ´v check-md .´ instead.') println('´-all´ flag is deprecated. Please use ´v check-md .´ instead.')
exit(1) exit(1)
} }
mut skip_line_length_check := '-skip-line-length-check' in os.args
if show_progress { if show_progress {
// this is intended to be replaced by the progress lines // this is intended to be replaced by the progress lines
println('') println('')
@ -76,6 +77,7 @@ fn main() {
continue continue
} }
mut mdfile := MDFile{ mut mdfile := MDFile{
skip_line_length_check: skip_line_length_check
path: file_path path: file_path
lines: lines lines: lines
} }
@ -157,6 +159,7 @@ enum MDFileParserState {
struct MDFile { struct MDFile {
path string path string
skip_line_length_check bool
mut: mut:
lines []string lines []string
examples []VCodeExample examples []VCodeExample
@ -176,6 +179,7 @@ fn (mut f MDFile) check() CheckResult {
mut anchor_data := AnchorData{} mut anchor_data := AnchorData{}
for j, line in f.lines { for j, line in f.lines {
// f.progress('line: $j') // f.progress('line: $j')
if !f.skip_line_length_check {
if f.state == .vexample { if f.state == .vexample {
if line.len > too_long_line_length_example { if line.len > too_long_line_length_example {
wprintln(wline(f.path, j, line.len, 'example lines must be less than ${too_long_line_length_example} characters')) wprintln(wline(f.path, j, line.len, 'example lines must be less than ${too_long_line_length_example} characters'))
@ -205,6 +209,7 @@ fn (mut f MDFile) check() CheckResult {
eprintln(line) eprintln(line)
res.errors++ res.errors++
} }
}
if f.state == .markdown { if f.state == .markdown {
anchor_data.add_links(j, line) anchor_data.add_links(j, line)
anchor_data.add_link_targets(j, line) anchor_data.add_link_targets(j, line)
@ -602,6 +607,8 @@ fn (mut f MDFile) check_examples() CheckResult {
'play' {} 'play' {}
// same as play, but run example as a test // same as play, but run example as a test
'play-test' {} 'play-test' {}
// when ```vmod
'mod' {}
else { else {
eprintln(eline(f.path, e.sline, 0, 'unrecognized command: "${command}", use one of: wip/ignore/compile/failcompile/okfmt/nofmt/oksyntax/badsyntax/cgen/globals/live/shared')) eprintln(eline(f.path, e.sline, 0, 'unrecognized command: "${command}", use one of: wip/ignore/compile/failcompile/okfmt/nofmt/oksyntax/badsyntax/cgen/globals/live/shared'))
should_cleanup_vfile = false should_cleanup_vfile = false