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:
parent
3345925883
commit
72b0421f3e
@ -411,7 +411,10 @@ fn (cfg DocConfig) readme_idx() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn write_toc(cn doc.DocNode, nodes []doc.DocNode, mut toc strings.Builder) {
|
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>')
|
toc.write('<li class="open"><a href="#$toc_slug">$cn.name</a>')
|
||||||
if cn.name != 'Constants' {
|
if cn.name != 'Constants' {
|
||||||
toc.writeln(' <ul>')
|
toc.writeln(' <ul>')
|
||||||
|
Loading…
Reference in New Issue
Block a user