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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,8 +467,8 @@ fn parse_arguments(args []string) Config {
|
||||
} $else {
|
||||
cfg.input_path = cfg.input_path.replace('\\', os.path_separator)
|
||||
}
|
||||
is_path := cfg.input_path.ends_with('.v') || cfg.input_path.split(os.path_separator).len >
|
||||
1 || cfg.input_path == '.'
|
||||
is_path := cfg.input_path.ends_with('.v') || cfg.input_path.split(os.path_separator).len > 1
|
||||
|| cfg.input_path == '.'
|
||||
if cfg.input_path.trim_right('/') == 'vlib' {
|
||||
cfg.is_vlib = true
|
||||
cfg.is_multi = true
|
||||
|
||||
@@ -159,9 +159,8 @@ fn (mut vt Vet) vet_file(path string, is_regression_test bool) {
|
||||
// vet_line vets the contents of `line` from `vet.file`.
|
||||
fn (mut vet Vet) vet_line(lines []string, line string, lnumber int) {
|
||||
// Vet public functions
|
||||
if line.starts_with('pub fn') ||
|
||||
(line.starts_with('fn ') && !(line.starts_with('fn C.') || line.starts_with('fn main')))
|
||||
{
|
||||
if line.starts_with('pub fn') || (line.starts_with('fn ') && !(line.starts_with('fn C.')
|
||||
|| line.starts_with('fn main'))) {
|
||||
// Scan function declarations for missing documentation
|
||||
is_pub_fn := line.starts_with('pub fn')
|
||||
if lnumber > 0 {
|
||||
|
||||
Reference in New Issue
Block a user