vdoc: fix panic on empty `//` comment on `v doc -f html file.v`; turn `expected code block after empty example` to a warning
parent
cf92224248
commit
4da2908d63
|
@ -303,7 +303,7 @@ fn html_highlight(code string, tb &ast.Table) string {
|
||||||
} else if typ == .char {
|
} else if typ == .char {
|
||||||
'`$tok.lit`'
|
'`$tok.lit`'
|
||||||
} else if typ == .comment {
|
} else if typ == .comment {
|
||||||
if tok.lit[0] == 1 { '//${tok.lit[1..]}' } else { '//$tok.lit' }
|
if tok.lit != '' && tok.lit[0] == 1 { '//${tok.lit[1..]}' } else { '//$tok.lit' }
|
||||||
} else {
|
} else {
|
||||||
tok.lit
|
tok.lit
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
module main
|
module main
|
||||||
|
|
||||||
const (
|
const (
|
||||||
source_root = 'temp'
|
source_root = 'temp' // some const
|
||||||
|
another = int(5) //
|
||||||
)
|
)
|
||||||
|
const (
|
||||||
|
windowpos_undefined_mask = C.SDL_WINDOWPOS_UNDEFINED_MASK // 0x1FFF0000u
|
||||||
|
windowpos_undefined = C.SDL_WINDOWPOS_UNDEFINED //
|
||||||
|
)
|
||||||
|
Used to indicate that you don't care what the window position is.
|
||||||
fn funky()
|
fn funky()
|
||||||
funky - comment for function below
|
funky - comment for function below
|
|
@ -1,6 +1,11 @@
|
||||||
module main
|
module main
|
||||||
|
|
||||||
const (
|
const (
|
||||||
source_root = 'temp'
|
source_root = 'temp' // some const
|
||||||
|
another = int(5) //
|
||||||
|
)
|
||||||
|
const (
|
||||||
|
windowpos_undefined_mask = C.SDL_WINDOWPOS_UNDEFINED_MASK // 0x1FFF0000u
|
||||||
|
windowpos_undefined = C.SDL_WINDOWPOS_UNDEFINED //
|
||||||
)
|
)
|
||||||
fn funky()
|
fn funky()
|
|
@ -1,5 +1,12 @@
|
||||||
pub const (
|
pub const (
|
||||||
source_root = 'temp'
|
source_root = 'temp' // some const
|
||||||
|
another = int(5) //
|
||||||
|
)
|
||||||
|
|
||||||
|
// Used to indicate that you don't care what the window position is.
|
||||||
|
pub const (
|
||||||
|
windowpos_undefined_mask = C.SDL_WINDOWPOS_UNDEFINED_MASK // 0x1FFF0000u
|
||||||
|
windowpos_undefined = C.SDL_WINDOWPOS_UNDEFINED //
|
||||||
)
|
)
|
||||||
|
|
||||||
// funky - comment for function below
|
// funky - comment for function below
|
||||||
|
|
|
@ -162,7 +162,11 @@ fn color_highlight(code string, tb &ast.Table) string {
|
||||||
lit = term.yellow('`$tok.lit`')
|
lit = term.yellow('`$tok.lit`')
|
||||||
}
|
}
|
||||||
.comment {
|
.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 {
|
.keyword {
|
||||||
lit = term.bright_blue(tok.lit)
|
lit = term.bright_blue(tok.lit)
|
||||||
|
@ -209,16 +213,18 @@ fn color_highlight(code string, tb &ast.Table) string {
|
||||||
} else if
|
} else if
|
||||||
next_tok.kind in [.lcbr, .rpar, .eof, .comma, .pipe, .name, .rcbr, .assign, .key_pub, .key_mut, .pipe, .comma]
|
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]
|
&& 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
|
tok_typ = .symbol
|
||||||
} else if next_tok.kind == .lpar || (!tok.lit[0].is_capital()
|
} else if next_tok.kind == .lpar
|
||||||
&& next_tok.kind == .lt && next_tok.pos == tok.pos + tok.lit.len) {
|
|| (!(tok.lit != '' && tok.lit[0].is_capital()) && next_tok.kind == .lt
|
||||||
|
&& next_tok.pos == tok.pos + tok.lit.len) {
|
||||||
tok_typ = .function
|
tok_typ = .function
|
||||||
} else if next_tok.kind == .dot {
|
} else if next_tok.kind == .dot {
|
||||||
if tok.lit in ['C', 'JS'] {
|
if tok.lit in ['C', 'JS'] {
|
||||||
tok_typ = .prefix
|
tok_typ = .prefix
|
||||||
} else {
|
} else {
|
||||||
if tok.lit[0].is_capital() {
|
if tok.lit != '' && tok.lit[0].is_capital() {
|
||||||
tok_typ = .symbol
|
tok_typ = .symbol
|
||||||
} else {
|
} else {
|
||||||
tok_typ = .module_
|
tok_typ = .module_
|
||||||
|
|
|
@ -62,13 +62,12 @@ pub fn (dc DocNode) merge_comments_without_examples() string {
|
||||||
if dc.comments[i].is_multi_line_example() {
|
if dc.comments[i].is_multi_line_example() {
|
||||||
i++
|
i++
|
||||||
if i == dc.comments.len || !dc.comments[i].has_triple_backtick() {
|
if i == dc.comments.len || !dc.comments[i].has_triple_backtick() {
|
||||||
eprintln('$dc.file_path:$dc.pos.line_nr: Expected code block after empty example line:')
|
eprintln('$dc.file_path:$dc.pos.line_nr: warning: expected code block after empty example line:')
|
||||||
eprintln('// ```')
|
eprintln('// ```')
|
||||||
if i < dc.comments.len {
|
if i < dc.comments.len {
|
||||||
eprintln('Found:')
|
eprintln('Found:')
|
||||||
eprintln('//' + dc.comments[i].text[1..])
|
eprintln('//' + dc.comments[i].text[1..])
|
||||||
}
|
}
|
||||||
exit(1)
|
|
||||||
}
|
}
|
||||||
i++
|
i++
|
||||||
for i < dc.comments.len && !dc.comments[i].has_triple_backtick() {
|
for i < dc.comments.len && !dc.comments[i].has_triple_backtick() {
|
||||||
|
|
Loading…
Reference in New Issue