From 2596b0c612370a64f21be33fcc7ef7c6db0b364c Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 2 Jun 2020 23:56:13 +0300 Subject: [PATCH] vdoc: enable printing README.md on stdout too --- cmd/tools/vdoc.v | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/cmd/tools/vdoc.v b/cmd/tools/vdoc.v index 566516da62..0dd70b9ee2 100644 --- a/cmd/tools/vdoc.v +++ b/cmd/tools/vdoc.v @@ -342,8 +342,8 @@ fn (mut config DocConfig) generate_docs_from_file() { output_type = .plaintext } } - if config.include_readme && output_type != .html { - eprintln('vdoc: Including README.md for doc generation is supported on HTML output only.') + if config.include_readme && output_type !in [.html, .stdout] { + eprintln('vdoc: Including README.md for doc generation is supported on HTML output, or when running directly in the terminal.') exit(1) } mut manifest_path := os.join_path(if os.is_dir(config.src_path) { config.src_path } else { os.base_dir(config.src_path) }, 'v.mod') @@ -362,14 +362,18 @@ fn (mut config DocConfig) generate_docs_from_file() { } // check README.md if os.exists(readme_path) && config.include_readme { - println('Found README.md...') readme_contents := os.read_file(readme_path) or { '' } - config.docs << doc.Doc{ - head: doc.DocNode{ - name: 'README', - comment: readme_contents + if output_type == .stdout { + println(readme_contents) + } + if output_type == .html { + config.docs << doc.Doc{ + head: doc.DocNode{ + name: 'README', + comment: readme_contents + } } - } + } } if config.is_multi { dirs := get_modules_list(config.src_path)