vdoc: fix a panic on `v doc -s modname` with an empty module

pull/5442/head
Delyan Angelov 2020-06-20 19:33:44 +03:00
parent 37927235cd
commit 8a6beac692
1 changed files with 7 additions and 1 deletions

View File

@ -127,9 +127,15 @@ fn open_url(url string) {
}
fn (mut cfg DocConfig) serve_html() {
server_url := 'http://localhost:' + cfg.server_port.str()
docs := cfg.render()
dkeys := docs.keys()
if dkeys.len < 1 {
eprintln('no documentation created, the module has no `pub` functions')
exit(1)
}
def_name := docs.keys()[0]
//
server_url := 'http://localhost:' + cfg.server_port.str()
server := net.listen(cfg.server_port) or {
panic(err)
}