vdoc: HTML highlight generic function as function, not name (#13923)

pull/13927/head
Nick Treleaven 2022-04-03 21:41:02 +01:00 committed by GitHub
parent 44603f8e59
commit d10135e2c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 3 deletions

View File

@ -326,7 +326,8 @@ fn html_highlight(code string, tb &ast.Table) string {
tok_typ = .builtin
} else if next_tok.kind == .lcbr {
tok_typ = .symbol
} else if next_tok.kind == .lpar {
} else if next_tok.kind == .lpar
|| (!tok.lit[0].is_capital() && next_tok.kind == .lt) {
tok_typ = .function
} else {
tok_typ = .name

View File

@ -206,7 +206,7 @@ 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].ascii_str().is_upper() || prev_prev.lit in ['C', 'JS']) {
&& (tok.lit[0].is_capital() || prev_prev.lit in ['C', 'JS']) {
tok_typ = .symbol
} else if next_tok.kind in [.lpar, .lt] {
tok_typ = .function
@ -214,7 +214,7 @@ fn color_highlight(code string, tb &ast.Table) string {
if tok.lit in ['C', 'JS'] {
tok_typ = .prefix
} else {
if tok.lit[0].ascii_str().is_upper() {
if tok.lit[0].is_capital() {
tok_typ = .symbol
} else {
tok_typ = .module_

View File

@ -449,6 +449,7 @@ pub fn (nn u64) hex_full() string {
}
// str returns the contents of `byte` as a zero terminated `string`.
// See also: [`byte.ascii_str`](#byte.ascii_str)
// Example: assert byte(111).str() == '111'
pub fn (b byte) str() string {
return int(b).str_l(7)

View File

@ -1208,6 +1208,7 @@ pub fn (s string) to_upper() string {
}
// is_upper returns `true` if all characters in the string is uppercase.
// See also: [`byte.is_capital`](#byte.is_capital)
// Example: assert 'HELLO V'.is_upper() == true
[direct_array_access]
pub fn (s string) is_upper() bool {