From f28e67d52693961b378f50de8baa5aa99cedf99e Mon Sep 17 00:00:00 2001 From: Swastik Baranwal Date: Thu, 18 Mar 2021 18:36:16 +0530 Subject: [PATCH] cmd/tools/v/vdoc: keep `_` sep in numeric literals and highlight modules properly (#9358) --- cmd/tools/vdoc/utils.v | 8 ++++++-- vlib/v/doc/doc.v | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/tools/vdoc/utils.v b/cmd/tools/vdoc/utils.v index e97fca7c69..304d4d9ac4 100644 --- a/cmd/tools/vdoc/utils.v +++ b/cmd/tools/vdoc/utils.v @@ -189,7 +189,7 @@ fn color_highlight(code string, tb &table.Table) string { } return lit } - mut s := scanner.new_scanner(code, .parse_comments, &pref.Preferences{}) + mut s := scanner.new_scanner(code, .parse_comments, &pref.Preferences{ is_fmt: true }) mut prev_prev := token.Token{} mut prev := token.Token{} mut tok := s.scan() @@ -215,7 +215,11 @@ fn color_highlight(code string, tb &table.Table) string { if tok.lit in ['C', 'JS'] { tok_typ = .prefix } else { - tok_typ = .module_ + if tok.lit[0].ascii_str().is_upper() { + tok_typ = .symbol + } else { + tok_typ = .module_ + } } } else if tok.lit in ['r', 'c'] && next_tok.kind == .string { tok_typ = .prefix diff --git a/vlib/v/doc/doc.v b/vlib/v/doc/doc.v index ee814d2e10..c3d87b8fa7 100644 --- a/vlib/v/doc/doc.v +++ b/vlib/v/doc/doc.v @@ -100,6 +100,7 @@ pub fn new_vdoc_preferences() &pref.Preferences { // so its preferences should be permissive: return &pref.Preferences{ enable_globals: true + is_fmt: true } }