mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
vdoc: fix panic on empty //
comment on v doc -f html file.v
; turn expected code block after empty example
to a warning
This commit is contained in:
parent
cf92224248
commit
4da2908d63
6 changed files with 36 additions and 13 deletions
|
@ -162,7 +162,11 @@ fn color_highlight(code string, tb &ast.Table) string {
|
|||
lit = term.yellow('`$tok.lit`')
|
||||
}
|
||||
.comment {
|
||||
lit = if tok.lit[0] == 1 { '//${tok.lit[1..]}' } else { '//$tok.lit' }
|
||||
lit = if tok.lit != '' && tok.lit[0] == 1 {
|
||||
'//${tok.lit[1..]}'
|
||||
} else {
|
||||
'//$tok.lit'
|
||||
}
|
||||
}
|
||||
.keyword {
|
||||
lit = term.bright_blue(tok.lit)
|
||||
|
@ -209,16 +213,18 @@ fn color_highlight(code string, tb &ast.Table) string {
|
|||
} else if
|
||||
next_tok.kind in [.lcbr, .rpar, .eof, .comma, .pipe, .name, .rcbr, .assign, .key_pub, .key_mut, .pipe, .comma]
|
||||
&& prev.kind in [.name, .amp, .rsbr, .key_type, .assign, .dot, .question, .rpar, .key_struct, .key_enum, .pipe, .key_interface]
|
||||
&& (tok.lit[0].is_capital() || prev_prev.lit in ['C', 'JS']) {
|
||||
&& ((tok.lit != '' && tok.lit[0].is_capital())
|
||||
|| prev_prev.lit in ['C', 'JS']) {
|
||||
tok_typ = .symbol
|
||||
} else if next_tok.kind == .lpar || (!tok.lit[0].is_capital()
|
||||
&& next_tok.kind == .lt && next_tok.pos == tok.pos + tok.lit.len) {
|
||||
} else if next_tok.kind == .lpar
|
||||
|| (!(tok.lit != '' && tok.lit[0].is_capital()) && next_tok.kind == .lt
|
||||
&& next_tok.pos == tok.pos + tok.lit.len) {
|
||||
tok_typ = .function
|
||||
} else if next_tok.kind == .dot {
|
||||
if tok.lit in ['C', 'JS'] {
|
||||
tok_typ = .prefix
|
||||
} else {
|
||||
if tok.lit[0].is_capital() {
|
||||
if tok.lit != '' && tok.lit[0].is_capital() {
|
||||
tok_typ = .symbol
|
||||
} else {
|
||||
tok_typ = .module_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue