Add comments for shortcuts and extract them for the manual (#2073).
[dcpomatic.git] / doc / manual / shortcuts.py
1 import sys
2
3 shortcuts = []
4
5 for filename in sys.argv[1:]:
6     with open(filename) as f:
7         for line in f:
8             line = line.strip();
9             if line.startswith('/* [Shortcut] '):
10                 desc = line[14:-2].strip()
11                 parts = desc.split(':')
12                 shortcuts.append(desc.split(':'))
13
14 shortcuts.sort(key=lambda x: x[0])
15
16 print("""
17 <table id="keyboard shortcuts">
18   <title>Keyboard shortcuts</title>
19   <tgroup cols='2' align='left' colsep='1' rowsep='1'>
20     <thead>
21       <row>
22         <entry>Key</entry>
23         <entry>Action</entry>
24       </row>
25     </thead>
26     <tbody>
27 """)
28
29 for s in shortcuts:
30     print("      <row>")
31     print(f"        <entry>{s[0]}</entry>")
32     print(f"        <entry>{s[1]}</entry>")
33     print("      </row>")
34
35 print("""
36     </tbody>
37   </tgroup>
38 </table>
39 """)
40