vdoc: fix `v doc sokol` const formatting
parent
0cd9066f44
commit
62a872b8b5
|
@ -112,15 +112,17 @@ fn convert_pos(file_path string, pos token.Position) DocPos {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (d Doc) get_signature(stmt ast.Stmt) string {
|
pub fn (d Doc) get_signature(stmt ast.Stmt, file &ast.File) string {
|
||||||
mut f := fmt.Fmt{
|
mut f := fmt.Fmt{
|
||||||
out: strings.new_builder(1000)
|
out: strings.new_builder(1000)
|
||||||
out_imports: strings.new_builder(200)
|
out_imports: strings.new_builder(200)
|
||||||
table: d.table
|
table: d.table
|
||||||
|
file: file
|
||||||
cur_mod: d.head.name.split('.').last()
|
cur_mod: d.head.name.split('.').last()
|
||||||
indent: 0
|
indent: 0
|
||||||
is_debug: false
|
is_debug: false
|
||||||
}
|
}
|
||||||
|
f.process_file_imports(file)
|
||||||
match stmt {
|
match stmt {
|
||||||
ast.Module {
|
ast.Module {
|
||||||
return 'module $it.name'
|
return 'module $it.name'
|
||||||
|
@ -331,7 +333,7 @@ pub fn (mut d Doc) generate() ?bool {
|
||||||
if stmt is ast.Import {
|
if stmt is ast.Import {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
signature := d.get_signature(stmt)
|
signature := d.get_signature(stmt, file_ast)
|
||||||
pos := d.get_pos(stmt)
|
pos := d.get_pos(stmt)
|
||||||
mut name := d.get_name(stmt)
|
mut name := d.get_name(stmt)
|
||||||
if (!signature.starts_with('pub') && d.pub_only) || stmt is ast.GlobalDecl {
|
if (!signature.starts_with('pub') && d.pub_only) || stmt is ast.GlobalDecl {
|
||||||
|
|
|
@ -45,9 +45,7 @@ pub fn fmt(file ast.File, table &table.Table, is_debug bool) string {
|
||||||
file: file
|
file: file
|
||||||
is_debug: is_debug
|
is_debug: is_debug
|
||||||
}
|
}
|
||||||
for imp in file.imports {
|
f.process_file_imports(file)
|
||||||
f.mod2alias[imp.mod.all_after_last('.')] = imp.alias
|
|
||||||
}
|
|
||||||
f.cur_mod = 'main'
|
f.cur_mod = 'main'
|
||||||
for stmt in file.stmts {
|
for stmt in file.stmts {
|
||||||
if stmt is ast.Import {
|
if stmt is ast.Import {
|
||||||
|
@ -63,6 +61,12 @@ pub fn fmt(file ast.File, table &table.Table, is_debug bool) string {
|
||||||
return res[..f.import_pos] + f.out_imports.str() + res[f.import_pos..] // + '\n'
|
return res[..f.import_pos] + f.out_imports.str() + res[f.import_pos..] // + '\n'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn (mut f Fmt) process_file_imports(file &ast.File) {
|
||||||
|
for imp in file.imports {
|
||||||
|
f.mod2alias[imp.mod.all_after_last('.')] = imp.alias
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
fn (mut f Fmt) find_comment(line_nr int) {
|
fn (mut f Fmt) find_comment(line_nr int) {
|
||||||
for comment in f.file.comments {
|
for comment in f.file.comments {
|
||||||
|
|
Loading…
Reference in New Issue