From eccf707270d632fee92de2490525945345c088ae Mon Sep 17 00:00:00 2001 From: Ned Palacios <7358345+nedpals@users.noreply.github.com> Date: Thu, 18 Mar 2021 21:04:53 +0800 Subject: [PATCH] vdoc: improve error message for non-existing symbols (#9359) --- cmd/tools/vdoc/vdoc.v | 3 ++- vlib/v/doc/doc.v | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/tools/vdoc/vdoc.v b/cmd/tools/vdoc/vdoc.v index 0f89e0b307..3bcb900178 100644 --- a/cmd/tools/vdoc/vdoc.v +++ b/cmd/tools/vdoc/vdoc.v @@ -330,7 +330,8 @@ fn (mut vd VDoc) generate_docs_from_file() { } outputs := vd.render(out) if outputs.len == 0 { - println('No documentation for $dirs') + eprintln('vdoc: No documentation found for ${dirs[0]}') + exit(1) } else { first := outputs.keys()[0] println(outputs[first]) diff --git a/vlib/v/doc/doc.v b/vlib/v/doc/doc.v index 29983234c5..ee814d2e10 100644 --- a/vlib/v/doc/doc.v +++ b/vlib/v/doc/doc.v @@ -231,10 +231,6 @@ pub fn (mut d Doc) stmt(stmt ast.Stmt, filename string) ?DocNode { return error('invalid stmt type to document') } } - included := node.name in d.filter_symbol_names || node.parent_name in d.filter_symbol_names - if d.filter_symbol_names.len != 0 && !included { - return error('not included in the list of symbol names') - } return node } @@ -428,6 +424,13 @@ pub fn (mut d Doc) file_asts(file_asts []ast.File) ? { } } } + if d.filter_symbol_names.len != 0 && d.contents.len != 0 { + for filter_name in d.filter_symbol_names { + if filter_name !in d.contents { + return error('vdoc: `$filter_name` symbol in module `$d.orig_mod_name` not found') + } + } + } d.time_generated = time.now() }