當前位置: 首頁>>代碼示例>>Python>>正文


Python nodes.definition_list_item方法代碼示例

本文整理匯總了Python中docutils.nodes.definition_list_item方法的典型用法代碼示例。如果您正苦於以下問題:Python nodes.definition_list_item方法的具體用法?Python nodes.definition_list_item怎麽用?Python nodes.definition_list_item使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在docutils.nodes的用法示例。


在下文中一共展示了nodes.definition_list_item方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _format_subcommands

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import definition_list_item [as 別名]
def _format_subcommands(self, parser_info):
        assert 'children' in parser_info
        items = []
        for subcmd in parser_info['children']:
            subcmd_items = []
            if subcmd['help']:
                subcmd_items.append(nodes.paragraph(text=subcmd['help']))
            else:
                subcmd_items.append(nodes.paragraph(text='Undocumented'))
            items.append(
                nodes.definition_list_item(
                    '',
                    nodes.term('', '', nodes.strong(
                        text=subcmd['bare_usage'])),
                    nodes.definition('', *subcmd_items)))
        return nodes.definition_list('', *items) 
開發者ID:rucio,項目名稱:rucio,代碼行數:18,代碼來源:ext.py

示例2: indent

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import definition_list_item [as 別名]
def indent(self, match, context, next_state):
        """Definition list item."""
        definitionlist = nodes.definition_list()
        definitionlistitem, blank_finish = self.definition_list_item(context)
        definitionlist += definitionlistitem
        self.parent += definitionlist
        offset = self.state_machine.line_offset + 1   # next line
        newline_offset, blank_finish = self.nested_list_parse(
              self.state_machine.input_lines[offset:],
              input_offset=self.state_machine.abs_line_offset() + 1,
              node=definitionlist, initial_state='DefinitionList',
              blank_finish=blank_finish, blank_finish_state='Definition')
        self.goto_line(newline_offset)
        if not blank_finish:
            self.parent += self.unindent_warning('Definition list')
        return [], 'Body', [] 
開發者ID:skarlekar,項目名稱:faces,代碼行數:18,代碼來源:states.py

示例3: definition_list_item

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import definition_list_item [as 別名]
def definition_list_item(self, termline):
        indented, indent, line_offset, blank_finish = \
              self.state_machine.get_indented()
        itemnode = nodes.definition_list_item(
            '\n'.join(termline + list(indented)))
        lineno = self.state_machine.abs_line_number() - 1
        (itemnode.source,
         itemnode.line) = self.state_machine.get_source_and_line(lineno)
        termlist, messages = self.term(termline, lineno)
        itemnode += termlist
        definition = nodes.definition('', *messages)
        itemnode += definition
        if termline[0][-2:] == '::':
            definition += self.reporter.info(
                  'Blank line missing before literal block (after the "::")? '
                  'Interpreted as a definition list item.',
                  line=lineno+1)
        self.nested_parse(indented, input_offset=line_offset, node=definition)
        return itemnode, blank_finish 
開發者ID:skarlekar,項目名稱:faces,代碼行數:21,代碼來源:states.py

示例4: run

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import definition_list_item [as 別名]
def run(self):
        # XXX: do this once only
        fd = pkg_resources.resource_stream ('crocoite', 'data/click.yaml')
        config = list (yaml.safe_load_all (fd))

        l = nodes.definition_list ()
        for site in config:
            urls = set ()
            v = nodes.definition ()
            vl = nodes.bullet_list ()
            v += vl
            for s in site['selector']:
                i = nodes.list_item ()
                i += nodes.paragraph (text=s['description'])
                vl += i
                urls.update (map (lambda x: URL(x).with_path ('/'), s.get ('urls', [])))

            item = nodes.definition_list_item ()
            term = ', '.join (map (lambda x: x.host, urls)) if urls else site['match']
            k = nodes.term (text=term)
            item += k

            item += v
            l += item
        return [l] 
開發者ID:PromyLOPh,項目名稱:crocoite,代碼行數:27,代碼來源:clicklist.py

示例5: map_nested_definitions

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import definition_list_item [as 別名]
def map_nested_definitions(nested_content):
    if nested_content is None:
        raise Exception('Nested content should be iterable, not null')
    # build definition dictionary
    definitions = {}
    for item in nested_content:
        if not isinstance(item, nodes.definition_list):
            continue
        for subitem in item:
            if not isinstance(subitem, nodes.definition_list_item):
                continue
            if not len(subitem.children) > 0:
                continue
            classifier = '@after'
            idx = subitem.first_child_matching_class(nodes.classifier)
            if idx is not None:
                ci = subitem[idx]
                if len(ci.children) > 0:
                    classifier = ci.children[0].astext()
            if classifier is not None and classifier not in (
                    '@replace', '@before', '@after'):
                raise Exception('Unknown classifier: %s' % classifier)
            idx = subitem.first_child_matching_class(nodes.term)
            if idx is not None:
                term = subitem[idx]
                if len(term.children) > 0:
                    term = term.children[0].astext()
                    idx = subitem.first_child_matching_class(nodes.definition)
                    if idx is not None:
                        subContent = []
                        for _ in subitem[idx]:
                            if isinstance(_, nodes.definition_list):
                                subContent.append(_)
                        definitions[term] = (classifier, subitem[idx].astext(), subContent)

    return definitions 
開發者ID:rucio,項目名稱:rucio,代碼行數:38,代碼來源:ext.py

示例6: map_nested_definitions

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import definition_list_item [as 別名]
def map_nested_definitions(nested_content):
    if nested_content is None:
        raise Exception('Nested content should be iterable, not null')
    # build definition dictionary
    definitions = {}
    for item in nested_content:
        if not isinstance(item, nodes.definition_list):
            continue
        for subitem in item:
            if not isinstance(subitem, nodes.definition_list_item):
                continue
            if not len(subitem.children) > 0:
                continue
            classifier = '@after'
            idx = subitem.first_child_matching_class(nodes.classifier)
            if idx is not None:
                ci = subitem[idx]
                if len(ci.children) > 0:
                    classifier = ci.children[0].astext()
            if classifier is not None and classifier not in (
                    '@replace', '@before', '@after'):
                raise Exception('Unknown classifier: %s' % classifier)
            idx = subitem.first_child_matching_class(nodes.term)
            if idx is not None:
                ch = subitem[idx]
                if len(ch.children) > 0:
                    term = ch.children[0].astext()
                    idx = subitem.first_child_matching_class(nodes.definition)
                    if idx is not None:
                        def_node = subitem[idx]
                        def_node.attributes['classifier'] = classifier
                        definitions[term] = def_node
    return definitions 
開發者ID:pnnl,項目名稱:safekit,代碼行數:35,代碼來源:ext.py

示例7: print_command_args_and_opts

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import definition_list_item [as 別名]
def print_command_args_and_opts(arg_list, opt_list, sub_list=None):
    items = []
    if arg_list:
        items.append(nodes.definition_list_item(
            '', nodes.term(text='Positional arguments:'),
            nodes.definition('', arg_list)))
    if opt_list:
        items.append(nodes.definition_list_item(
            '', nodes.term(text='Options:'),
            nodes.definition('', opt_list)))
    if sub_list and len(sub_list):
        items.append(nodes.definition_list_item(
            '', nodes.term(text='Sub-commands:'),
            nodes.definition('', sub_list)))
    return nodes.definition_list('', *items) 
開發者ID:pnnl,項目名稱:safekit,代碼行數:17,代碼來源:ext.py

示例8: print_subcommand_list

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import definition_list_item [as 別名]
def print_subcommand_list(data, nested_content):
    definitions = map_nested_definitions(nested_content)
    items = []
    if 'children' in data:
        for child in data['children']:
            my_def = [nodes.paragraph(
                text=child['help'])] if child['help'] else []
            name = child['name']
            my_def = apply_definition(definitions, my_def, name)
            if len(my_def) == 0:
                my_def.append(nodes.paragraph(text='Undocumented'))
            if 'description' in child:
                my_def.append(nodes.paragraph(text=child['description']))
            my_def.append(nodes.literal_block(text=child['usage']))
            my_def.append(print_command_args_and_opts(
                print_arg_list(child, nested_content),
                print_opt_list(child, nested_content),
                print_subcommand_list(child, nested_content)
            ))
            items.append(
                nodes.definition_list_item(
                    '',
                    nodes.term('', '', nodes.strong(text=name)),
                    nodes.definition('', *my_def)
                )
            )
    return nodes.definition_list('', *items) 
開發者ID:pnnl,項目名稱:safekit,代碼行數:29,代碼來源:ext.py


注:本文中的docutils.nodes.definition_list_item方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。