当前位置: 首页>>代码示例>>Python>>正文


Python docutils.nodes方法代码示例

本文整理汇总了Python中docutils.nodes方法的典型用法代码示例。如果您正苦于以下问题:Python docutils.nodes方法的具体用法?Python docutils.nodes怎么用?Python docutils.nodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在docutils的用法示例。


在下文中一共展示了docutils.nodes方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle_non_section_nodes

# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import nodes [as 别名]
def handle_non_section_nodes(section_node, non_section_child_nodes, doc_name,
                             data):
    """
    All the nodes that are not section nodes are parsed here.
    """
    non_code_nodes = filter(
        lambda x: type(x) not in [docutils.nodes.literal_block],
        non_section_child_nodes
    )
    code_nodes = filter(lambda x: type(x) in [docutils.nodes.literal_block],
                        non_section_child_nodes)
    code = '\n'.join(map(lambda x: x.astext(), code_nodes))
    text = '\n'.join(map(lambda x: x.astext(), non_code_nodes))

    data[section_node.get('ids')[0]] = {
        "code": code,
        "text": (text + '\n' + doc_name[:-4] + '.html#' +
                 section_node.get('ids')[0]),
        "file": doc_name
    } 
开发者ID:coala,项目名称:corobo,代码行数:22,代码来源:extraction.py

示例2: visit_section

# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import nodes [as 别名]
def visit_section(self, node):
        """ Checks if the visited sub-command section nodes exists and it
            options are in sync.

            Uses :py:class:`OptionsCheckVisitor` for checking
            sub-commands options
        """
        # pylint: disable=no-self-use
        title = str(node[0][0])
        if title.upper() == SUBCOMMANDS_TITLE:
            return

        sub_cmd = self.command + ' ' + title

        try:
            args = self.sub_commands[title]
            options_visitor = OptionsCheckVisitor(sub_cmd, args, self.document)
            node.walkabout(options_visitor)
            options_visitor.check_undocumented_arguments(
                {'--help', '--quiet', '--verbose', '-h', '-q', '-v'})
            del self.sub_commands[title]
        except KeyError:
            raise sphinx.errors.SphinxError(
                'No such sub-command {!r}'.format(sub_cmd)) 
开发者ID:QubesOS,项目名称:qubes-core-admin-client,代码行数:26,代码来源:dochelpers.py

示例3: gather_elements

# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import nodes [as 别名]
def gather_elements(self, client, node, style):
        if isinstance(node.parent, docutils.nodes.sidebar):
            elements = [
                Paragraph(client.gen_pdftext(node), client.styles['sidebar-subtitle'])
            ]
        elif isinstance(node.parent, docutils.nodes.document):
            # elements = [Paragraph(client.gen_pdftext(node),
            # client.styles['subtitle'])]
            # The visible output is now done by the cover template
            elements = []
            # FIXME: looks like subtitles don't have a rawsource like
            # titles do.
            # That means that literals and italics etc in subtitles won't
            # work.
            client.doc_subtitle = getattr(node, 'rawtext', node.astext()).strip()
        else:
            elements = node.elements  # FIXME Can we get here???
        return elements 
开发者ID:rst2pdf,项目名称:rst2pdf,代码行数:20,代码来源:genelements.py

示例4: validate_strip_class

# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import nodes [as 别名]
def validate_strip_class(setting, value, option_parser,
                         config_parser=None, config_section=None):
    # value is a comma separated string list:
    value = validate_comma_separated_list(setting, value, option_parser,
                                          config_parser, config_section)
    # validate list elements:
    for cls in value:
        normalized = docutils.nodes.make_id(cls)
        if cls != normalized:
            raise ValueError('invalid class value %r (perhaps %r?)'
                             % (cls, normalized))
    return value 
开发者ID:skarlekar,项目名称:faces,代码行数:14,代码来源:frontend.py

示例5: validate_strip_class

# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import nodes [as 别名]
def validate_strip_class(setting, value, option_parser,
                         config_parser=None, config_section=None):
    # value is a comma separated string list:
    value = validate_comma_separated_list(setting, value, option_parser,
                                          config_parser, config_section)
    # validate list elements:
    for cls in value:
        normalized = docutils.nodes.make_id(cls)
        if cls != normalized:
            raise ValueError('Invalid class value %r (perhaps %r?)'
                             % (cls, normalized))
    return value 
开发者ID:QData,项目名称:deepWordBug,代码行数:14,代码来源:frontend.py

示例6: ticket

# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import nodes [as 别名]
def ticket(name, rawtext, text, lineno, inliner, options=None, content=None):
    """Link to qubes ticket

    :param str name: The role name used in the document
    :param str rawtext: The entire markup snippet, with role
    :param str text: The text marked with the role
    :param int lineno: The line number where rawtext appears in the input
    :param docutils.parsers.rst.states.Inliner inliner: The inliner instance \
        that called this function
    :param options: Directive options for customisation
    :param content: The directive content for customisation
    """  # pylint: disable=unused-argument

    if options is None:
        options = {}

    ticketno = text.lstrip('#')
    if not ticketno.isdigit():
        msg = inliner.reporter.error(
            'Invalid ticket identificator: {!r}'.format(text), line=lineno)
        prb = inliner.problematic(rawtext, rawtext, msg)
        return [prb], [msg]

    try:
        info = fetch_ticket_info(inliner.document.settings.env.app, ticketno)
    except urllib.error.HTTPError as e:
        msg = inliner.reporter.error(
            'Error while fetching ticket info: {!s}'.format(e), line=lineno)
        prb = inliner.problematic(rawtext, rawtext, msg)
        return [prb], [msg]

    docutils.parsers.rst.roles.set_classes(options)

    node = docutils.nodes.reference(
        rawtext,
        '#{} ({})'.format(info.number, info.summary),
        refuri=info.uri,
        **options)

    return [node], [] 
开发者ID:QubesOS,项目名称:qubes-core-admin,代码行数:42,代码来源:dochelpers.py

示例7: __init__

# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import nodes [as 别名]
def __init__(self, command, args, document):
        assert isinstance(args, set)
        docutils.nodes.SparseNodeVisitor.__init__(self, document)
        self.command = command
        self.args = args 
开发者ID:QubesOS,项目名称:qubes-core-admin,代码行数:7,代码来源:dochelpers.py

示例8: visit_desc

# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import nodes [as 别名]
def visit_desc(self, node):
        """ Skips all but 'option' elements """
        # pylint: disable=no-self-use
        if not node.get('desctype', None) == 'option':
            raise docutils.nodes.SkipChildren 
开发者ID:QubesOS,项目名称:qubes-core-admin,代码行数:7,代码来源:dochelpers.py

示例9: visit_desc_name

# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import nodes [as 别名]
def visit_desc_name(self, node):
        """ Checks if the option is defined `self.args` """
        if not isinstance(node[0], docutils.nodes.Text):
            raise sphinx.errors.SphinxError('first child should be Text')

        arg = str(node[0])
        try:
            self.args.remove(arg)
        except KeyError:
            raise sphinx.errors.SphinxError(
                'No such argument for {!r}: {!r}'.format(self.command, arg)) 
开发者ID:QubesOS,项目名称:qubes-core-admin,代码行数:13,代码来源:dochelpers.py

示例10: apply

# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import nodes [as 别名]
def apply(self):
        thebe_config = self.config.jupyter_sphinx_thebelab_config

        for cell_node in self.document.traverse(JupyterCellNode):
            (output_bundle_node,) = cell_node.traverse(CellOutputBundleNode)

            # Create doctree nodes for cell outputs.
            output_nodes = cell_output_to_nodes(
                output_bundle_node.outputs,
                self.config.jupyter_execute_data_priority,
                bool(cell_node.attributes["stderr"]),
                sphinx_abs_dir(self.env),
                thebe_config,
            )
            # Remove the outputbundlenode and we'll attach the outputs next
            attach_outputs(output_nodes, cell_node, thebe_config, cell_node.cm_language)

        # Image collect extra nodes from cell outputs that we need to process
        for node in self.document.traverse(image):
            # If the image node has `candidates` then it's already been processed
            # as in-line content, so skip it
            if "candidates" in node:
                continue
            # re-initialize an ImageCollector because the `app` imagecollector instance
            # is only available via event listeners.
            col = ImageCollector()
            col.process_doc(self.app, node) 
开发者ID:jupyter,项目名称:jupyter-sphinx,代码行数:29,代码来源:ast.py

示例11: visit_section

# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import nodes [as 别名]
def visit_section(self, node):
        non_section_childs = list(filter(
            lambda x: type(x) != docutils.nodes.section, node.children
        ))
        handle_non_section_nodes(node, non_section_childs, self.name, self.data) 
开发者ID:coala,项目名称:corobo,代码行数:7,代码来源:extraction.py

示例12: visit_reference

# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import nodes [as 别名]
def visit_reference(self, node):
        # Catch reference nodes for link-checking.
        check_link(node['refuri']) 
开发者ID:eliben,项目名称:code-for-blog,代码行数:5,代码来源:rst-link-check.py

示例13: default_visit

# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import nodes [as 别名]
def default_visit(self, node):
        # Pass all other nodes through.
        pass 
开发者ID:eliben,项目名称:code-for-blog,代码行数:5,代码来源:rst-link-check.py

示例14: __init__

# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import nodes [as 别名]
def __init__(self, document):
        docutils.nodes.SparseNodeVisitor.__init__(self, document)
        self.toc = None
        # For some reason, when called via sphinx,
        # .. contents:: ends up trying to call
        # visitor.document.reporter.debug
        # so we need a valid document here.
        self.document = docutils.utils.new_document('') 
开发者ID:rst2pdf,项目名称:rst2pdf,代码行数:10,代码来源:genelements.py


注:本文中的docutils.nodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。