vdoc: fix the indentation of the generated html file (#7802)
parent
f7135979f5
commit
c8caf71282
|
@ -41,8 +41,7 @@ const (
|
||||||
favicons_path = os.join_path(res_path, 'favicons')
|
favicons_path = os.join_path(res_path, 'favicons')
|
||||||
vexe = pref.vexe_path()
|
vexe = pref.vexe_path()
|
||||||
vroot = os.dir(vexe)
|
vroot = os.dir(vexe)
|
||||||
html_content = '
|
html_content = '<!DOCTYPE html>
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
@ -97,8 +96,8 @@ const (
|
||||||
{{ footer_assets }}
|
{{ footer_assets }}
|
||||||
<script async src="search_index.js" type="text/javascript"></script>
|
<script async src="search_index.js" type="text/javascript"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>'
|
||||||
'
|
tabs = ['\t\t', '\t\t\t\t\t\t', '\t\t\t\t\t\t\t']
|
||||||
)
|
)
|
||||||
|
|
||||||
enum OutputType {
|
enum OutputType {
|
||||||
|
@ -406,12 +405,12 @@ fn doc_node_html(dd doc.DocNode, link string, head bool, tb &table.Table) string
|
||||||
sym_name := get_sym_name(dd)
|
sym_name := get_sym_name(dd)
|
||||||
node_id := get_node_id(dd)
|
node_id := get_node_id(dd)
|
||||||
hash_link := if !head { ' <a href="#$node_id">#</a>' } else { '' }
|
hash_link := if !head { ' <a href="#$node_id">#</a>' } else { '' }
|
||||||
dnw.writeln('<section id="$node_id" class="doc-node$node_class">')
|
dnw.writeln('${tabs[1]}s<section id="$node_id" class="doc-node$node_class">')
|
||||||
if dd.name.len > 0 {
|
if dd.name.len > 0 {
|
||||||
if dd.kind == .const_group {
|
if dd.kind == .const_group {
|
||||||
dnw.write('<div class="title"><$head_tag>$sym_name$hash_link</$head_tag>')
|
dnw.write('${tabs[2]}<div class="title"><$head_tag>$sym_name$hash_link</$head_tag>')
|
||||||
} else {
|
} else {
|
||||||
dnw.write('<div class="title"><$head_tag>$dd.kind $sym_name$hash_link</$head_tag>')
|
dnw.write('${tabs[2]}<div class="title"><$head_tag>$dd.kind $sym_name$hash_link</$head_tag>')
|
||||||
}
|
}
|
||||||
if link.len != 0 {
|
if link.len != 0 {
|
||||||
dnw.write('<a class="link" rel="noreferrer" target="_blank" href="$link">$link_svg</a>')
|
dnw.write('<a class="link" rel="noreferrer" target="_blank" href="$link">$link_svg</a>')
|
||||||
|
@ -421,7 +420,10 @@ fn doc_node_html(dd doc.DocNode, link string, head bool, tb &table.Table) string
|
||||||
if !head && dd.content.len > 0 {
|
if !head && dd.content.len > 0 {
|
||||||
dnw.writeln('<pre class="signature"><code>$hlighted_code</code></pre>')
|
dnw.writeln('<pre class="signature"><code>$hlighted_code</code></pre>')
|
||||||
}
|
}
|
||||||
dnw.writeln('$md_content\n</section>')
|
for line_content in md_content.split('\n') {
|
||||||
|
dnw.write('\n${tabs[2]}$line_content')
|
||||||
|
}
|
||||||
|
dnw.writeln('\n${tabs[1]}</section>')
|
||||||
dnw_str := dnw.str()
|
dnw_str := dnw.str()
|
||||||
defer {
|
defer {
|
||||||
dnw.free()
|
dnw.free()
|
||||||
|
@ -559,12 +561,11 @@ fn (cfg DocConfig) gen_html(idx int) string {
|
||||||
header_name).replace('{{ version }}', version).replace('{{ light_icon }}', cfg.assets['light_icon']).replace('{{ dark_icon }}',
|
header_name).replace('{{ version }}', version).replace('{{ light_icon }}', cfg.assets['light_icon']).replace('{{ dark_icon }}',
|
||||||
cfg.assets['dark_icon']).replace('{{ menu_icon }}', cfg.assets['menu_icon']).replace('{{ head_assets }}',
|
cfg.assets['dark_icon']).replace('{{ menu_icon }}', cfg.assets['menu_icon']).replace('{{ head_assets }}',
|
||||||
if cfg.inline_assets {
|
if cfg.inline_assets {
|
||||||
'\n <style>' + cfg.assets['doc_css'] + '</style>\n <style>' + cfg.assets['normalize_css'] +
|
'\n${tabs[0]}<style>' + cfg.assets['doc_css'] + '</style>\n${tabs[0]}<style>' + cfg.assets['normalize_css'] +
|
||||||
'</style>\n <script>' + cfg.assets['dark_mode_js'] + '</script>'
|
'</style>\n${tabs[0]}<script>' + cfg.assets['dark_mode_js'] + '</script>'
|
||||||
} else {
|
} else {
|
||||||
'\n <link rel="stylesheet" href="' + cfg.assets['doc_css'] + '" />\n <link rel="stylesheet" href="' +
|
'\n${tabs[0]}<link rel="stylesheet" href="' + cfg.assets['doc_css'] + '" />\n${tabs[0]}<link rel="stylesheet" href="' +
|
||||||
cfg.assets['normalize_css'] + '" />\n</style>\n <script src="' + cfg.assets['dark_mode_js'] +
|
cfg.assets['normalize_css'] + '" />\n${tabs[0]}<script src="' + cfg.assets['dark_mode_js'] + '"></script>'
|
||||||
'"></script>'
|
|
||||||
}).replace('{{ toc_links }}', if cfg.is_multi || cfg.docs.len > 1 {
|
}).replace('{{ toc_links }}', if cfg.is_multi || cfg.docs.len > 1 {
|
||||||
modules_toc_str
|
modules_toc_str
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue