From 8a6beac692077c29183e93a664d8c05fe1925939 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 20 Jun 2020 19:33:44 +0300 Subject: [PATCH] vdoc: fix a panic on `v doc -s modname` with an empty module --- cmd/tools/vdoc.v | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/tools/vdoc.v b/cmd/tools/vdoc.v index 968f11a756..cbde014ad3 100644 --- a/cmd/tools/vdoc.v +++ b/cmd/tools/vdoc.v @@ -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) }