Skip to content

Commit

Permalink
option list much improved
Browse files Browse the repository at this point in the history
  • Loading branch information
boyska committed Dec 16, 2015
1 parent 9b6c17f commit 96053ff
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions doc/source/clickdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ def get_command(obj_path):


def format_param(param):
text = "%s %s\n %s\n\n" % (
', '.join(param.opts),
param.metavar or '',
param.help
)
return nodes.paragraph(text, text)
group = nodes.option_group()
for opt in param.opts:
option = nodes.option()
option += nodes.option_string(opt, opt)
option += nodes.option_argument(param.metavar or '', param.metavar or '', delimiter="=")
group += option
item = nodes.option_list_item()
item += group
description = nodes.description()
description += nodes.paragraph(param.help, param.help)
item += description
return item


class UsageDirective(SingleArgDirective):
Expand All @@ -42,10 +48,10 @@ class OptionsDirective(SingleArgDirective):
def run(self):
command = get_command(self.get_arg())

options = [nodes.paragraph('foobar[%s]' % self.get_arg())]
options = nodes.option_list()
for param in command.params:
options.append(format_param(param))
return options
options += format_param(param)
return [options]


class OptionDirective(Directive):
Expand Down

0 comments on commit 96053ff

Please sign in to comment.