tools: improve the output of ./v doc -m -f html vlib/

This commit is contained in:
Delyan Angelov 2025-08-01 18:44:40 +03:00
parent ca620f4965
commit 2a9d1b204b
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
3 changed files with 7 additions and 7 deletions

View file

@ -79,8 +79,10 @@ fn (vd &VDoc) render_search_index(out Output) {
}
js_search_index.writeln('];\n')
js_search_data.writeln('];\n')
final := js_search_index.str() + js_search_data.str()
out_file_path := os.join_path(out.path, 'search_index.js')
os.write_file(out_file_path, js_search_index.str() + js_search_data.str()) or { panic(err) }
println('Generating search_index.js of ${final.len:8} bytes in `${out_file_path} ...')
os.write_file(out_file_path, final) or { panic(err) }
}
fn (mut vd VDoc) render_static_html(out Output) {
@ -115,7 +117,7 @@ fn (vd &VDoc) get_resource(name string, out Output) string {
} else {
output_path := os.join_path(out.path, name)
if !os.exists(output_path) {
println('Generating ${out.typ} in "${output_path}"')
println('Generating ${res.len:8} bytes of static resources in `${output_path}` ...')
os.write_file(output_path, res) or { panic(err) }
}
return name

View file

@ -42,6 +42,7 @@ mut:
}
fn main() {
unbuffer_stdout() // avoid the need for flush_stdout() calls
if os.args.len < 2 || '-h' in os.args || '-help' in os.args || '--help' in os.args
|| os.args[1..] == ['doc', 'help'] {
os.system('${os.quoted_path(vexe)} help doc')

View file

@ -188,11 +188,9 @@ fn (mut vd VDoc) work_processor(mut work sync.Channel, mut wg sync.WaitGroup) {
break
}
vd.vprintln('> start processing ${pdoc.d.base_path} ...')
flush_stdout()
file_name, content := vd.render_doc(pdoc.d, pdoc.out)
output_path := os.join_path(pdoc.out.path, file_name)
println('Generating ${pdoc.out.typ} in "${output_path}"')
flush_stdout()
println('Generating ${content.len:8} bytes of ${pdoc.out.typ} in `${output_path}` ...')
os.write_file(output_path, content) or { panic(err) }
}
wg.done()
@ -436,15 +434,14 @@ fn (mut vd VDoc) generate_docs_from_file() {
vd.render_search_index(out)
// move favicons to target directory
println('Copying favicons...')
favicons_path := os.join_path(cfg.theme_dir, 'favicons')
favicons := os.ls(favicons_path) or { panic(err) }
for favicon in favicons {
favicon_path := os.join_path(favicons_path, favicon)
destination_path := os.join_path(out.path, favicon)
os.cp(favicon_path, destination_path) or { panic(err) }
}
println('Copied ${favicons.len} icons to `${out.path}` .')
}
}
}