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


Python rst.Parser方法代碼示例

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


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

示例1: _check_rst_data

# 需要導入模塊: from docutils.parsers import rst [as 別名]
# 或者: from docutils.parsers.rst import Parser [as 別名]
def _check_rst_data(self, data):
        """Returns warnings when the provided data doesn't compile."""
        source_path = StringIO()
        parser = Parser()
        settings = frontend.OptionParser().get_default_values()
        settings.tab_width = 4
        settings.pep_references = None
        settings.rfc_references = None
        reporter = SilentReporter(source_path,
                          settings.report_level,
                          settings.halt_level,
                          stream=settings.warning_stream,
                          debug=settings.debug,
                          encoding=settings.error_encoding,
                          error_handler=settings.error_encoding_error_handler)

        document = nodes.document(settings, reporter, source=source_path)
        document.note_source(source_path, -1)
        try:
            parser.parse(data, document)
        except AttributeError:
            reporter.messages.append((-1, 'Could not finish the parsing.',
                                      '', {}))

        return reporter.messages 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:27,代碼來源:check.py

示例2: _check_rst_data

# 需要導入模塊: from docutils.parsers import rst [as 別名]
# 或者: from docutils.parsers.rst import Parser [as 別名]
def _check_rst_data(self, data):
        """Returns warnings when the provided data doesn't compile."""
        source_path = StringIO()
        parser = Parser()
        settings = frontend.OptionParser(components=(Parser,)).get_default_values()
        settings.tab_width = 4
        settings.pep_references = None
        settings.rfc_references = None
        reporter = SilentReporter(source_path,
                          settings.report_level,
                          settings.halt_level,
                          stream=settings.warning_stream,
                          debug=settings.debug,
                          encoding=settings.error_encoding,
                          error_handler=settings.error_encoding_error_handler)

        document = nodes.document(settings, reporter, source=source_path)
        document.note_source(source_path, -1)
        try:
            parser.parse(data, document)
        except AttributeError as e:
            reporter.messages.append(
                (-1, 'Could not finish the parsing: %s.' % e, '', {}))

        return reporter.messages 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:27,代碼來源:check.py

示例3: fix_docutils

# 需要導入模塊: from docutils.parsers import rst [as 別名]
# 或者: from docutils.parsers.rst import Parser [as 別名]
def fix_docutils():
    '''Work around https://bitbucket.org/birkenfeld/sphinx/issue/1154/'''

    import docutils.parsers
    from docutils.parsers import rst
    old_getclass = docutils.parsers.get_parser_class

    # Check if bug is there
    try:
        old_getclass('rst')
    except AttributeError:
        pass
    else:
        return

    def get_parser_class(parser_name):
        """Return the Parser class from the `parser_name` module."""
        if parser_name in ('rst', 'restructuredtext'):
            return rst.Parser
        else:
            return old_getclass(parser_name)
    docutils.parsers.get_parser_class = get_parser_class

    assert docutils.parsers.get_parser_class('rst') is rst.Parser 
開發者ID:s3ql,項目名稱:s3ql,代碼行數:26,代碼來源:setup.py

示例4: get_transforms

# 需要導入模塊: from docutils.parsers import rst [as 別名]
# 或者: from docutils.parsers.rst import Parser [as 別名]
def get_transforms(self):
        """List of transforms for documents parsed by this parser."""
        return rst.Parser.get_transforms(self) + [
            CreateNotebookSectionAnchors,
            ReplaceAlertDivs,
            CopyLinkedFiles,
        ] 
開發者ID:spatialaudio,項目名稱:nbsphinx,代碼行數:9,代碼來源:nbsphinx.py

示例5: renderList

# 需要導入模塊: from docutils.parsers import rst [as 別名]
# 或者: from docutils.parsers.rst import Parser [as 別名]
def renderList(l, markDownHelp, settings=None):
    """
    Given a list of reStructuredText or MarkDown sections, return a docutils node list
    """
    if len(l) == 0:
        return []
    if markDownHelp:
        return parseMarkDownBlock('\n\n'.join(l) + '\n')
    else:
        if settings is None:
            settings = OptionParser(components=(Parser,)).get_default_values()
        document = new_document(None, settings)
        Parser().parse('\n\n'.join(l) + '\n', document)
        return document.children 
開發者ID:rucio,項目名稱:rucio,代碼行數:16,代碼來源:ext.py

示例6: _check_rst_data

# 需要導入模塊: from docutils.parsers import rst [as 別名]
# 或者: from docutils.parsers.rst import Parser [as 別名]
def _check_rst_data(self, data):
        """Returns warnings when the provided data doesn't compile."""
        # the include and csv_table directives need this to be a path
        source_path = self.distribution.script_name or 'setup.py'
        parser = Parser()
        settings = frontend.OptionParser(components=(Parser,)).get_default_values()
        settings.tab_width = 4
        settings.pep_references = None
        settings.rfc_references = None
        reporter = SilentReporter(source_path,
                          settings.report_level,
                          settings.halt_level,
                          stream=settings.warning_stream,
                          debug=settings.debug,
                          encoding=settings.error_encoding,
                          error_handler=settings.error_encoding_error_handler)

        document = nodes.document(settings, reporter, source=source_path)
        document.note_source(source_path, -1)
        try:
            parser.parse(data, document)
        except AttributeError as e:
            reporter.messages.append(
                (-1, 'Could not finish the parsing: %s.' % e, '', {}))

        return reporter.messages 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:28,代碼來源:check.py

示例7: __init__

# 需要導入模塊: from docutils.parsers import rst [as 別名]
# 或者: from docutils.parsers.rst import Parser [as 別名]
def __init__(self, parser=None, parser_name=None):
        """`parser` should be ``None``."""
        if parser is None:
            parser = rst.Parser(rfc2822=True, inliner=self.inliner_class())
        standalone.Reader.__init__(self, parser, '') 
開發者ID:skarlekar,項目名稱:faces,代碼行數:7,代碼來源:pep.py

示例8: render

# 需要導入模塊: from docutils.parsers import rst [as 別名]
# 或者: from docutils.parsers.rst import Parser [as 別名]
def render(app, doctree, fromdocname):
    for node in doctree.traverse(YaqlDocNode):
        new_doc = utils.new_document('YAQL', doctree.settings)
        content = generate_doc(node.source)
        rst.Parser().parse(content, new_doc)
        node.replace_self(new_doc.children) 
開發者ID:openstack,項目名稱:yaql,代碼行數:8,代碼來源:yaqlautodoc.py

示例9: get_releases

# 需要導入模塊: from docutils.parsers import rst [as 別名]
# 或者: from docutils.parsers.rst import Parser [as 別名]
def get_releases(self):
        full_path = os.path.join(ROOT_DIR, "CHANGELOG.rst")
        with open(full_path) as f:
            changelog = f.read()
        with mock.patch.object(sys, "stderr"):
            parser = rst.Parser()
            settings = frontend.OptionParser(
                components=(rst.Parser,)).get_default_values()
            document = utils.new_document(changelog, settings)
            parser.parse(changelog, document)
            changelog = document.children
        if len(changelog) != 1:
            self.fail("'%s' file should contain one global section "
                      "with subsections for each release." % full_path)

        releases = []
        for node in changelog[0].children:
            if not isinstance(node, nodes.section):
                continue
            title = node.astext().split("\n", 1)[0]
            result = self.RE_RELEASE.match(title)
            if result:
                releases.append(result.groupdict()["version"])
        if not releases:
            self.fail("'%s' doesn't mention any releases..." % full_path)
        return releases 
開發者ID:openstack,項目名稱:rally-openstack,代碼行數:28,代碼來源:test_docker_readme.py

示例10: _parse_rst

# 需要導入模塊: from docutils.parsers import rst [as 別名]
# 或者: from docutils.parsers.rst import Parser [as 別名]
def _parse_rst(text):
    parser = rst.Parser()
    settings = frontend.OptionParser(
        components=(rst.Parser,)).get_default_values()
    document = utils.new_document(text, settings)
    parser.parse(text, document)
    return document.children 
開發者ID:openstack,項目名稱:rally-openstack,代碼行數:9,代碼來源:test_docstrings.py


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