1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: smarter if condition wrapping (#8201)

This commit is contained in:
Lukas Neubert
2021-01-23 09:33:22 +01:00
committed by GitHub
parent 9812230847
commit 8b61891348
65 changed files with 686 additions and 811 deletions

View File

@ -266,9 +266,8 @@ fn (vd VDoc) gen_html(d doc.Doc) string {
names := dc.head.name.split('.')
submod_prefix = if names.len > 1 { names[0] } else { dc.head.name }
mut href_name := './${dc.head.name}.html'
if (cfg.is_vlib && dc.head.name == 'builtin' && !cfg.include_readme) ||
dc.head.name == 'README'
{
if (cfg.is_vlib && dc.head.name == 'builtin' && !cfg.include_readme)
|| dc.head.name == 'README' {
href_name = './index.html'
} else if submod_prefix !in vd.docs.map(it.head.name) {
href_name = '#'
@ -303,19 +302,19 @@ fn (vd VDoc) gen_html(d doc.Doc) string {
header_name).replace('{{ version }}', version).replace('{{ light_icon }}', vd.assets['light_icon']).replace('{{ dark_icon }}',
vd.assets['dark_icon']).replace('{{ menu_icon }}', vd.assets['menu_icon']).replace('{{ head_assets }}',
if cfg.inline_assets {
'\n${tabs[0]}<style>' + vd.assets['doc_css'] + '</style>\n${tabs[0]}<style>' + vd.assets['normalize_css'] +
'</style>\n${tabs[0]}<script>' + vd.assets['dark_mode_js'] + '</script>'
'\n${tabs[0]}<style>' + vd.assets['doc_css'] + '</style>\n${tabs[0]}<style>' +
vd.assets['normalize_css'] + '</style>\n${tabs[0]}<script>' +
vd.assets['dark_mode_js'] + '</script>'
} else {
'\n${tabs[0]}<link rel="stylesheet" href="' + vd.assets['doc_css'] + '" />\n${tabs[0]}<link rel="stylesheet" href="' +
vd.assets['normalize_css'] + '" />\n${tabs[0]}<script src="' + vd.assets['dark_mode_js'] +
'"></script>'
'\n${tabs[0]}<link rel="stylesheet" href="' + vd.assets['doc_css'] +
'" />\n${tabs[0]}<link rel="stylesheet" href="' + vd.assets['normalize_css'] +
'" />\n${tabs[0]}<script src="' + vd.assets['dark_mode_js'] + '"></script>'
}).replace('{{ toc_links }}', if cfg.is_multi || vd.docs.len > 1 {
modules_toc_str
} else {
symbols_toc_str
}).replace('{{ contents }}', contents.str()).replace('{{ right_content }}', if cfg.is_multi &&
vd.docs.len > 1 && d.head.name != 'README'
{
}).replace('{{ contents }}', contents.str()).replace('{{ right_content }}', if cfg.is_multi
&& vd.docs.len > 1&& d.head.name != 'README' {
'<div class="doc-toc"><ul>' + symbols_toc_str + '</ul></div>'
} else {
''
@ -405,9 +404,8 @@ fn html_highlight(code string, tb &table.Table) string {
else {
if token.is_key(tok.lit) || token.is_decl(tok.kind) {
tok_typ = .keyword
} else if tok.kind == .decl_assign || tok.kind.is_assign() || tok.is_unary() ||
tok.kind.is_relational() || tok.kind.is_infix()
{
} else if tok.kind == .decl_assign || tok.kind.is_assign() || tok.is_unary()
|| tok.kind.is_relational()|| tok.kind.is_infix() {
tok_typ = .operator
}
}