1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vdoc: add -comments and new comment merger (#11221)

This commit is contained in:
Leo Developer
2021-08-19 09:20:43 +02:00
committed by GitHub
parent 337c325109
commit 7bffabbce2
15 changed files with 208 additions and 53 deletions

View File

@@ -51,6 +51,7 @@ mut:
is_verbose bool
include_readme bool
include_examples bool = true
include_comments bool // for plaintext
inline_assets bool
no_timestamp bool
output_path string
@@ -95,13 +96,15 @@ fn (vd VDoc) gen_plaintext(d doc.Doc) string {
} else {
pw.writeln('$d.head.content\n')
}
comments := if cfg.include_examples {
d.head.merge_comments()
} else {
d.head.merge_comments_without_examples()
}
if comments.trim_space().len > 0 && !cfg.pub_only {
pw.writeln(comments.split_into_lines().map(' ' + it).join('\n'))
if cfg.include_comments {
comments := if cfg.include_examples {
d.head.merge_comments()
} else {
d.head.merge_comments_without_examples()
}
if comments.trim_space().len > 0 {
pw.writeln(comments.split_into_lines().map(' ' + it).join('\n'))
}
}
vd.write_plaintext_content(d.contents.arr(), mut pw)
return pw.str()
@@ -116,7 +119,7 @@ fn (vd VDoc) write_plaintext_content(contents []doc.DocNode, mut pw strings.Buil
} else {
pw.writeln(cn.content)
}
if cn.comments.len > 0 && !cfg.pub_only {
if cn.comments.len > 0 && cfg.include_comments {
comments := if cfg.include_examples {
cn.merge_comments()
} else {
@@ -414,6 +417,9 @@ fn parse_arguments(args []string) Config {
'-l' {
cfg.show_loc = true
}
'-comments' {
cfg.include_comments = true
}
'-m' {
cfg.is_multi = true
}