1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vdoc: fix v doc sokol const formatting

This commit is contained in:
Delyan Angelov 2020-06-15 18:28:00 +03:00
parent 0cd9066f44
commit 62a872b8b5
2 changed files with 11 additions and 5 deletions

View File

@ -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{
out: strings.new_builder(1000)
out_imports: strings.new_builder(200)
table: d.table
file: file
cur_mod: d.head.name.split('.').last()
indent: 0
is_debug: false
}
f.process_file_imports(file)
match stmt {
ast.Module {
return 'module $it.name'
@ -331,7 +333,7 @@ pub fn (mut d Doc) generate() ?bool {
if stmt is ast.Import {
continue
}
signature := d.get_signature(stmt)
signature := d.get_signature(stmt, file_ast)
pos := d.get_pos(stmt)
mut name := d.get_name(stmt)
if (!signature.starts_with('pub') && d.pub_only) || stmt is ast.GlobalDecl {

View File

@ -45,9 +45,7 @@ pub fn fmt(file ast.File, table &table.Table, is_debug bool) string {
file: file
is_debug: is_debug
}
for imp in file.imports {
f.mod2alias[imp.mod.all_after_last('.')] = imp.alias
}
f.process_file_imports(file)
f.cur_mod = 'main'
for stmt in file.stmts {
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'
}
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) {
for comment in f.file.comments {