vdoc: make vexe_path a const

pull/5228/head
Don Alfons Nisnoni 2020-06-05 20:22:50 +08:00 committed by GitHub
parent 0aadde2673
commit 44442223a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 17 deletions

View File

@ -14,6 +14,7 @@ const (
exe_path = os.executable() exe_path = os.executable()
exe_dir = os.dir(exe_path) exe_dir = os.dir(exe_path)
res_path = os.join_path(exe_dir, 'vdoc-resources') res_path = os.join_path(exe_dir, 'vdoc-resources')
vexe_path = os.base_dir(@VEXE)
) )
enum OutputType { enum OutputType {
@ -384,7 +385,7 @@ fn (mut cfg DocConfig) generate_docs_from_file() {
} }
is_vlib := 'vlib' in cfg.input_path is_vlib := 'vlib' in cfg.input_path
dir_path := if is_vlib { dir_path := if is_vlib {
os.base_dir(@VEXE) vexe_path
} else if os.is_dir(cfg.input_path) { } else if os.is_dir(cfg.input_path) {
cfg.input_path cfg.input_path
} else { } else {
@ -486,7 +487,6 @@ fn (cfg DocConfig) vprintln(str string) {
fn lookup_module(mod string) ?string { fn lookup_module(mod string) ?string {
mod_path := mod.replace('.', os.path_separator) mod_path := mod.replace('.', os.path_separator)
vexe_path := os.base_dir(@VEXE)
compile_dir := os.real_path(os.base_dir('.')) compile_dir := os.real_path(os.base_dir('.'))
modules_dir := os.join_path(compile_dir, 'modules', mod_path) modules_dir := os.join_path(compile_dir, 'modules', mod_path)
vlib_path := os.join_path(vexe_path, 'vlib', mod_path) vlib_path := os.join_path(vexe_path, 'vlib', mod_path)
@ -595,7 +595,7 @@ fn main() {
is_path := cfg.input_path.ends_with('.v') || cfg.input_path.split(os.path_separator).len > 1 || cfg.input_path == '.' is_path := cfg.input_path.ends_with('.v') || cfg.input_path.split(os.path_separator).len > 1 || cfg.input_path == '.'
if cfg.input_path == 'vlib' { if cfg.input_path == 'vlib' {
cfg.is_multi = true cfg.is_multi = true
cfg.input_path = os.join_path(os.base_dir(@VEXE), 'vlib') cfg.input_path = os.join_path(vexe_path, 'vlib')
} else if !is_path { } else if !is_path {
cfg.vprintln('Input "$cfg.input_path" is not a valid path. Looking for modules named "$cfg.input_path"...') cfg.vprintln('Input "$cfg.input_path" is not a valid path. Looking for modules named "$cfg.input_path"...')
mod_path := lookup_module(cfg.input_path) or { mod_path := lookup_module(cfg.input_path) or {