mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
vdoc: support v doc -check-examples -f none vlib/builtin
This commit is contained in:
parent
5058fd7b79
commit
15f0f8a481
4 changed files with 12 additions and 6 deletions
|
@ -10,7 +10,7 @@ const vexe = os.getenv_opt('VEXE') or { @VEXE }
|
||||||
|
|
||||||
const vroot = os.dir(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 {
|
enum RunExampleMode {
|
||||||
skip
|
skip
|
||||||
|
|
|
@ -73,6 +73,7 @@ fn set_output_type_from_str(format string) OutputType {
|
||||||
'md', 'markdown' { .markdown }
|
'md', 'markdown' { .markdown }
|
||||||
'json' { .json }
|
'json' { .json }
|
||||||
'text' { .plaintext }
|
'text' { .plaintext }
|
||||||
|
'none' { .none }
|
||||||
else { .ansi }
|
else { .ansi }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ struct Readme {
|
||||||
|
|
||||||
enum OutputType {
|
enum OutputType {
|
||||||
unset
|
unset
|
||||||
|
none
|
||||||
html
|
html
|
||||||
markdown
|
markdown
|
||||||
json
|
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) {
|
fn (mut vd VDoc) render_doc(d doc.Doc, out Output) (string, string) {
|
||||||
name := vd.get_file_name(d.head.name, out)
|
name := vd.get_file_name(d.head.name, out)
|
||||||
output := match out.typ {
|
output := match out.typ {
|
||||||
|
.none { '' }
|
||||||
.html { vd.gen_html(d) }
|
.html { vd.gen_html(d) }
|
||||||
.markdown { vd.gen_markdown(d, true) }
|
.markdown { vd.gen_markdown(d, true) }
|
||||||
.json { vd.gen_json(d) }
|
.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} ...')
|
vd.vprintln('> start processing ${pdoc.d.base_path} ...')
|
||||||
file_name, content := vd.render_doc(pdoc.d, pdoc.out)
|
file_name, content := vd.render_doc(pdoc.d, pdoc.out)
|
||||||
output_path := os.join_path(pdoc.out.path, file_name)
|
if vd.cfg.output_type != .none {
|
||||||
println('Generating ${content.len:8} bytes of ${pdoc.out.typ} in `${output_path}` ...')
|
output_path := os.join_path(pdoc.out.path, file_name)
|
||||||
os.write_file(output_path, content) or { panic(err) }
|
println('Generating ${content.len:8} bytes of ${pdoc.out.typ} in `${output_path}` ...')
|
||||||
|
os.write_file(output_path, content) or { panic(err) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
wg.done()
|
wg.done()
|
||||||
}
|
}
|
||||||
|
@ -301,7 +305,7 @@ fn (mut vd VDoc) generate_docs_from_file() {
|
||||||
ext := os.file_ext(out.path)
|
ext := os.file_ext(out.path)
|
||||||
out.typ = set_output_type_from_str(ext.all_after('.'))
|
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.')
|
eprintln('vdoc: Including README.md for doc generation is supported on HTML output, or when running directly in the terminal.')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,8 @@ Options:
|
||||||
-no-color Forces plain text output, without ANSI colors.
|
-no-color Forces plain text output, without ANSI colors.
|
||||||
Note: -color is on for -f ansi .
|
Note: -color is on for -f ansi .
|
||||||
-f Specifies the output format to be used.
|
-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.
|
-h, -help Prints this help text.
|
||||||
-m Generate docs for modules listed in that folder.
|
-m Generate docs for modules listed in that folder.
|
||||||
-o The output file/folder path where to store the docs. Use `-o stdout`
|
-o The output file/folder path where to store the docs. Use `-o stdout`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue