summaryrefslogtreecommitdiff
path: root/man/lib/mksectionindex.py
blob: e1a849261afe5e62781a431734bf0c6e102c8c0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import sys

if __name__ == "__main__":
    prefix = sys.argv[1]
    section = sys.argv[2]
    index_file = """<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<style>
    table.head, table.foot { width: 100%; }
    td.head-rtitle, td.foot-os { text-align: right; }
    td.head-vol { text-align: center; }
    .Nd, .Bf, .Op { display: inline; }
    .Pa, .Ad { font-style: italic; }
    .Ms { font-weight: bold; }
    .Bl-diag > dt { font-weight: bold; }
    code.Nm, .Fl, .Cm, .Ic, code.In, .Fd, .Fn, .Cd { font-weight: bold;
    font-family: inherit; }
</style>"""

    index_file += f"<title>Section {section} index</title>"
    index_file += f"""
</head>
<body>
    <h1>Section {section} index</h1>
<pre>
"""

    for f in os.listdir():
        if f == 'INDEX':
            continue
        index_file += f"<a href=\"{prefix}{section}/{f}.html\">{f}</a>\n"

    index_file += "</pre></body></html>"
    print(index_file)