From 32ea53960e10f0c6f8a6e4bc81204336a5a4af27 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 9 Oct 2021 11:56:30 +0300 Subject: [PATCH] v doc: show a proper error message instead of panic on `v doc -m file.v` --- cmd/tools/vdoc/vdoc.v | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/tools/vdoc/vdoc.v b/cmd/tools/vdoc/vdoc.v index fcf119c90b..cb4ddb11e1 100644 --- a/cmd/tools/vdoc/vdoc.v +++ b/cmd/tools/vdoc/vdoc.v @@ -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 { - eprintln('vdoc: No documentation found for ${dirs[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]