tools,v.doc: let https://modules.vlang.io use vlib/README.md as the index page. (#23480)

This commit is contained in:
Delyan Angelov 2025-01-16 03:15:16 +02:00 committed by GitHub
parent d680c4227b
commit e5153e7be7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 87 additions and 40 deletions

View file

@ -12,12 +12,15 @@ fn escape(str string) string {
}
fn get_sym_name(dn doc.DocNode) string {
sym_name := if dn.parent_name.len > 0 && dn.parent_name != 'void' {
'(${dn.parent_name}) ${dn.name}'
} else {
dn.name
if dn.is_readme {
if title := dn.frontmatter['title'] {
return title
}
}
return sym_name
if dn.parent_name.len > 0 && dn.parent_name != 'void' {
return '(${dn.parent_name}) ${dn.name}'
}
return dn.name
}
fn get_node_id(dn doc.DocNode) string {
@ -30,7 +33,7 @@ fn get_node_id(dn doc.DocNode) string {
}
fn is_module_readme(dn doc.DocNode) bool {
return dn.comments.len > 0 && (dn.content == 'module ${dn.name}' || dn.name == 'README')
return dn.is_readme || (dn.comments.len > 0 && dn.content == 'module ${dn.name}')
}
// trim_doc_node_description returns the nodes trimmed description.