Skip to content

Commit 32ea539

Browse files
committed
v doc: show a proper error message instead of panic on v doc -m file.v
1 parent e267106 commit 32ea539

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cmd/tools/vdoc/vdoc.v

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,22 @@ fn (mut vd VDoc) generate_docs_from_file() {
325325
docs << vd.docs.filter(it.head.name != 'builtin')
326326
vd.docs = docs
327327
}
328+
if dirs.len == 0 && cfg.is_multi {
329+
eprintln('vdoc: -m requires at least 1 module folder')
330+
exit(1)
331+
}
328332
vd.vprintln('Rendering docs...')
329333
if out.path.len == 0 || out.path == 'stdout' {
330334
if out.typ == .html {
331335
vd.render_static_html(out)
332336
}
333337
outputs := vd.render(out)
334338
if outputs.len == 0 {
335-
eprintln('vdoc: No documentation found for ${dirs[0]}')
339+
if dirs.len == 0 {
340+
eprintln('vdoc: No documentation found')
341+
} else {
342+
eprintln('vdoc: No documentation found for ${dirs[0]}')
343+
}
336344
exit(1)
337345
} else {
338346
first := outputs.keys()[0]

0 commit comments

Comments
 (0)