Skip to content

Commit 15f0f8a

Browse files
committed
vdoc: support v doc -check-examples -f none vlib/builtin
1 parent 5058fd7 commit 15f0f8a

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎cmd/tools/vdoc/main.v‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const vexe = os.getenv_opt('VEXE') or { @VEXE }
1010

1111
const vroot = os.dir(vexe)
1212

13-
const allowed_formats = ['md', 'markdown', 'json', 'text', 'ansi', 'html', 'htm']
13+
const allowed_formats = ['md', 'markdown', 'json', 'text', 'ansi', 'html', 'htm', 'none']
1414

1515
enum RunExampleMode {
1616
skip

‎cmd/tools/vdoc/utils.v‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ fn set_output_type_from_str(format string) OutputType {
7373
'md', 'markdown' { .markdown }
7474
'json' { .json }
7575
'text' { .plaintext }
76+
'none' { .none }
7677
else { .ansi }
7778
}
7879
}

‎cmd/tools/vdoc/vdoc.v‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct Readme {
1919

2020
enum OutputType {
2121
unset
22+
none
2223
html
2324
markdown
2425
json
@@ -151,6 +152,7 @@ fn (mut vd VDoc) write_plaintext_content(contents []doc.DocNode, mut pw strings.
151152
fn (mut vd VDoc) render_doc(d doc.Doc, out Output) (string, string) {
152153
name := vd.get_file_name(d.head.name, out)
153154
output := match out.typ {
155+
.none { '' }
154156
.html { vd.gen_html(d) }
155157
.markdown { vd.gen_markdown(d, true) }
156158
.json { vd.gen_json(d) }
@@ -190,9 +192,11 @@ fn (mut vd VDoc) work_processor(mut work sync.Channel, mut wg sync.WaitGroup) {
190192
}
191193
vd.vprintln('> start processing ${pdoc.d.base_path} ...')
192194
file_name, content := vd.render_doc(pdoc.d, pdoc.out)
193-
output_path := os.join_path(pdoc.out.path, file_name)
194-
println('Generating ${content.len:8} bytes of ${pdoc.out.typ} in `${output_path}` ...')
195-
os.write_file(output_path, content) or { panic(err) }
195+
if vd.cfg.output_type != .none {
196+
output_path := os.join_path(pdoc.out.path, file_name)
197+
println('Generating ${content.len:8} bytes of ${pdoc.out.typ} in `${output_path}` ...')
198+
os.write_file(output_path, content) or { panic(err) }
199+
}
196200
}
197201
wg.done()
198202
}
@@ -301,7 +305,7 @@ fn (mut vd VDoc) generate_docs_from_file() {
301305
ext := os.file_ext(out.path)
302306
out.typ = set_output_type_from_str(ext.all_after('.'))
303307
}
304-
if cfg.include_readme && out.typ !in [.html, .ansi, .plaintext] {
308+
if cfg.include_readme && out.typ !in [.html, .ansi, .plaintext, .none] {
305309
eprintln('vdoc: Including README.md for doc generation is supported on HTML output, or when running directly in the terminal.')
306310
exit(1)
307311
}

‎vlib/v/help/common/doc.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ Options:
2020
-no-color Forces plain text output, without ANSI colors.
2121
Note: -color is on for -f ansi .
2222
-f Specifies the output format to be used.
23-
Available formats are: md/markdown, json, text, ansi and html/htm.
23+
Available formats are: none, md/markdown, json, text, ansi and html/htm.
24+
Note: the format `none` is mostly useful in combination with -check-examples .
2425
-h, -help Prints this help text.
2526
-m Generate docs for modules listed in that folder.
2627
-o The output file/folder path where to store the docs. Use `-o stdout`

0 commit comments

Comments
 (0)