diff --git a/cmd/tools/vdoc/main.v b/cmd/tools/vdoc/main.v index 8dacf3070d..dcd4a2e381 100644 --- a/cmd/tools/vdoc/main.v +++ b/cmd/tools/vdoc/main.v @@ -10,7 +10,7 @@ const vexe = os.getenv_opt('VEXE') or { @VEXE } const vroot = os.dir(vexe) -const allowed_formats = ['md', 'markdown', 'json', 'text', 'ansi', 'html', 'htm'] +const allowed_formats = ['md', 'markdown', 'json', 'text', 'ansi', 'html', 'htm', 'none'] enum RunExampleMode { skip diff --git a/cmd/tools/vdoc/utils.v b/cmd/tools/vdoc/utils.v index 2a0493573a..86675131bc 100644 --- a/cmd/tools/vdoc/utils.v +++ b/cmd/tools/vdoc/utils.v @@ -73,6 +73,7 @@ fn set_output_type_from_str(format string) OutputType { 'md', 'markdown' { .markdown } 'json' { .json } 'text' { .plaintext } + 'none' { .none } else { .ansi } } } diff --git a/cmd/tools/vdoc/vdoc.v b/cmd/tools/vdoc/vdoc.v index bc2f137f7f..9d122f9d5b 100644 --- a/cmd/tools/vdoc/vdoc.v +++ b/cmd/tools/vdoc/vdoc.v @@ -19,6 +19,7 @@ struct Readme { enum OutputType { unset + none html markdown json @@ -151,6 +152,7 @@ fn (mut vd VDoc) write_plaintext_content(contents []doc.DocNode, mut pw strings. fn (mut vd VDoc) render_doc(d doc.Doc, out Output) (string, string) { name := vd.get_file_name(d.head.name, out) output := match out.typ { + .none { '' } .html { vd.gen_html(d) } .markdown { vd.gen_markdown(d, true) } .json { vd.gen_json(d) } @@ -190,9 +192,11 @@ fn (mut vd VDoc) work_processor(mut work sync.Channel, mut wg sync.WaitGroup) { } vd.vprintln('> start processing ${pdoc.d.base_path} ...') file_name, content := vd.render_doc(pdoc.d, pdoc.out) - output_path := os.join_path(pdoc.out.path, file_name) - println('Generating ${content.len:8} bytes of ${pdoc.out.typ} in `${output_path}` ...') - os.write_file(output_path, content) or { panic(err) } + if vd.cfg.output_type != .none { + output_path := os.join_path(pdoc.out.path, file_name) + println('Generating ${content.len:8} bytes of ${pdoc.out.typ} in `${output_path}` ...') + os.write_file(output_path, content) or { panic(err) } + } } wg.done() } @@ -301,7 +305,7 @@ fn (mut vd VDoc) generate_docs_from_file() { ext := os.file_ext(out.path) out.typ = set_output_type_from_str(ext.all_after('.')) } - if cfg.include_readme && out.typ !in [.html, .ansi, .plaintext] { + if cfg.include_readme && out.typ !in [.html, .ansi, .plaintext, .none] { eprintln('vdoc: Including README.md for doc generation is supported on HTML output, or when running directly in the terminal.') exit(1) } diff --git a/vlib/v/help/common/doc.txt b/vlib/v/help/common/doc.txt index 0037f1ff27..926d0ec0b4 100644 --- a/vlib/v/help/common/doc.txt +++ b/vlib/v/help/common/doc.txt @@ -20,7 +20,8 @@ Options: -no-color Forces plain text output, without ANSI colors. Note: -color is on for -f ansi . -f Specifies the output format to be used. - Available formats are: md/markdown, json, text, ansi and html/htm. + Available formats are: none, md/markdown, json, text, ansi and html/htm. + Note: the format `none` is mostly useful in combination with -check-examples . -h, -help Prints this help text. -m Generate docs for modules listed in that folder. -o The output file/folder path where to store the docs. Use `-o stdout`