vdoc: sort function names

pull/3855/head
yuyi 2020-02-27 03:46:09 +08:00 committed by GitHub
parent 70f085be18
commit 46ec400cb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 9 deletions

View File

@ -47,7 +47,7 @@ pub fn doc(mod string, table &table.Table) string {
d.stmts << file_ast.stmts
}
d.print_fns()
d.writeln('')
d.out.writeln('')
d.print_methods()
/*
for stmt in file_ast.stmts {
@ -59,36 +59,44 @@ pub fn doc(mod string, table &table.Table) string {
return d.out.str()
}
fn (d mut Doc) writeln(s string) {
d.out.writeln(s)
}
fn (d mut Doc) write_fn_node(f ast.FnDecl) {
d.writeln(f.str(d.table).replace(d.mod + '.', ''))
fn (d &Doc) get_fn_node(f ast.FnDecl) string {
return f.str(d.table).replace(d.mod + '.', '')
}
fn (d mut Doc) print_fns() {
mut fn_names := []string
for stmt in d.stmts {
match stmt {
ast.FnDecl {
if it.is_pub && !it.is_method {
d.write_fn_node(it)
name := d.get_fn_node(it)
fn_names << name
}
}
else {}
}
}
fn_names.sort()
for s in fn_names {
d.out.writeln(s)
}
}
fn (d mut Doc) print_methods() {
mut fn_names := []string
for stmt in d.stmts {
match stmt {
ast.FnDecl {
if it.is_pub && it.is_method {
d.write_fn_node(it)
name := d.get_fn_node(it)
fn_names << name
}
}
else {}
}
}
fn_names.sort()
for s in fn_names {
d.out.writeln(s)
}
}