-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-man-index
More file actions
executable file
·126 lines (114 loc) · 4.4 KB
/
create-man-index
File metadata and controls
executable file
·126 lines (114 loc) · 4.4 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python3
from os.path import basename
import re, sys
def render_cmd(subcmd, page_dir, indent):
if subcmd:
# split handles "bup on [HOST index]", etc.
subcmd_and_sec = subcmd.split()[0]
cmd_name = 'bup ' + re.sub(r'^([^.]+)\.[0-9]+', r'\1', subcmd)
page_name = f'bup-{subcmd_and_sec}'
else:
cmd_name = 'bup'
page_name = 'bup.1'
print('%s<li><a href="%s/%s.html">%s</a></li>'
% ((' ' * indent), page_dir, page_name, cmd_name))
def render_sections(sections, other, requested_cmds, page_dir, indent=0):
rendered = set()
for section in sections:
sec_name, cmds = section
print('%s<h3>%s</h3>' % ((' ' * indent), sec_name))
print('%s<ul>' % (' ' * indent))
for cmd in cmds:
cmd_name = cmd and cmd.split()[0] or None
if cmd_name not in requested_cmds:
continue
render_cmd(cmd, page_dir, indent + 2)
rendered.add(cmd_name)
print('%s</ul>' % (' ' * indent))
remaining_cmds = requested_cmds - rendered
if remaining_cmds:
print('%s<h3>%s</h3>' % ((' ' * indent), other))
print('%s<ul>' % (' ' * indent))
for cmd in sorted(remaining_cmds):
render_cmd(cmd, page_dir, indent + 2)
print('%s</ul>' % (' ' * indent))
def cmd_from_html_path(x):
assert(x.endswith('.html'))
base = basename(x)
if base == 'bup.1.html':
return None
assert(base.startswith('bup-'))
return base[4:-5] or None
# Usage: create-man-index DIR_CONTAINING_HTML_PAGES HTML_PAGES_TO_INCLUDE...
# e.g. create-man-index man $(git ls-files 'man/*.html')
version = sys.argv[1]
page_dir = sys.argv[2]
pages = sys.argv[3:]
print("""<!doctype html>'
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>bup man pages</title>
<link rel="stylesheet" href="stylesheets/styles.css">
<link rel="stylesheet" href="stylesheets/pygment_trac.css">
<!--[if lt IE 8]>
<link rel="stylesheet" href="stylesheets/ie.css">
<![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
</head>
<body>
<div id="header">
<nav>
<li class="fork"><a href="https://github.com/bup/bup">SOURCE</a></li>
<li class="downloads"><a href="https://github.com/bup/bup/zipball/%(version)s">ZIP</a></li>
<li class="downloads"><a href="https://github.com/bup/bup/tarball/%(version)s">TAR</a></li>
<li class="title">RELEASE (%(version)s)</li>
</nav>
</div><!-- end header -->
<div class="wrapper">
<section>
<div id="title">
<h1>bup</h1>
<p>Very efficient backup system based on the git packfile format, providing fast incremental saves and global deduplication (among and within files, including virtual machine images).</p>
<hr>
<span class="credits left">Contact us on the <a href="https://groups.google.com/forum/#!forum/bup-list">mailing list</a></span>
<span class="credits right">Theme by <a href="https://twitter.com/michigangraham">mattgraham</a></span>
</div>""" % {'version' : version})
known_sections = [['Common operations',
[None, # bup(1) -- (no subcommand)
'help.1',
'init.1',
'fsck.1',
'tag.1',
'version.1']],
['Inspection',
['ls.1',
'fuse.1',
'web.1',
'ftp.1']],
['Save and restore',
['index.1',
'on.1 [HOST index]',
'save.1',
'on.1 [HOST save]',
'restore.1']],
['Split and join',
['split.1',
'join.1']],
['Importing data',
['import-duplicity.1',
'import-rdiff-backup.1',
'import-rsnapshot.1']],
['Pruning old data (destructive)',
['rm.1',
'gc.1',
'prune-older.1']]]
requested_cmds = frozenset((cmd_from_html_path(x) for x in pages))
render_sections(known_sections, 'Others', requested_cmds, page_dir, 8)
print("""
</section>
</div>
</body>
</html>
""")