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


Python nodes.classifier方法代碼示例

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


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

示例1: term

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import classifier [as 別名]
def term(self, lines, lineno):
        """Return a definition_list's term and optional classifiers."""
        assert len(lines) == 1
        text_nodes, messages = self.inline_text(lines[0], lineno)
        term_node = nodes.term()
        (term_node.source,
         term_node.line) = self.state_machine.get_source_and_line(lineno)
        term_node.rawsource = unescape(lines[0])
        node_list = [term_node]
        for i in range(len(text_nodes)):
            node = text_nodes[i]
            if isinstance(node, nodes.Text):
                parts = self.classifier_delimiter.split(node.rawsource)
                if len(parts) == 1:
                    node_list[-1] += node
                else:

                    node_list[-1] += nodes.Text(parts[0].rstrip())
                    for part in parts[1:]:
                        classifier_node = nodes.classifier('', part)
                        node_list.append(classifier_node)
            else:
                node_list[-1] += node
        return node_list, messages 
開發者ID:skarlekar,項目名稱:faces,代碼行數:26,代碼來源:states.py

示例2: term

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import classifier [as 別名]
def term(self, lines, lineno):
        """Return a definition_list's term and optional classifiers."""
        assert len(lines) == 1
        text_nodes, messages = self.inline_text(lines[0], lineno)
        term_node = nodes.term(lines[0])
        (term_node.source,
         term_node.line) = self.state_machine.get_source_and_line(lineno)
        node_list = [term_node]
        for i in range(len(text_nodes)):
            node = text_nodes[i]
            if isinstance(node, nodes.Text):
                parts = self.classifier_delimiter.split(node)
                if len(parts) == 1:
                    node_list[-1] += node
                else:
                    text = parts[0].rstrip()
                    textnode = nodes.Text(utils.unescape(text, True))
                    node_list[-1] += textnode
                    for part in parts[1:]:
                        node_list.append(
                            nodes.classifier(unescape(part, True), part))
            else:
                node_list[-1] += node
        return node_list, messages 
開發者ID:aws-samples,項目名稱:aws-builders-fair-projects,代碼行數:26,代碼來源:states.py

示例3: map_nested_definitions

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import classifier [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

示例4: visit_definition_list_item

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import classifier [as 別名]
def visit_definition_list_item(self, node):
        self._li_has_classifier = len(node) >= 2 and \
                                  isinstance(node[1], nodes.classifier) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:5,代碼來源:textwriter.py

示例5: map_nested_definitions

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import classifier [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

示例6: apply_definition

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import classifier [as 別名]
def apply_definition(definitions, my_def, name):
    if name in definitions:
        definition = definitions[name]
        classifier = definition['classifier']
        if classifier == '@replace':
            return definition.children
        if classifier == '@after':
            return my_def + definition.children
        if classifier == '@before':
            return definition.children + my_def
        raise Exception('Unknown classifier: %s' % classifier)
    return my_def 
開發者ID:pnnl,項目名稱:safekit,代碼行數:14,代碼來源:ext.py

示例7: visit_definition_list_item

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import classifier [as 別名]
def visit_definition_list_item(self, node):
        self._li_has_classifier = len(node) >= 2 and \
            isinstance(node[1], nodes.classifier) 
開發者ID:openstack,項目名稱:releases,代碼行數:5,代碼來源:rst2txt.py

示例8: visit_definition_list_item

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import classifier [as 別名]
def visit_definition_list_item(self, node):
    self._li_has_classifier = len(node) >= 2 and \
                              isinstance(node[1], nodes.classifier) 
開發者ID:intelligent-agent,項目名稱:redeem,代碼行數:5,代碼來源:TextWriter.py

示例9: print_subcommands

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import classifier [as 別名]
def print_subcommands(data, nested_content, markDownHelp=False):
    """
    Each subcommand is a dictionary with the following keys:

    ['usage', 'action_groups', 'bare_usage', 'name', 'help', 'epilog']

    In essence, this is all tossed in a new section with the title 'name'.
    Apparently there can also be a 'description' entry.
    """

    definitions = map_nested_definitions(nested_content)
    items = []
    if 'children' in data:
        subCommands = nodes.section(ids=["Sub-commands:"])
        subCommands += nodes.title('Sub-commands:', 'Sub-commands:')

        for child in data['children']:
            sec = nodes.section(ids=[child['name']])
            sec += nodes.title(child['name'], child['name'])

            if 'description' in child and child['description']:
                desc = [child['description']]
            elif child['help']:
                desc = [child['help']]
            else:
                desc = ['Undocumented']

            # Handle nested content
            subContent = []
            if child['name'] in definitions:
                classifier, s, subContent = definitions[child['name']]
                if classifier == '@replace':
                    desc = [s]
                elif classifier == '@after':
                    desc.append(s)
                elif classifier == '@before':
                    desc.insert(0, s)

            for element in renderList(desc, markDownHelp):
                sec += element
            sec += nodes.literal_block(text=child['bare_usage'])
            for x in print_action_groups(child, nested_content + subContent, markDownHelp):
                sec += x

            for x in print_subcommands(child, nested_content + subContent, markDownHelp):
                sec += x

            if 'epilog' in child and child['epilog']:
                for element in renderList([child['epilog']], markDownHelp):
                    sec += element

            subCommands += sec

        items.append(subCommands)

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


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