List kitten names in the kitten default shortcuts list

This commit is contained in:
pagedown 2021-12-10 14:33:29 +08:00
parent 49d284cd16
commit 59957a913a
No known key found for this signature in database
GPG Key ID: E921CF18AC8FF6EB

View File

@ -84,6 +84,10 @@ def as_rst() -> str:
def key(x: ActionGroup) -> str: def key(x: ActionGroup) -> str:
return group_title(x).lower() return group_title(x).lower()
def kitten_link(text: str) -> str:
x = text.split()
return f':doc:`kittens/{x[2]}`'.replace('_', '-') if len(x) > 2 else ''
for group in sorted(allg, key=key): for group in sorted(allg, key=key):
title = group_title(group) title = group_title(group)
a('') a('')
@ -107,6 +111,12 @@ def as_rst() -> str:
if action.name in maps: if action.name in maps:
a('') a('')
a('Default shortcuts using this action:') a('Default shortcuts using this action:')
scs = {f':sc:`kitty.{m.name}`' for m in maps[action.name]} if action.name == 'kitten':
a(', '.join(sorted(scs))) scs = {(kitten_link(m.parseable_text), m.short_text, f':sc:`kitty.{m.name}`') for m in maps[action.name]}
for s in sorted(scs):
a('')
a(f'- {s[0]} - {s[2]} {s[1]}')
else:
scs = {f':sc:`kitty.{m.name}`' for m in maps[action.name]}
a(', '.join(sorted(scs)))
return '\n'.join(lines) return '\n'.join(lines)