1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v doc: show a proper error message instead of panic on v doc -m file.v

This commit is contained in:
Delyan Angelov 2021-10-09 11:56:30 +03:00
parent e267106220
commit 32ea53960e
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -325,6 +325,10 @@ fn (mut vd VDoc) generate_docs_from_file() {
docs << vd.docs.filter(it.head.name != 'builtin')
vd.docs = docs
}
if dirs.len == 0 && cfg.is_multi {
eprintln('vdoc: -m requires at least 1 module folder')
exit(1)
}
vd.vprintln('Rendering docs...')
if out.path.len == 0 || out.path == 'stdout' {
if out.typ == .html {
@ -332,7 +336,11 @@ fn (mut vd VDoc) generate_docs_from_file() {
}
outputs := vd.render(out)
if outputs.len == 0 {
if dirs.len == 0 {
eprintln('vdoc: No documentation found')
} else {
eprintln('vdoc: No documentation found for ${dirs[0]}')
}
exit(1)
} else {
first := outputs.keys()[0]