<$head_tag>$sym_name$hash_link$head_tag>')
} else {
dnw.write('${tabs[2]}
<$head_tag>$dn.kind $sym_name$hash_link$head_tag>')
}
if link.len != 0 {
dnw.write('
$main.link_svg')
}
dnw.write('
')
}
if !head && dn.content.len > 0 {
dnw.writeln('
$hlighted_code
')
}
// do not mess with md_content further, its formatting is important, just output it 1:1 !
dnw.writeln('$md_content\n')
// Write examples if any found
examples := dn.examples()
if include_examples && examples.len > 0 {
example_title := if examples.len > 1 { 'Examples' } else { 'Example' }
dnw.writeln('
$example_title
')
for example in examples {
// hl_example := html_highlight(example, tb)
dnw.writeln('$example
')
}
dnw.writeln('')
}
dnw.writeln('')
dnw_str := dnw.str()
defer {
dnw.free()
}
return dnw_str
}
fn html_tag_escape(str string) string {
return str.replace_each(['<', '<', '>', '>'])
}
/*
fn js_compress(str string) string {
mut js := strings.new_builder(200)
lines := str.split_into_lines()
rules := [') {', ' = ', ', ', '{ ', ' }', ' (', '; ', ' + ', ' < ', ' - ', ' || ', ' var',
': ', ' >= ', ' && ', ' else if', ' === ', ' !== ', ' else ']
clean := ['){', '=', ',', '{', '}', '(', ';', '+', '<', '-', '||', 'var', ':', '>=', '&&',
'else if', '===', '!==', 'else']
for line in lines {
mut trimmed := line.trim_space()
if trimmed.starts_with('//') || (trimmed.starts_with('/*') && trimmed.ends_with('*/')) {
continue
}
for i in 0 .. rules.len - 1 {
trimmed = trimmed.replace(rules[i], clean[i])
}
js.write(trimmed)
}
js_str := js.str()
js.free()
return js_str
}
*/
fn write_toc(dn doc.DocNode, mut toc strings.Builder) {
mut toc_slug := if dn.name.len == 0 || dn.content.len == 0 { '' } else { slug(dn.name) }
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)
}
}
if is_module_readme(dn) {
toc.write('
README')
} else if dn.name != 'Constants' {
toc.write('$dn.kind $dn.name')
toc.writeln(' ')
for child in dn.children {
cname := dn.name + '.' + child.name
toc.writeln('- $child.kind $child.name
')
}
toc.writeln('
')
} else {
toc.write('$dn.name')
}
toc.writeln('')
}