@@ -27,6 +27,8 @@ const vexe = @VEXE
2727struct CheckResult {
2828pub mut :
2929 files int
30+ lines int
31+ examples int
3032 oks int
3133 warnings int
3234 ferrors int
@@ -36,6 +38,8 @@ pub mut:
3638fn (v1 CheckResult) + (v2 CheckResult) CheckResult {
3739 return CheckResult{
3840 files: v1 .files + v2 .files
41+ lines: v1 .lines + v2 .lines
42+ examples: v1 .examples + v2 .examples
3943 oks: v1 .oks + v2 .oks
4044 warnings: v1 .warnings + v2 .warnings
4145 ferrors: v1 .ferrors + v2 .ferrors
@@ -44,6 +48,7 @@ fn (v1 CheckResult) + (v2 CheckResult) CheckResult {
4448}
4549
4650fn main () {
51+ unbuffer_stdout ()
4752 if non_option_args.len == 0 || '-help' in os.args {
4853 help.print_and_exit ('check-md' )
4954 }
@@ -52,10 +57,6 @@ fn main() {
5257 exit (1 )
5358 }
5459 mut skip_line_length_check := '-skip-line-length-check' in os.args
55- if show_progress {
56- // this is intended to be replaced by the progress lines
57- println ('' )
58- }
5960 mut files_paths := non_option_args.clone ()
6061 mut res := CheckResult{}
6162 if term_colors {
@@ -65,6 +66,7 @@ fn main() {
6566 defer {
6667 os.rmdir_all (vcheckfolder) or {}
6768 }
69+ mut all_mdfiles := []MDFile{}
6870 for i := 0 ; i < files_paths.len; i++ {
6971 file_path := files_paths[i]
7072 if os.is_dir (file_path) {
@@ -77,17 +79,26 @@ fn main() {
7779 res.warnings++
7880 continue
7981 }
80- mut mdfile := MDFile{
82+ all_mdfiles << MDFile{
8183 skip_line_length_check: skip_line_length_check
8284 path: file_path
8385 lines: lines
8486 }
87+ }
88+ println ('> Found: ${all_mdfiles .len } .md files.' )
89+ if show_progress {
90+ // this is intended to be replaced by the progress lines
91+ println ('' )
92+ }
93+ for idx, mut mdfile in all_mdfiles {
94+ mdfile.idx = idx
95+ mdfile.nfiles = all_mdfiles.len
8596 res + = mdfile.check ()
8697 }
8798 if res.errors == 0 && show_progress {
8899 clear_previous_line ()
89100 }
90- println ('Checked .md files: ${res .files } | OKs: ${res .oks } | Warnings: ${res .warnings } | Errors: ${res .errors } | Formatting errors: ${res .ferrors }' )
101+ println ('Checked .md files: ${res .files } | Ex.: ${ res . examples } | Lines: ${ res . lines } | OKs: ${res .oks } | Warnings: ${res .warnings } | Errors: ${res .errors } | Fmt errors: ${res .ferrors }' )
91102 if res.ferrors > 0 && ! should_autofix {
92103 println ('Note: you can use `VAUTOFIX=1 v check-md file.md`, or `v check-md -fix file.md`,' )
93104 println (' to fix the V formatting errors in the markdown code blocks, when possible.' )
@@ -166,6 +177,8 @@ struct MDFile {
166177 path string
167178 skip_line_length_check bool
168179mut :
180+ idx int
181+ nfiles int
169182 lines []string
170183 examples []VCodeExample
171184 current VCodeExample
180193fn (mut f MDFile) progress (message string ) {
181194 if show_progress {
182195 clear_previous_line ()
183- println ('File: ${f .path }, ${message }' )
196+ println ('${ message } | File ${f .idx + 1 : 3 }/${ f . nfiles : - 3 }: ${f . path }' )
184197 }
185198}
186199
@@ -241,6 +254,8 @@ fn (mut f MDFile) check() CheckResult {
241254 f.check_examples ()
242255 return CheckResult{
243256 files: 1
257+ lines: f.lines.len
258+ examples: f.examples.len
244259 oks: f.oks
245260 warnings: f.warnings
246261 errors: f.errors
@@ -472,8 +487,8 @@ fn (mut f MDFile) check_examples() {
472487 mut acommands := e.command.split (' ' )
473488 nofmt := 'nofmt' in acommands
474489 for command in acommands {
475- f.progress ('OK: ${f .oks :3 }, W: ${f .warnings :2 }, E: ${f .errors :2 }, F: ${f .ferrors :2 }, example ${
476- eidx + 1 }/${f .examples .len }, from line ${e .sline } to line ${e .eline }, lines: ${f .lines .len :5 }, command: ${command }' )
490+ f.progress ('OK: ${f .oks :3 }, W: ${f .warnings :2 }, E: ${f .errors :2 }, F: ${f .ferrors :2 }, ex. ${
491+ eidx + 1 : 3 }/${f .examples .len : - 3 }, from line ${e .sline : 4 } to line ${e .eline : - 4 } of ${f .lines .len :- 4 }, command: ${command : 12 s }' )
477492 fmt_res := if nofmt { 0 } else { get_fmt_exit_code (vfile, vexe) }
478493 f.ferrors + = fmt_res
479494 match command {
0 commit comments