vdoc: fix toc Constants link (#7810)

pull/7755/head^2
Lukas Neubert 2021-01-02 19:18:17 +01:00 committed by GitHub
parent 9980de39c3
commit 38c764f0ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -462,8 +462,12 @@ fn (cfg DocConfig) readme_idx() int {
fn write_toc(dn doc.DocNode, nodes []doc.DocNode, mut toc strings.Builder) { fn write_toc(dn doc.DocNode, nodes []doc.DocNode, mut toc strings.Builder) {
mut toc_slug := if dn.name.len == 0 || dn.content.len == 0 { '' } else { slug(dn.name) } mut toc_slug := if dn.name.len == 0 || dn.content.len == 0 { '' } else { slug(dn.name) }
if toc_slug == '' && dn.children.len > 0 { if toc_slug == '' && dn.children.len > 0 {
if dn.children[0].name == '' {
toc_slug = slug(dn.name)
} else {
toc_slug = slug(dn.name + '.' + dn.children[0].name) toc_slug = slug(dn.name + '.' + dn.children[0].name)
} }
}
if dn.name != 'Constants' { if dn.name != 'Constants' {
toc.write('<li class="open"><a href="#$toc_slug">$dn.kind $dn.name</a>') toc.write('<li class="open"><a href="#$toc_slug">$dn.kind $dn.name</a>')
toc.writeln(' <ul>') toc.writeln(' <ul>')