vvet: allow passing many files, improve specifity for emacs goto error
parent
dc3101384f
commit
68af46402e
|
@ -632,9 +632,9 @@ fn (mut cfg DocConfig) generate_docs_from_file() {
|
||||||
}
|
}
|
||||||
if cfg.include_readme {
|
if cfg.include_readme {
|
||||||
readme_contents := cfg.get_readme(dir_path)
|
readme_contents := cfg.get_readme(dir_path)
|
||||||
if cfg.output_type == .stdout {
|
if cfg.output_type == .stdout {
|
||||||
println(markdown.to_plain(readme_contents))
|
println(markdown.to_plain(readme_contents))
|
||||||
} else if cfg.output_type == .html && cfg.is_multi {
|
} else if cfg.output_type == .html && cfg.is_multi {
|
||||||
cfg.docs << doc.Doc{
|
cfg.docs << doc.Doc{
|
||||||
head: doc.DocNode{
|
head: doc.DocNode{
|
||||||
name: 'README',
|
name: 'README',
|
||||||
|
@ -642,7 +642,7 @@ fn (mut cfg DocConfig) generate_docs_from_file() {
|
||||||
}
|
}
|
||||||
time_generated: time.now()
|
time_generated: time.now()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dirs := if cfg.is_multi { get_modules_list(cfg.input_path, []string{}) } else { [cfg.input_path] }
|
dirs := if cfg.is_multi { get_modules_list(cfg.input_path, []string{}) } else { [cfg.input_path] }
|
||||||
for dirpath in dirs {
|
for dirpath in dirs {
|
||||||
|
|
|
@ -9,33 +9,48 @@ import v.parser
|
||||||
import v.util
|
import v.util
|
||||||
import v.table
|
import v.table
|
||||||
import os
|
import os
|
||||||
|
import os.cmdline
|
||||||
|
|
||||||
fn main() {
|
struct VetOptions {
|
||||||
mut prefs := pref.new_preferences()
|
is_verbose bool
|
||||||
prefs.is_vet = true
|
}
|
||||||
table := table.new_table()
|
|
||||||
args := util.join_env_vflags_and_os_args()
|
fn (vet_options &VetOptions) vprintln(s string) {
|
||||||
if args.len < 3 {
|
if !vet_options.is_verbose {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
path := args[2]
|
println(s)
|
||||||
if path.ends_with('.v') {
|
}
|
||||||
vet_file(path, table, prefs)
|
|
||||||
} else if os.is_dir(path) {
|
fn main() {
|
||||||
println("vet'ing directory '$path'...")
|
args := util.join_env_vflags_and_os_args()
|
||||||
files := os.walk_ext(path, '.v')
|
paths := cmdline.only_non_options(cmdline.options_after(args, ['vet']))
|
||||||
for file in files {
|
vet_options := VetOptions{
|
||||||
vet_file(file, table, prefs)
|
is_verbose: '-verbose' in args || '-v' in args
|
||||||
|
}
|
||||||
|
for path in paths {
|
||||||
|
if path.ends_with('.v') {
|
||||||
|
vet_options.vet_file(path)
|
||||||
|
} else if os.is_dir(path) {
|
||||||
|
vet_options.vprintln("vetting folder '$path'...")
|
||||||
|
files := os.walk_ext(path, '.v')
|
||||||
|
for file in files {
|
||||||
|
vet_options.vet_file(file)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vet_file(path string, table &table.Table, prefs &pref.Preferences) {
|
fn (vet_options &VetOptions) vet_file(path string) {
|
||||||
|
mut prefs := pref.new_preferences()
|
||||||
|
prefs.is_vet = true
|
||||||
|
table := table.new_table()
|
||||||
if path.contains('/tests') {
|
if path.contains('/tests') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
file_ast := parser.parse_file(path, table, .parse_comments, prefs, &ast.Scope{
|
file_ast := parser.parse_file(path, table, .parse_comments, prefs, &ast.Scope{
|
||||||
parent: 0
|
parent: 0
|
||||||
})
|
})
|
||||||
|
vet_options.vprintln("vetting file '$path'...")
|
||||||
vet.vet(file_ast, table, true)
|
vet.vet(file_ast, table, true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,9 +115,13 @@ pub fn parse_file(path string, b_table &table.Table, comments_mode scanner.Comme
|
||||||
global_scope: global_scope
|
global_scope: global_scope
|
||||||
}
|
}
|
||||||
if pref.is_vet && p.scanner.text.contains('\n ') {
|
if pref.is_vet && p.scanner.text.contains('\n ') {
|
||||||
// TODO make this smarter
|
source_lines := os.read_lines(path) or { []string{} }
|
||||||
println(p.scanner.file_path)
|
for lnumber, line in source_lines {
|
||||||
println('Looks like you are using spaces for indentation.\n' + 'You can run `v fmt -w file.v` to fix that automatically')
|
if line.starts_with(' ') {
|
||||||
|
eprintln('${p.scanner.file_path}:${lnumber+1}: Looks like you are using spaces for indentation.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
eprintln('NB: You can run `v fmt -w file.v` to fix these automatically')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
return p.parse()
|
return p.parse()
|
||||||
|
|
Loading…
Reference in New Issue