From ee42dd914c4ad5754bfc534726d558ce803a3de6 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 12 Apr 2021 14:59:27 +0300 Subject: [PATCH] tools: make `v check-md` more strict about unformatted code samples in `failcompile` sections. --- cmd/tools/vcheck-md.v | 14 +++++++++----- cmd/v/help/check-md.txt | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd/tools/vcheck-md.v b/cmd/tools/vcheck-md.v index 2af65c7e7e..94fb5119f0 100644 --- a/cmd/tools/vcheck-md.v +++ b/cmd/tools/vcheck-md.v @@ -13,8 +13,7 @@ import v.pref const ( too_long_line_length = 100 term_colors = term.can_show_color_on_stderr() - is_all = '-all' in os.args - hide_warnings = '-hide-warnings' in os.args + hide_warnings = '-hide-warnings' in os.args || '-w' in os.args non_option_args = cmdline.only_non_options(os.args[2..]) ) @@ -38,7 +37,7 @@ fn main() { vhelp.show_topic('check-md') exit(0) } - if is_all { + if '-all' in os.args { println('´-all´ flag is deprecated. Please use ´v check-md .´ instead.') exit(1) } @@ -304,8 +303,13 @@ fn (mut f MDFile) check_examples() CheckResult { 'failcompile' { res := silent_cmdexecute('"$vexe" -w -Wfatal-errors -o x.c $vfile') os.rm('x.c') or {} - if res == 0 { - eprintln(eline(f.path, e.sline, 0, '`failcompile` example compiled')) + if res == 0 || fmt_res != 0 { + 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) should_cleanup_vfile = false errors++ diff --git a/cmd/v/help/check-md.txt b/cmd/v/help/check-md.txt index 29a6a36d68..1b0dc7f9bb 100644 --- a/cmd/v/help/check-md.txt +++ b/cmd/v/help/check-md.txt @@ -7,7 +7,7 @@ Usage: Note: You can also combine files and directories. 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. These are: