vdoc: remove local mode (#9282)

pull/9259/head
Ned Palacios 2021-03-13 13:49:03 +08:00 committed by GitHub
parent 21bbc24c49
commit 62458e3553
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 44 deletions

View File

@ -43,9 +43,6 @@ mut:
struct Config { struct Config {
mut: mut:
pub_only bool = true pub_only bool = true
is_local bool
local_filename string
local_pos int
show_loc bool // for plaintext show_loc bool // for plaintext
is_multi bool is_multi bool
is_vlib bool is_vlib bool
@ -282,38 +279,27 @@ fn (mut vd VDoc) generate_docs_from_file() {
} else { } else {
[cfg.input_path] [cfg.input_path]
} }
is_local_and_single := cfg.is_local && !cfg.is_multi
for dirpath in dirs { for dirpath in dirs {
mut dcs := doc.Doc{}
vd.vprintln('Generating $out.typ docs for "$dirpath"') vd.vprintln('Generating $out.typ docs for "$dirpath"')
if is_local_and_single { mut dcs := doc.generate(dirpath, cfg.pub_only, true, cfg.symbol_name) or {
dcs = doc.generate_with_pos(dirpath, cfg.local_filename, cfg.local_pos) or { vd.emit_generate_err(err)
vd.emit_generate_err(err) exit(1)
exit(1)
}
} else {
dcs = doc.generate(dirpath, cfg.pub_only, true, cfg.symbol_name) or {
vd.emit_generate_err(err)
exit(1)
}
} }
if dcs.contents.len == 0 { if dcs.contents.len == 0 {
continue continue
} }
if !is_local_and_single { if cfg.is_multi || (!cfg.is_multi && cfg.include_readme) {
if cfg.is_multi || (!cfg.is_multi && cfg.include_readme) { readme_contents := vd.get_readme(dirpath)
readme_contents := vd.get_readme(dirpath) comment := doc.DocComment{
comment := doc.DocComment{ text: readme_contents
text: readme_contents
}
dcs.head.comments = [comment]
} }
if cfg.pub_only { dcs.head.comments = [comment]
for name, dc in dcs.contents { }
dcs.contents[name].content = dc.content.all_after('pub ') if cfg.pub_only {
for i, cc in dc.children { for name, dc in dcs.contents {
dcs.contents[name].children[i].content = cc.content.all_after('pub ') dcs.contents[name].content = dc.content.all_after('pub ')
} for i, cc in dc.children {
dcs.contents[name].children[i].content = cc.content.all_after('pub ')
} }
} }
} }
@ -390,11 +376,6 @@ fn parse_arguments(args []string) Config {
'-all' { '-all' {
cfg.pub_only = false cfg.pub_only = false
} }
'-filename' {
cfg.is_local = true
cfg.local_filename = cmdline.option(current_args, '-filename', '')
i++
}
'-f' { '-f' {
format := cmdline.option(current_args, '-f', '') format := cmdline.option(current_args, '-f', '')
if format !in allowed_formats { if format !in allowed_formats {
@ -419,14 +400,6 @@ fn parse_arguments(args []string) Config {
cfg.output_path = if opath == 'stdout' { opath } else { os.real_path(opath) } cfg.output_path = if opath == 'stdout' { opath } else { os.real_path(opath) }
i++ i++
} }
'-pos' {
if !cfg.is_local {
eprintln('vdoc: `-pos` is only allowed with `-filename` flag.')
exit(1)
}
cfg.local_pos = cmdline.option(current_args, '-pos', '').int()
i++
}
'-no-timestamp' { '-no-timestamp' {
cfg.no_timestamp = true cfg.no_timestamp = true
} }

View File

@ -22,9 +22,7 @@ Options:
to a file. to a file.
-readme Include README.md to docs if present. -readme Include README.md to docs if present.
-v Enables verbose logging. For debugging purposes. -v Enables verbose logging. For debugging purposes.
-filename Specifies the specific file to document. -no-timestamp Omits the timestamp in the output file.
-pos Specifies the position. Used with `-filename`.
-no-timestamp Omit timestamp in the output file.
For HTML mode: For HTML mode:
-inline-assets Embeds the contents of the CSS and JS assets into the webpage directly. -inline-assets Embeds the contents of the CSS and JS assets into the webpage directly.