summaryrefslogtreecommitdiff
path: root/doc/manual/shortcuts.py
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-08-17 22:49:10 +0200
committerCarl Hetherington <cth@carlh.net>2021-08-17 22:49:10 +0200
commit3f047eef5b84c4212da865b5cdadb70076f07805 (patch)
tree30731e46b7e57416f22d6aece914c413ae826943 /doc/manual/shortcuts.py
parent924f4edb20d14bc697956254951fb87513cf2e19 (diff)
Add comments for shortcuts and extract them for the manual (#2073).
Diffstat (limited to 'doc/manual/shortcuts.py')
-rw-r--r--doc/manual/shortcuts.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/doc/manual/shortcuts.py b/doc/manual/shortcuts.py
new file mode 100644
index 000000000..a18786799
--- /dev/null
+++ b/doc/manual/shortcuts.py
@@ -0,0 +1,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>
+""")
+