mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vdoc: show variadic args correctly
This commit is contained in:
parent
ee0a0afb25
commit
6c85e285e7
@ -19,17 +19,23 @@ pub fn (node &FnDecl) str(t &table.Table) string {
|
|||||||
sym := t.get_type_symbol(node.receiver.typ)
|
sym := t.get_type_symbol(node.receiver.typ)
|
||||||
name := sym.name.after('.')
|
name := sym.name.after('.')
|
||||||
m := if node.rec_mut { 'mut ' } else { '' }
|
m := if node.rec_mut { 'mut ' } else { '' }
|
||||||
receiver = '($node.receiver.name ${m}$name) '
|
receiver = '($node.receiver.name $m$name) '
|
||||||
}
|
}
|
||||||
name := node.name.after('.')
|
name := node.name.after('.')
|
||||||
f.write('fn ${receiver}${name}(')
|
f.write('fn ${receiver}${name}(')
|
||||||
for i, arg in node.args {
|
for i, arg in node.args {
|
||||||
is_last_arg := i == node.args.len - 1
|
is_last_arg := i == node.args.len - 1
|
||||||
should_add_type := is_last_arg || node.args[i + 1].typ != arg.typ
|
should_add_type := is_last_arg || node.args[i + 1].typ != arg.typ ||
|
||||||
|
(node.is_variadic && i == node.args.len - 2)
|
||||||
f.write(arg.name)
|
f.write(arg.name)
|
||||||
if should_add_type {
|
if should_add_type {
|
||||||
|
if node.is_variadic && is_last_arg {
|
||||||
|
f.write(' ...' + t.type_to_str(arg.typ))
|
||||||
|
}
|
||||||
|
else {
|
||||||
f.write(' ' + t.type_to_str(arg.typ))
|
f.write(' ' + t.type_to_str(arg.typ))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if !is_last_arg {
|
if !is_last_arg {
|
||||||
f.write(', ')
|
f.write(', ')
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user