<$head_tag>$sym_name$hash_link$head_tag>')
} else {
dnw.write_string('${tabs[2]}
<$head_tag>$dn.kind $sym_name$hash_link$head_tag>')
}
if link.len != 0 {
dnw.write_string('
$link_svg')
}
dnw.write_string('
')
}
if tags.len > 0 || has_deprecated {
mut attributes := if has_deprecated {
'
deprecated
'
} else {
''
}
attributes += tags.map('
$it
').join('')
dnw.writeln('
$attributes
')
}
if !head && dn.content.len > 0 {
dnw.writeln('
$highlighted_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()
return dnw_str
}
fn html_tag_escape(str string) string {
excaped_string := str.replace_each(['<', '<', '>', '>'])
mut re := regex.regex_opt(r'`.+[(<)(>)].+`') or { regex.RE{} }
if re.find_all_str(excaped_string).len > 0 {
return str
}
return excaped_string
}
/*
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_string(trimmed)
}
js_str := js.str()
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) {
if dn.comments.len == 0 || (dn.comments.len > 0 && dn.comments[0].text.len == 0) {
return
}
toc.write_string('
README')
} else if dn.name != 'Constants' {
toc.write_string('$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_string('$dn.name')
}
toc.writeln('')
}