tools: make `v check-md` more strict about unformatted code samples in `failcompile` sections.

pull/9701/head
Delyan Angelov 2021-04-12 14:59:27 +03:00
parent a4fb851f3d
commit ee42dd914c
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 10 additions and 6 deletions

View File

@ -13,8 +13,7 @@ import v.pref
const ( const (
too_long_line_length = 100 too_long_line_length = 100
term_colors = term.can_show_color_on_stderr() term_colors = term.can_show_color_on_stderr()
is_all = '-all' in os.args hide_warnings = '-hide-warnings' in os.args || '-w' in os.args
hide_warnings = '-hide-warnings' in os.args
non_option_args = cmdline.only_non_options(os.args[2..]) non_option_args = cmdline.only_non_options(os.args[2..])
) )
@ -38,7 +37,7 @@ fn main() {
vhelp.show_topic('check-md') vhelp.show_topic('check-md')
exit(0) exit(0)
} }
if is_all { if '-all' in os.args {
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)
} }
@ -304,8 +303,13 @@ fn (mut f MDFile) check_examples() CheckResult {
'failcompile' { 'failcompile' {
res := silent_cmdexecute('"$vexe" -w -Wfatal-errors -o x.c $vfile') res := silent_cmdexecute('"$vexe" -w -Wfatal-errors -o x.c $vfile')
os.rm('x.c') or {} os.rm('x.c') or {}
if res == 0 { if res == 0 || fmt_res != 0 {
eprintln(eline(f.path, e.sline, 0, '`failcompile` example compiled')) if res == 0 {
eprintln(eline(f.path, e.sline, 0, '`failcompile` example compiled'))
}
if fmt_res != 0 {
eprintln(eline(f.path, e.sline, 0, 'example is not formatted'))
}
eprintln(vcontent) eprintln(vcontent)
should_cleanup_vfile = false should_cleanup_vfile = false
errors++ errors++

View File

@ -7,7 +7,7 @@ Usage:
Note: You can also combine files and directories. Note: You can also combine files and directories.
Flags: Flags:
-hide-warnings Do not print warnings, only errors. -w, -hide-warnings Do not print warnings, only errors.
NB: There are several special keywords, which you can put after the code fences for v. NB: There are several special keywords, which you can put after the code fences for v.
These are: These are: