Skip to content

Commit

Permalink
vdoc: include the project root folder, when searching for readme of `…
Browse files Browse the repository at this point in the history
…src/` (#19000)
  • Loading branch information
ttytm committed Jul 29, 2023
1 parent 1c2b4e7 commit e78e468
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 0 deletions.
@@ -0,0 +1 @@
hello from readme
@@ -0,0 +1,3 @@
module foo

fn bar()
@@ -0,0 +1,4 @@
hello from readme
module foo

fn bar()
@@ -0,0 +1,3 @@
module foo

pub fn bar() {}
Empty file.
5 changes: 5 additions & 0 deletions cmd/tools/vdoc/tests/vdoc_file_test.v
Expand Up @@ -52,6 +52,11 @@ fn check_path(vexe string, dir string, tests []string) int {
cmd: '${os.quoted_path(vexe)} doc -comments ${os.quoted_path(program)}'
out_filename: 'main.comments.out'
)
fails += check_output(
program: program
cmd: '${os.quoted_path(vexe)} doc -readme -comments ${os.quoted_path(program)}'
out_filename: 'main.readme.comments.out'
)
total_fails += fails
if fails == 0 {
println(term.green('OK'))
Expand Down
3 changes: 3 additions & 0 deletions cmd/tools/vdoc/vdoc.v
Expand Up @@ -233,6 +233,9 @@ fn (vd VDoc) get_readme(path string) string {
}
}
if fname == '' {
if path.all_after_last(os.path_separator) == 'src' {
return vd.get_readme(path.all_before_last(os.path_separator))
}
return ''
}
readme_path := os.join_path(path, '${fname}.md')
Expand Down

0 comments on commit e78e468

Please sign in to comment.