summaryrefslogtreecommitdiff
path: root/doc/manual/shortcuts.py
blob: a18786799de265d66aeda4b604bcc9e7f92546f1 (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
39
40
import sys

shortcuts = []

for filename in sys.argv[1:]:
    with open(filename) as f:
        for line in f:
            line = line.strip();
            if line.startswith('/* [Shortcut] '):
                desc = line[14:-2].strip()
                parts = desc.split(':')
                shortcuts.append(desc.split(':'))

shortcuts.sort(key=lambda x: x[0])

print("""
<table id="keyboard shortcuts">
  <title>Keyboard shortcuts</title>
  <tgroup cols='2' align='left' colsep='1' rowsep='1'>
    <thead>
      <row>
	<entry>Key</entry>
	<entry>Action</entry>
      </row>
    </thead>
    <tbody>
""")

for s in shortcuts:
    print("      <row>")
    print(f"        <entry>{s[0]}</entry>")
    print(f"        <entry>{s[1]}</entry>")
    print("      </row>")

print("""
    </tbody>
  </tgroup>
</table>
""")