Output all option variant names in manual

This commit is contained in:
Kovid Goyal 2017-05-04 17:03:31 +05:30
parent 215a446575
commit e6eff0f6cf
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -195,15 +195,14 @@ def render_options(cmd, groups, options_header=True, add_program=True, header_le
lines.append('')
if desc:
lines.extend([desc, ''])
for opt in sorted(options, cmp=lambda x, y:cmp(x.get_opt_string(),
y.get_opt_string())):
for opt in sorted(options, key=lambda x: x.get_opt_string()):
help = opt.help if opt.help else ''
help = help.replace('\n', ' ').replace('*', '\\*').replace('%default', str(opt.default))
help = help.replace('"', r'\ ``"``\ ')
help = help.replace("'", r"\ ``'``\ ")
help = mark_options(help)
opt = opt.get_opt_string() + ((', '+', '.join(opt._short_opts)) if opt._short_opts else '')
opt = '.. option:: '+opt
opt_strings = (x.strip() for x in tuple(opt._long_opts or ()) + tuple(opt._short_opts or ()))
opt = '.. option:: ' + ', '.join(opt_strings)
lines.extend([opt, '', ' '+help, ''])
return lines