From 96053ff3e5edb1c29ad2d2142365cac39827ab4c Mon Sep 17 00:00:00 2001 From: boyska Date: Wed, 16 Dec 2015 15:22:30 +0100 Subject: [PATCH] option list much improved --- doc/source/clickdoc.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/doc/source/clickdoc.py b/doc/source/clickdoc.py index 9d3a18c..146e000 100644 --- a/doc/source/clickdoc.py +++ b/doc/source/clickdoc.py @@ -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): @@ -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):