1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vdoc: if toc_slug is empty use the one from first child (#7533)

This commit is contained in:
Lukas Neubert 2020-12-25 16:01:43 +01:00 committed by GitHub
parent 3345925883
commit 72b0421f3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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