mirror of
https://github.com/vlang/v.git
synced 2025-09-17 19:36:35 -04:00
vdoc: cleanup node.v
(#21250)
This commit is contained in:
parent
6be2717680
commit
6dc417e662
@ -6,11 +6,10 @@ pub const should_sort = os.getenv_opt('VDOC_SORT') or { 'true' }.bool()
|
||||
|
||||
pub fn (nodes []DocNode) find(symname string) !DocNode {
|
||||
for node in nodes {
|
||||
if node.name != symname {
|
||||
continue
|
||||
}
|
||||
if node.name == symname {
|
||||
return node
|
||||
}
|
||||
}
|
||||
return error('symbol not found')
|
||||
}
|
||||
|
||||
@ -29,15 +28,13 @@ pub fn (mut nodes []DocNode) sort_by_kind() {
|
||||
}
|
||||
|
||||
fn compare_nodes_by_kind(a &DocNode, b &DocNode) int {
|
||||
ak := int((*a).kind)
|
||||
bk := int((*b).kind)
|
||||
if ak < bk {
|
||||
return -1
|
||||
ak := int(a.kind)
|
||||
bk := int(b.kind)
|
||||
return match true {
|
||||
ak < bk { -1 }
|
||||
ak > bk { 1 }
|
||||
else { 0 }
|
||||
}
|
||||
if ak > bk {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
fn compare_nodes_by_name(a &DocNode, b &DocNode) int {
|
||||
@ -48,7 +45,7 @@ fn compare_nodes_by_name(a &DocNode, b &DocNode) int {
|
||||
|
||||
// arr() converts the map into an array of `DocNode`.
|
||||
pub fn (cnts map[string]DocNode) arr() []DocNode {
|
||||
mut contents := cnts.keys().map(cnts[it])
|
||||
mut contents := cnts.values()
|
||||
contents.sort_by_name()
|
||||
contents.sort_by_kind()
|
||||
return contents
|
||||
|
Loading…
x
Reference in New Issue
Block a user