mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v doc
: add highlighting for new types and fix highlighting for edge cases (#15455)
This commit is contained in:
parent
cd31108260
commit
22a79cfa1e
@ -138,8 +138,9 @@ fn gen_footer_text(d &doc.Doc, include_timestamp bool) string {
|
||||
}
|
||||
|
||||
fn color_highlight(code string, tb &ast.Table) string {
|
||||
builtin := ['bool', 'string', 'i8', 'i16', 'int', 'i64', 'i128', 'byte', 'u16', 'u32', 'u64',
|
||||
'u128', 'rune', 'f32', 'f64', 'int_literal', 'float_literal', 'byteptr', 'voidptr', 'any']
|
||||
builtin := ['bool', 'string', 'i8', 'i16', 'int', 'i64', 'i128', 'isize', 'byte', 'u8', 'u16',
|
||||
'u32', 'u64', 'usize', 'u128', 'rune', 'f32', 'f64', 'int_literal', 'float_literal',
|
||||
'byteptr', 'voidptr', 'any']
|
||||
highlight_code := fn (tok token.Token, typ HighlightTokenTyp) string {
|
||||
mut lit := ''
|
||||
match typ {
|
||||
@ -211,9 +212,10 @@ fn color_highlight(code string, tb &ast.Table) string {
|
||||
&& (next_tok.kind != .lpar || prev.kind !in [.key_fn, .rpar]) {
|
||||
tok_typ = .builtin
|
||||
} 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 != '' && tok.lit[0].is_capital())
|
||||
(next_tok.kind in [.lcbr, .rpar, .eof, .comma, .pipe, .name, .rcbr, .assign, .key_pub, .key_mut, .pipe, .comma, .comment]
|
||||
&& next_tok.lit !in builtin)
|
||||
&& (prev.kind in [.name, .amp, .lcbr, .rsbr, .key_type, .assign, .dot, .question, .rpar, .key_struct, .key_enum, .pipe, .key_interface, .comment]
|
||||
&& prev.lit !in builtin) && ((tok.lit != '' && tok.lit[0].is_capital())
|
||||
|| prev_prev.lit in ['C', 'JS']) {
|
||||
tok_typ = .symbol
|
||||
} else if next_tok.kind == .lpar
|
||||
|
Loading…
Reference in New Issue
Block a user