Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vdoc: minor cleanup #21258

Merged
merged 3 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions cmd/tools/vdoc/html.v
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ fn html_highlight(code string, tb &ast.Table) string {

buf.write_string('<span class="token ${final_tok_typ}">')
if tok_typ == .string {
// Make sure to escape html in strings. Otherwise it will rendered in the
// Make sure to escape html in strings. Otherwise it will be rendered in the
// html documentation outputs / its style rules will affect the readme.
buf.write_string("'${html.escape(tok.lit.str())}'")
} else {
Expand Down Expand Up @@ -514,11 +514,10 @@ fn doc_node_html(dn doc.DocNode, link string, head bool, include_examples bool,
for i := 0; i < readme_lines.len - 1; i++ {
l := readme_lines[i]
nl := readme_lines[i + 1]
is_codeblock_divider := l.trim_left('\x01').trim_space().starts_with('```')
if is_codeblock_divider {
if l.trim_left('\x01').trim_space().starts_with('```') {
is_codeblock = !is_codeblock
}
if !is_codeblock && !is_codeblock_divider && l != '' && nl != ''
if !is_codeblock && l != '' && nl != ''
&& !nl.trim_left('\x01').trim_space().starts_with('```') {
merged_lines << '${l} ${nl}'
i++
Expand Down
6 changes: 1 addition & 5 deletions cmd/tools/vdoc/tests/vdoc_file_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@ import v.util.diff
const vexe_path = @VEXE
const vexe = os.quoted_path(vexe_path)
const vroot = os.dir(vexe_path)
const diff_cmd = find_diff_cmd()
const should_autofix = os.getenv('VAUTOFIX') != ''

fn find_diff_cmd() string {
return diff.find_working_diff_command() or { '' }
}

fn test_vet() {
os.setenv('VCOLORS', 'never', true)
os.chdir(vroot)!
Expand Down Expand Up @@ -125,6 +120,7 @@ fn check_path(dir string, tests []string) int {
}

fn print_compare(expected string, found string) {
diff_cmd := diff.find_working_diff_command() or { return }
println(term.red('FAIL'))
println('============')
println('expected:')
Expand Down