diff --git a/.gitignore b/.gitignore index 5abc519ab1..6fbc12584d 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,5 @@ cachegrind.out.* ._* thumbs.db /.symlink/* + +_docs \ No newline at end of file diff --git a/cmd/tools/vdoc.v b/cmd/tools/vdoc.v index db2ba25b59..e0cc995a13 100644 --- a/cmd/tools/vdoc.v +++ b/cmd/tools/vdoc.v @@ -7,16 +7,17 @@ import os import os.cmdline import strings import v.doc -import v.util import v.vmod const ( + allowed_formats = ['md', 'markdown', 'json', 'text', 'stdout', 'html', 'htm'] exe_path = os.executable() exe_dir = os.dir(exe_path) res_path = os.join_path(exe_dir, 'vdoc-resources') ) enum OutputType { + unset html markdown json @@ -25,15 +26,18 @@ enum OutputType { } struct DocConfig { - pub_only bool = true - show_loc bool = false // for plaintext - serve_http bool = false // for html - is_multi bool = false - include_readme bool = false mut: - opath string - src_path string - docs []doc.Doc + pub_only bool = true + show_loc bool = false // for plaintext + serve_http bool = false // for html + is_multi bool = false + is_verbose bool = false + include_readme bool = false + inline_assets bool = false + output_path string + input_path string + output_type OutputType = .unset + docs []doc.Doc manifest vmod.Manifest } @@ -54,7 +58,7 @@ fn open_url(url string) { } fn (mut cfg DocConfig) serve_html() { - docs := cfg.multi_render(.html) + docs := cfg.render() def_name := docs.keys()[0] server := net.listen(8046) or { panic(err) @@ -113,7 +117,7 @@ fn (cfg DocConfig) gen_json(idx int) string { mut jw := strings.new_builder(200) jw.writeln('{\n\t"module_name": "$dcs.head.name",\n\t"description": "${escape(dcs.head.comment)}",\n\t"contents": [') for i, cn in dcs.contents { - name := cn.name[dcs.head.name.len+1..] + name := cn.name.all_after(dcs.head.name) jw.writeln('\t\t{') jw.writeln('\t\t\t"name": "$name",') jw.writeln('\t\t\t"signature": "${escape(cn.content)}",') @@ -174,20 +178,25 @@ fn (cfg DocConfig) gen_html(idx int) string {