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


Python nodes.definition方法代碼示例

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


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

示例1: _format_subcommands

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

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import definition [as 別名]
def build_regexp(definition, compile=True):
    """
    Build, compile and return a regular expression based on `definition`.

    :Parameter: `definition`: a 4-tuple (group name, prefix, suffix, parts),
        where "parts" is a list of regular expressions and/or regular
        expression definitions to be joined into an or-group.
    """
    name, prefix, suffix, parts = definition
    part_strings = []
    for part in parts:
        if type(part) is tuple:
            part_strings.append(build_regexp(part, None))
        else:
            part_strings.append(part)
    or_group = '|'.join(part_strings)
    regexp = '%(prefix)s(?P<%(name)s>%(or_group)s)%(suffix)s' % locals()
    if compile:
        return re.compile(regexp, re.UNICODE)
    else:
        return regexp 
開發者ID:skarlekar,項目名稱:faces,代碼行數:23,代碼來源:states.py

示例3: definition_list_item

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

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import definition [as 別名]
def _create_section(self, parent, sectionid, title=None, term=None):
        """Create a new section

        :returns: If term is specified, returns a definition node contained
        within the newly created section.  Otherwise return the newly created
        section node.
        """

        idb = nodes.make_id(sectionid)
        section = nodes.section(ids=[idb])
        parent.append(section)

        if term:
            if term != '**':
                section.append(nodes.term('', term))

            definition = nodes.definition()
            section.append(definition)

            return definition

        if title:
            section.append(nodes.title('', title))

        return section 
開發者ID:openstack,項目名稱:senlin,代碼行數:27,代碼來源:resources.py

示例6: map_nested_definitions

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

示例7: text

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import definition [as 別名]
def text(self, match, context, next_state):
        """Titles, definition lists, paragraphs."""
        return [match.string], 'Text', [] 
開發者ID:skarlekar,項目名稱:faces,代碼行數:5,代碼來源:states.py

示例8: eof

# 需要導入模塊: from docutils import nodes [as 別名]
# 或者: from docutils.nodes import definition [as 別名]
def eof(self, context):
        """Not a definition."""
        self.state_machine.previous_line(2) # so parent SM can reassess
        return [] 
開發者ID:skarlekar,項目名稱:faces,代碼行數:6,代碼來源:states.py


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