Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: fix duplication in toc #19726

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions cmd/tools/vdoc/html.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Comment on lines +215 to +216
Copy link
Member

@ttytm ttytm Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the names array this could be

	names := dc.head.name.split('.')
	submod_prefix := names[0] or { dc.head.name }

Or even simpler

	submod_prefix := dc.head.name.all_before('.')

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
spytheman marked this conversation as resolved.
Show resolved Hide resolved
mut href_name := './${dc.head.name}.html'
if (cfg.is_vlib && dc.head.name == 'builtin' && !cfg.include_readme)
|| dc.head.name == 'README' {
Expand Down