vdoc: fix generating documentation for 3rd-party modules (#6651)
parent
3ae3196d42
commit
74ebce6b1f
|
@ -238,21 +238,21 @@ pub fn (nodes []DocNode) find_nodes_with_attr(attr_name string, value string) []
|
||||||
// For example, given something like /languages/v/vlib/x/websocket/tests/autobahn
|
// For example, given something like /languages/v/vlib/x/websocket/tests/autobahn
|
||||||
// it returns `x.websocket.tests`, because /languages/v/ has v.mod file in it.
|
// it returns `x.websocket.tests`, because /languages/v/ has v.mod file in it.
|
||||||
// NB: calling this is expensive, so keep the result, instead of recomputing it.
|
// NB: calling this is expensive, so keep the result, instead of recomputing it.
|
||||||
fn get_parent_mod(dir string) ?string {
|
fn get_parent_mod(input_dir string) ?string {
|
||||||
$if windows {
|
$if windows {
|
||||||
// windows root path is C: or D:
|
// windows root path is C: or D:
|
||||||
if dir.len <= 2 {
|
if input_dir.len <= 2 {
|
||||||
return error('root folder reached')
|
return error('root folder reached')
|
||||||
}
|
}
|
||||||
} $else {
|
} $else {
|
||||||
if dir.len == 0 {
|
if input_dir.len == 0 {
|
||||||
return error('root folder reached')
|
return error('root folder reached')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
base_dir := os.dir(dir)
|
base_dir := os.dir(input_dir)
|
||||||
fname_base_dir := os.file_name(base_dir)
|
input_dir_name := os.file_name(input_dir)
|
||||||
prefs := new_vdoc_preferences()
|
prefs := new_vdoc_preferences()
|
||||||
fentries := os.ls(base_dir) or {
|
fentries := os.ls(input_dir) or {
|
||||||
[]string{}
|
[]string{}
|
||||||
}
|
}
|
||||||
files := fentries.filter(!os.is_dir(it))
|
files := fentries.filter(!os.is_dir(it))
|
||||||
|
@ -260,13 +260,13 @@ fn get_parent_mod(dir string) ?string {
|
||||||
// the top level is reached, no point in climbing up further
|
// the top level is reached, no point in climbing up further
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
v_files := prefs.should_compile_filtered_files(base_dir, files)
|
v_files := prefs.should_compile_filtered_files(input_dir, files)
|
||||||
if v_files.len == 0 {
|
if v_files.len == 0 {
|
||||||
parent_mod := get_parent_mod(base_dir) or {
|
parent_mod := get_parent_mod(base_dir) or {
|
||||||
return fname_base_dir
|
return input_dir_name
|
||||||
}
|
}
|
||||||
if parent_mod.len > 0 {
|
if parent_mod.len > 0 {
|
||||||
return parent_mod + '.' + fname_base_dir
|
return parent_mod + '.' + input_dir_name
|
||||||
}
|
}
|
||||||
return error('No V files found.')
|
return error('No V files found.')
|
||||||
}
|
}
|
||||||
|
@ -279,10 +279,10 @@ fn get_parent_mod(dir string) ?string {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
parent_mod := get_parent_mod(base_dir) or {
|
parent_mod := get_parent_mod(base_dir) or {
|
||||||
return fname_base_dir
|
return error(err)
|
||||||
}
|
}
|
||||||
if parent_mod.len > 0 {
|
if parent_mod.len > 0 {
|
||||||
return parent_mod + '.' + file_ast.mod.name
|
return parent_mod
|
||||||
}
|
}
|
||||||
return file_ast.mod.name
|
return file_ast.mod.name
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue