vdoc: improve error message for non-existing symbols (#9359)

pull/9352/head
Ned Palacios 2021-03-18 21:04:53 +08:00 committed by GitHub
parent 7bbcf02134
commit eccf707270
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -330,7 +330,8 @@ fn (mut vd VDoc) generate_docs_from_file() {
} }
outputs := vd.render(out) outputs := vd.render(out)
if outputs.len == 0 { if outputs.len == 0 {
println('No documentation for $dirs') eprintln('vdoc: No documentation found for ${dirs[0]}')
exit(1)
} else { } else {
first := outputs.keys()[0] first := outputs.keys()[0]
println(outputs[first]) println(outputs[first])

View File

@ -231,10 +231,6 @@ pub fn (mut d Doc) stmt(stmt ast.Stmt, filename string) ?DocNode {
return error('invalid stmt type to document') 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 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() d.time_generated = time.now()
} }