vdoc: fix symbol filtering (#9210)
parent
00399b49ab
commit
114a7db6e5
|
@ -292,7 +292,7 @@ fn (mut vd VDoc) generate_docs_from_file() {
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dcs = doc.generate(dirpath, cfg.pub_only, true) or {
|
dcs = doc.generate(dirpath, cfg.pub_only, true, cfg.symbol_name) or {
|
||||||
vd.emit_generate_err(err)
|
vd.emit_generate_err(err)
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
@ -316,13 +316,6 @@ fn (mut vd VDoc) generate_docs_from_file() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !cfg.is_multi && cfg.symbol_name.len > 0 {
|
|
||||||
if cfg.symbol_name in dcs.contents {
|
|
||||||
for _, c in dcs.contents[cfg.symbol_name].children {
|
|
||||||
dcs.contents[c.name] = c
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
vd.docs << dcs
|
vd.docs << dcs
|
||||||
}
|
}
|
||||||
|
@ -449,7 +442,9 @@ fn parse_arguments(args []string) Config {
|
||||||
else {
|
else {
|
||||||
if cfg.input_path.len < 1 {
|
if cfg.input_path.len < 1 {
|
||||||
cfg.input_path = arg
|
cfg.input_path = arg
|
||||||
} else {
|
} else if !cfg.is_multi {
|
||||||
|
// Symbol name filtering should not be enabled
|
||||||
|
// in multi-module documentation mode.
|
||||||
cfg.symbol_name = arg
|
cfg.symbol_name = arg
|
||||||
}
|
}
|
||||||
if i == args.len - 1 {
|
if i == args.len - 1 {
|
||||||
|
|
|
@ -67,6 +67,7 @@ pub mut:
|
||||||
parent_mod_name string
|
parent_mod_name string
|
||||||
orig_mod_name string
|
orig_mod_name string
|
||||||
extract_vars bool
|
extract_vars bool
|
||||||
|
filter_symbol_names []string
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DocPos {
|
pub struct DocPos {
|
||||||
|
@ -230,6 +231,10 @@ pub fn (mut d Doc) stmt(stmt ast.Stmt, filename string) ?DocNode {
|
||||||
return error('invalid stmt type to document')
|
return error('invalid stmt type to document')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
included := node.name in d.filter_symbol_names || node.parent_name in d.filter_symbol_names
|
||||||
|
if d.filter_symbol_names.len != 0 && !included {
|
||||||
|
return error('not included in the list of symbol names')
|
||||||
|
}
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,10 +433,11 @@ pub fn (mut d Doc) file_asts(file_asts []ast.File) ? {
|
||||||
|
|
||||||
// generate documents a certain file directory and returns an
|
// generate documents a certain file directory and returns an
|
||||||
// instance of `Doc` if it is successful. Otherwise, it will throw an error.
|
// instance of `Doc` if it is successful. Otherwise, it will throw an error.
|
||||||
pub fn generate(input_path string, pub_only bool, with_comments bool) ?Doc {
|
pub fn generate(input_path string, pub_only bool, with_comments bool, filter_symbol_names ...string) ?Doc {
|
||||||
mut doc := new(input_path)
|
mut doc := new(input_path)
|
||||||
doc.pub_only = pub_only
|
doc.pub_only = pub_only
|
||||||
doc.with_comments = with_comments
|
doc.with_comments = with_comments
|
||||||
|
doc.filter_symbol_names = filter_symbol_names.filter(it.len != 0)
|
||||||
doc.generate() ?
|
doc.generate() ?
|
||||||
return doc
|
return doc
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue