doc: fix duplication in toc (#19726)

This commit is contained in:
Daniel Däschle 2023-11-02 10:52:34 +01:00 committed by GitHub
parent 8f05b0feea
commit 1e80e47b79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -210,13 +210,14 @@ fn (vd VDoc) gen_html(d doc.Doc) string {
}
// write nav1
if cfg.is_multi || vd.docs.len > 1 {
mut submod_prefix := ''
mut used_submod_prefix := []string{}
for i, dc in vd.docs {
if i - 1 >= 0 && dc.head.name.starts_with(submod_prefix + '.') {
names := dc.head.name.split('.')
submod_prefix := if names.len > 1 { names[0] } else { dc.head.name }
if i - 1 >= 0 && submod_prefix in used_submod_prefix {
continue
}
names := dc.head.name.split('.')
submod_prefix = if names.len > 1 { names[0] } else { dc.head.name }
used_submod_prefix << submod_prefix
mut href_name := './${dc.head.name}.html'
if (cfg.is_vlib && dc.head.name == 'builtin' && !cfg.include_readme)
|| dc.head.name == 'README' {