mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
parent
fd79183122
commit
491a1ac515
2 changed files with 31 additions and 1 deletions
|
@ -234,7 +234,10 @@ fn (vd &VDoc) get_readme(path string) Readme {
|
||||||
}
|
}
|
||||||
if fname == '' {
|
if fname == '' {
|
||||||
if path.all_after_last(os.path_separator) == 'src' {
|
if path.all_after_last(os.path_separator) == 'src' {
|
||||||
return vd.get_readme(path.all_before_last(os.path_separator))
|
next_path := path.all_before_last(os.path_separator)
|
||||||
|
if next_path != '' && path != next_path && os.is_dir(next_path) {
|
||||||
|
return vd.get_readme(next_path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Readme{}
|
return Readme{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ module main
|
||||||
import os
|
import os
|
||||||
import arrays
|
import arrays
|
||||||
|
|
||||||
|
const vexe_path = @VEXE
|
||||||
|
const vexe_ = os.quoted_path(vexe_path)
|
||||||
const tpath = os.join_path(os.vtmp_dir(), 'vod_test_module')
|
const tpath = os.join_path(os.vtmp_dir(), 'vod_test_module')
|
||||||
|
|
||||||
fn testsuite_begin() {
|
fn testsuite_begin() {
|
||||||
|
@ -104,3 +106,28 @@ fn test_get_module_list() {
|
||||||
// `delta` only contains a `_test.v` file.
|
// `delta` only contains a `_test.v` file.
|
||||||
assert !mod_list.any(it.contains(os.join_path(tpath, 'delta')))
|
assert !mod_list.any(it.contains(os.join_path(tpath, 'delta')))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_get_readme_md_src() {
|
||||||
|
// a special testcase for `src` dir get_readme
|
||||||
|
// https://github.com/vlang/v/issues/24232
|
||||||
|
|
||||||
|
os.mkdir('src')!
|
||||||
|
os.write_file('v.mod', "Module {
|
||||||
|
name: 'foobar'
|
||||||
|
description: 'foobar'
|
||||||
|
version: '0.0.0'
|
||||||
|
license: 'MIT'
|
||||||
|
dependencies: []
|
||||||
|
}
|
||||||
|
")!
|
||||||
|
os.write_file('src/foobar.v', 'module foobar
|
||||||
|
|
||||||
|
// square calculates the second power of `x`
|
||||||
|
pub fn square(x int) int {
|
||||||
|
return x * x
|
||||||
|
}
|
||||||
|
')!
|
||||||
|
res := os.execute_opt('${vexe_} doc -m src/ -v') or { panic(err) }
|
||||||
|
assert res.exit_code == 0
|
||||||
|
assert res.output.contains('square')
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue