mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vfmt: shorten main.const_name
to just const_name
This commit is contained in:
@ -131,10 +131,10 @@ fn (vd VDoc) render_search_index(out Output) {
|
||||
|
||||
fn (mut vd VDoc) render_static_html(out Output) {
|
||||
vd.assets = {
|
||||
'doc_css': vd.get_resource(main.css_js_assets[0], out)
|
||||
'normalize_css': vd.get_resource(main.css_js_assets[1], out)
|
||||
'doc_js': vd.get_resource(main.css_js_assets[2], out)
|
||||
'dark_mode_js': vd.get_resource(main.css_js_assets[3], out)
|
||||
'doc_css': vd.get_resource(css_js_assets[0], out)
|
||||
'normalize_css': vd.get_resource(css_js_assets[1], out)
|
||||
'doc_js': vd.get_resource(css_js_assets[2], out)
|
||||
'dark_mode_js': vd.get_resource(css_js_assets[3], out)
|
||||
'light_icon': vd.get_resource('light.svg', out)
|
||||
'dark_icon': vd.get_resource('dark.svg', out)
|
||||
'menu_icon': vd.get_resource('menu.svg', out)
|
||||
@ -144,7 +144,7 @@ fn (mut vd VDoc) render_static_html(out Output) {
|
||||
|
||||
fn (vd VDoc) get_resource(name string, out Output) string {
|
||||
cfg := vd.cfg
|
||||
path := os.join_path(main.res_path, name)
|
||||
path := os.join_path(res_path, name)
|
||||
mut res := os.read_file(path) or { panic('vdoc: could not read $path') }
|
||||
/*
|
||||
if minify {
|
||||
@ -294,7 +294,7 @@ fn (vd VDoc) gen_html(d doc.Doc) string {
|
||||
symbols_toc_str := symbols_toc.str()
|
||||
modules_toc.free()
|
||||
symbols_toc.free()
|
||||
return main.html_content.replace('{{ title }}', d.head.name).replace('{{ head_name }}',
|
||||
return html_content.replace('{{ title }}', d.head.name).replace('{{ head_name }}',
|
||||
header_name).replace('{{ version }}', version).replace('{{ light_icon }}', vd.assets['light_icon']).replace('{{ dark_icon }}',
|
||||
vd.assets['dark_icon']).replace('{{ menu_icon }}', vd.assets['menu_icon']).replace('{{ head_assets }}',
|
||||
if cfg.inline_assets {
|
||||
@ -452,7 +452,7 @@ fn doc_node_html(dn doc.DocNode, link string, head bool, include_examples bool,
|
||||
dnw.write('${tabs[2]}<div class="title"><$head_tag>$dn.kind $sym_name$hash_link</$head_tag>')
|
||||
}
|
||||
if link.len != 0 {
|
||||
dnw.write('<a class="link" rel="noreferrer" target="_blank" href="$link">$main.link_svg</a>')
|
||||
dnw.write('<a class="link" rel="noreferrer" target="_blank" href="$link">$link_svg</a>')
|
||||
}
|
||||
dnw.write('</div>')
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ fn (mut vd VDoc) generate_docs_from_file() {
|
||||
exit(1)
|
||||
}
|
||||
dir_path := if cfg.is_vlib {
|
||||
main.vroot
|
||||
vroot
|
||||
} else if os.is_dir(cfg.input_path) {
|
||||
cfg.input_path
|
||||
} else {
|
||||
@ -404,8 +404,8 @@ fn parse_arguments(args []string) Config {
|
||||
}
|
||||
'-f' {
|
||||
format := cmdline.option(current_args, '-f', '')
|
||||
if format !in main.allowed_formats {
|
||||
allowed_str := main.allowed_formats.join(', ')
|
||||
if format !in allowed_formats {
|
||||
allowed_str := allowed_formats.join(', ')
|
||||
eprintln('vdoc: "$format" is not a valid format. Only $allowed_str are allowed.')
|
||||
exit(1)
|
||||
}
|
||||
@ -472,7 +472,7 @@ fn parse_arguments(args []string) Config {
|
||||
if cfg.input_path.trim_right('/') == 'vlib' {
|
||||
cfg.is_vlib = true
|
||||
cfg.is_multi = true
|
||||
cfg.input_path = os.join_path(main.vroot, 'vlib')
|
||||
cfg.input_path = os.join_path(vroot, 'vlib')
|
||||
} else if !is_path {
|
||||
// TODO vd.vprintln('Input "$cfg.input_path" is not a valid path. Looking for modules named "$cfg.input_path"...')
|
||||
mod_path := doc.lookup_module(cfg.input_path) or {
|
||||
@ -486,7 +486,7 @@ fn parse_arguments(args []string) Config {
|
||||
|
||||
fn main() {
|
||||
if os.args.len < 2 || '-h' in os.args || '--help' in os.args || os.args[1..] == ['doc', 'help'] {
|
||||
os.system('$main.vexe help doc')
|
||||
os.system('$vexe help doc')
|
||||
exit(0)
|
||||
}
|
||||
args := os.args[2..].clone()
|
||||
|
@ -48,7 +48,7 @@ fn check_path(vexe string, dir string, tests []string) int {
|
||||
println(found)
|
||||
println('============\n')
|
||||
println('diff:')
|
||||
println(util.color_compare_strings(main.diff_cmd, found, expected))
|
||||
println(util.color_compare_strings(diff_cmd, found, expected))
|
||||
println('============\n')
|
||||
nb_fail++
|
||||
} else {
|
||||
|
@ -38,12 +38,12 @@ const show_warnings = '-hide-warnings' !in vet_options
|
||||
|
||||
fn main() {
|
||||
opt := Options{
|
||||
is_verbose: main.is_verbose
|
||||
is_verbose: is_verbose
|
||||
}
|
||||
mut vet := Vet{
|
||||
opt: opt
|
||||
}
|
||||
mut paths := cmdline.only_non_options(main.vet_options)
|
||||
mut paths := cmdline.only_non_options(vet_options)
|
||||
vtmp := os.getenv('VTMP')
|
||||
if vtmp != '' {
|
||||
// `v test-cleancode` passes also `-o tmpfolder` as well as all options in VFLAGS
|
||||
@ -57,7 +57,7 @@ fn main() {
|
||||
}
|
||||
if path.ends_with('.v') || path.ends_with('.vv') {
|
||||
if path.contains('cmd/tools/vvet/tests/') {
|
||||
if main.is_force || paths.len == 1 {
|
||||
if is_force || paths.len == 1 {
|
||||
vet.vet_file(path, true)
|
||||
continue
|
||||
} else {
|
||||
@ -79,7 +79,7 @@ fn main() {
|
||||
files << vfiles
|
||||
files << vvfiles
|
||||
for file in files {
|
||||
if !main.is_force && file.ends_with('.vv') && file.contains('cmd/tools/vvet/tests/') {
|
||||
if !is_force && file.ends_with('.vv') && file.contains('cmd/tools/vvet/tests/') {
|
||||
continue
|
||||
}
|
||||
vet.vet_file(file, false)
|
||||
@ -90,7 +90,7 @@ fn main() {
|
||||
warnings := vet.errors.filter(it.kind == .warning)
|
||||
errors := vet.errors.filter(it.kind == .error)
|
||||
errors_vfmt := vet.errors.filter(it.kind == .error && it.fix == .vfmt)
|
||||
if main.show_warnings {
|
||||
if show_warnings {
|
||||
for err in warnings {
|
||||
eprintln('$err.file_path:$err.pos.line_nr: warning: $err.message')
|
||||
}
|
||||
|
Reference in New Issue
Block a user