コード例 #1
0
ファイル: ext.py プロジェクト: Eibriel/blender-asset-manager
 def _format_optional_arguments(self, parser_info):
     assert 'options' in parser_info
     items = []
     for opt in parser_info['options']:
         names = []
         opt_items = []
         for name in opt['name']:
             option_declaration = [nodes.option_string(text=name)]
             if opt['default'] is not None \
                     and opt['default'] != '==SUPPRESS==':
                 option_declaration += nodes.option_argument(
                     '', text='=' + str(opt['default']))
             names.append(nodes.option('', *option_declaration))
         if opt['help']:
             opt_items.append(nodes.paragraph(text=opt['help']))
         else:
             opt_items.append(nodes.paragraph(text='Undocumented'))
         if 'choices' in opt:
             opt_items.append(
                 nodes.paragraph(
                     text='Possible choices: ' + ', '.join(opt['choices'])))
         items.append(
             nodes.option_list_item(
                 '', nodes.option_group('', *names),
                 nodes.description('', *opt_items)))
     return nodes.option_list('', *items)
コード例 #2
0
ファイル: ext.py プロジェクト: Eibriel/blender-asset-manager
def print_opt_list(data, nested_content):
    definitions = map_nested_definitions(nested_content)
    items = []
    if 'options' in data:
        for opt in data['options']:
            names = []
            my_def = [nodes.paragraph(text=opt['help'])] if opt['help'] else []
            for name in opt['name']:
                option_declaration = [nodes.option_string(text=name)]
                if opt['default'] is not None \
                        and opt['default'] != '==SUPPRESS==':
                    option_declaration += nodes.option_argument(
                        '', text='=' + str(opt['default']))
                names.append(nodes.option('', *option_declaration))
                my_def = apply_definition(definitions, my_def, name)
            if len(my_def) == 0:
                my_def.append(nodes.paragraph(text='Undocumented'))
            if 'choices' in opt:
                my_def.append(nodes.paragraph(
                    text=('Possible choices: %s' % ', '.join([str(c) for c in opt['choices']]))))
            items.append(
                nodes.option_list_item(
                    '', nodes.option_group('', *names),
                    nodes.description('', *my_def)))
    return nodes.option_list('', *items) if items else None
コード例 #3
0
def print_opt_list(data, nested_content):
    definitions = map_nested_definitions(nested_content)
    items = []
    nodes_list = []  # dictionary to hold the group options, the group title is used as the key
    if 'action_groups' in data:
        for action_group in data['action_groups']:
            if 'options' in action_group:
                for opt in action_group['options']:
                    names = []
                    my_def = [nodes.paragraph(text=opt['help'])] if opt['help'] else []
                    for name in opt['name']:
                        option_declaration = [nodes.option_string(text=name)]
                        if opt['default'] is not None \
                                and opt['default'] != '==SUPPRESS==':
                            option_declaration += nodes.option_argument(
                                '', text='=' + str(opt['default']))
                        names.append(nodes.option('', *option_declaration))
                        my_def = apply_definition(definitions, my_def, name)
                    if len(my_def) == 0 and 'choices' not in opt:
                        my_def.append(nodes.paragraph(text='Undocumented'))
                    if 'choices' in opt:
                        my_def.append(nodes.paragraph(
                            text=('Possible choices: %s' % ', '.join([str(c) for c in opt['choices']]))))
                    items.append(
                        nodes.option_list_item(
                            '', nodes.option_group('', *names),
                            nodes.description('', *my_def)))
            opts = nodes.option_list('', *items) if items else None
            nodes_list.append({'options': opts,
                               'title': action_group['title'],
                               'description': action_group['description']})
    return nodes_list
コード例 #4
0
 def _format_optional_arguments(self, parser_info):
     assert 'options' in parser_info
     items = []
     for opt in parser_info['options']:
         names = []
         opt_items = []
         for name in opt['name']:
             option_declaration = [nodes.option_string(text=name)]
             if opt['default'] is not None \
                     and opt['default'] != '==SUPPRESS==':
                 option_declaration += nodes.option_argument(
                     '', text='=' + str(opt['default']))
             names.append(nodes.option('', *option_declaration))
         if opt['help']:
             opt_items.append(nodes.paragraph(text=opt['help']))
         else:
             opt_items.append(nodes.paragraph(text='Undocumented'))
         if 'choices' in opt:
             opt_items.append(
                 nodes.paragraph(
                     text='Possible choices: ' + ', '.join(opt['choices'])))
         items.append(
             nodes.option_list_item(
                 '', nodes.option_group('', *names),
                 nodes.description('', *opt_items)))
     return nodes.option_list('', *items)
コード例 #5
0
ファイル: ext.py プロジェクト: kartikeyap/package-manager
def print_opt_list(data, nested_content):
    definitions = map_nested_definitions(nested_content)
    items = []
    if 'options' in data:
        for opt in data['options']:
            names = []
            my_def = [nodes.paragraph(text=opt['help'])] if opt['help'] else []
            for name in opt['name']:
                option_declaration = [nodes.option_string(text=name)]
                if opt['default'] is not None \
                        and opt['default'] != '==SUPPRESS==':
                    option_declaration += nodes.option_argument(
                        '', text='=' + str(opt['default']))
                names.append(nodes.option('', *option_declaration))
                my_def = apply_definition(definitions, my_def, name)
            if len(my_def) == 0:
                my_def.append(nodes.paragraph(text='Undocumented'))
            if 'choices' in opt:
                my_def.append(
                    nodes.paragraph(
                        text=('Possible choices: %s' %
                              ', '.join([str(c) for c in opt['choices']]))))
            items.append(
                nodes.option_list_item('', nodes.option_group('', *names),
                                       nodes.description('', *my_def)))
    return nodes.option_list('', *items) if items else None
コード例 #6
0
ファイル: debug.py プロジェクト: dotmpe/docutils-ext
    def __add_option(self, option):
        if option.action not in ('callback','store_const','store_true',
                'store_false','count','version','help'):
            optnodes = [ nodes.option('', nodes.option_string('',o),
                nodes.option_argument('', option.metavar or 'ARG'))
                for o in option._short_opts + option._long_opts ]
        else:                
            optnodes = [ nodes.option('', nodes.option_string('',o),)
                for o in option._short_opts + option._long_opts ]

        help =  u''                
        if option.help != optparse.SUPPRESS_HELP:
            if option.default != optparse.NO_DEFAULT:
                help = option.help.replace('%default', str(option.default))
            else:                
                help = option.help
        item = nodes.option_list_item('',
                nodes.option_group('', *optnodes))
        if help:
            item += nodes.description('',nodes.paragraph('',help))
        return item
コード例 #7
0
def print_opt_list(data, nested_content):
    definitions = map_nested_definitions(nested_content)
    nodes_list = [
    ]  # dictionary to hold the group options, the group title is used as the key
    if 'action_groups' in data:
        for action_group in data['action_groups']:
            items = []
            if 'options' in action_group:
                for opt in action_group['options']:
                    names = []
                    my_def = [nodes.paragraph(
                        text=opt['help'])] if opt['help'] else []
                    for name in opt['name']:
                        option_declaration = [nodes.option_string(text=name)]
                        if opt['default'] is not None \
                                and opt['default'] != '==SUPPRESS==':
                            option_declaration += nodes.option_argument(
                                '', text='=' + str(opt['default']))
                        names.append(nodes.option('', *option_declaration))
                        my_def = apply_definition(definitions, my_def, name)
                    if len(my_def) == 0 and 'choices' not in opt:
                        my_def.append(nodes.paragraph(text='Undocumented'))
                    if 'choices' in opt:
                        my_def.append(
                            nodes.paragraph(text=(
                                'Possible choices: %s' %
                                ', '.join([str(c) for c in opt['choices']]))))
                    items.append(
                        nodes.option_list_item('',
                                               nodes.option_group('', *names),
                                               nodes.description('', *my_def)))
            opts = nodes.option_list('', *items) if items else None
            nodes_list.append({
                'options': opts,
                'title': action_group['title'],
                'description': action_group['description']
            })
    return nodes_list