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


Python parsers.rst方法代码示例

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


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

示例1: read_doc

# 需要导入模块: from docutils import parsers [as 别名]
# 或者: from docutils.parsers import rst [as 别名]
def read_doc(fn, kwds):

    with codecs.open(fn, encoding="utf-8")  as fileobj:
        txt = fileobj.read()
    
    txt = unicode(txt)

    # Parse the file into a document with the rst parser.
    default_settings = docutils.frontend.OptionParser(
        components=(docutils.parsers.rst.Parser,)).get_default_values()

    default_settings.report_level = 'quiet' # level 4
    document = docutils.utils.new_document(fileobj.name, default_settings)

    parser = docutils.parsers.rst.Parser()
    parser.parse(txt, document)

    # Visit the parsed document with our link-checking visitor.
    visitor = TermVisitor(document)
    visitor.kwds_dict = kwds
    document.walk(visitor) 
开发者ID:geographika,项目名称:mappyfile,代码行数:23,代码来源:docs_parser.py

示例2: parse_readme

# 需要导入模块: from docutils import parsers [as 别名]
# 或者: from docutils.parsers import rst [as 别名]
def parse_readme(cls, readme_path: str = 'README.rst',
                     encoding: str = 'utf-8') -> t.Tuple[str, str]:
        """Parse readme and resolve relative links in it if it is feasible.

        Links are resolved if readme is in rst format and the package is hosted on GitHub.
        """
        readme_path = pathlib.Path(readme_path)
        with HERE.joinpath(readme_path).open(encoding=encoding) as readme_file:
            long_description = readme_file.read()  # type: str

        if readme_path.suffix.lower() == '.rst' and cls.url.startswith('https://github.com/'):
            base_url = '{}/blob/v{}/'.format(cls.url, cls.version)
            long_description = resolve_relative_rst_links(long_description, base_url)

        long_description_content_type = {'.rst': 'text/x-rst', '.md': 'text/markdown'}.get(
            readme_path.suffix.lower(), 'text/plain')
        long_description_content_type += '; charset=UTF-8'

        return long_description, long_description_content_type 
开发者ID:mbdevpl,项目名称:transpyle,代码行数:21,代码来源:setup_boilerplate.py

示例3: _parse_rst

# 需要导入模块: from docutils import parsers [as 别名]
# 或者: from docutils.parsers import rst [as 别名]
def _parse_rst(text: str) -> docutils.nodes.document:
    parser = docutils.parsers.rst.Parser()
    components = (docutils.parsers.rst.Parser,)
    settings = docutils.frontend.OptionParser(
        components=components).get_default_values()
    document = docutils.utils.new_document('<rst-doc>', settings=settings)
    parser.parse(text, document)
    return document


# date can be YYYY-MM-DD or "TBD" 
开发者ID:aio-libs,项目名称:aiobotocore,代码行数:13,代码来源:test-version.py

示例4: test_release_versions

# 需要导入模块: from docutils import parsers [as 别名]
# 或者: from docutils.parsers import rst [as 别名]
def test_release_versions():
    # ensures versions in CHANGES.rst + __init__.py match
    init_version = version.parse(aiobotocore.__version__)

    changes_path = Path(__file__).absolute().parent.parent / 'CHANGES.rst'

    with changes_path.open('r') as f:
        changes_doc = _parse_rst(f.read())

    rst_ver_str = changes_doc[0][1][0][0]  # ex: 0.11.1 (2020-01-03)
    rst_prev_ver_str = changes_doc[0][2][0][0]

    rst_ver_groups = _rst_ver_date_str_re.match(rst_ver_str)
    rst_prev_ver_groups = _rst_ver_date_str_re.match(rst_prev_ver_str)

    rst_ver = version.parse(rst_ver_groups['version'])
    rst_prev_ver = version.parse(rst_prev_ver_groups['version'])

    # first the init version should match the rst version
    assert init_version == rst_ver

    # the current version must be greater than the previous version
    assert rst_ver > rst_prev_ver

    rst_date = rst_ver_groups['date']
    rst_prev_date = rst_prev_ver_groups['date']

    if rst_date == 'TBD':
        assert rst_ver.is_prerelease, \
            'Version must be prerelease if final release date not set'
    else:
        assert not rst_ver.is_prerelease, \
            'Version must not be prerelease if release date set'

        rst_date = datetime.strptime(rst_date, '%Y-%m-%d').date()
        rst_prev_date = datetime.strptime(rst_prev_date, '%Y-%m-%d').date()

        assert rst_date > rst_prev_date, 'Current release must be after last release' 
开发者ID:aio-libs,项目名称:aiobotocore,代码行数:40,代码来源:test-version.py

示例5: parse_rst

# 需要导入模块: from docutils import parsers [as 别名]
# 或者: from docutils.parsers import rst [as 别名]
def parse_rst(text: str) -> docutils.nodes.document:
    """Parse text assuming it's an RST markup."""
    parser = docutils.parsers.rst.Parser()
    components = (docutils.parsers.rst.Parser,)
    settings = docutils.frontend.OptionParser(components=components).get_default_values()
    document = docutils.utils.new_document('<rst-doc>', settings=settings)
    parser.parse(text, document)
    return document 
开发者ID:vecto-ai,项目名称:vecto,代码行数:10,代码来源:setup_boilerplate.py

示例6: parse_readme

# 需要导入模块: from docutils import parsers [as 别名]
# 或者: from docutils.parsers import rst [as 别名]
def parse_readme(cls, readme_path: str = 'README.rst', encoding: str = 'utf-8') -> str:
        """Parse readme and resolve relative links in it if it is feasible.

        Links are resolved if readme is in rst format and the package is hosted on GitHub.
        """
        with HERE.joinpath(readme_path).open(encoding=encoding) as readme_file:
            long_description = readme_file.read()  # type: str

        if readme_path.endswith('.rst') and cls.download_url.startswith('https://github.com/'):
            base_url = '{}/blob/v{}/'.format(cls.download_url, cls.version)
            long_description = resolve_relative_rst_links(long_description, base_url)

        return long_description 
开发者ID:vecto-ai,项目名称:vecto,代码行数:15,代码来源:setup_boilerplate.py

示例7: check_links_in_rst

# 需要导入模块: from docutils import parsers [as 别名]
# 或者: from docutils.parsers import rst [as 别名]
def check_links_in_rst(fileobj):
    # Parse the file into a document with the rst parser.
    default_settings = docutils.frontend.OptionParser(
        components=(docutils.parsers.rst.Parser,)).get_default_values()
    document = docutils.utils.new_document(fileobj.name, default_settings)
    parser = docutils.parsers.rst.Parser()
    parser.parse(fileobj.read(), document)

    # Visit the parsed document with our link-checking visitor.
    visitor = LinkCheckerVisitor(document)
    document.walk(visitor) 
开发者ID:eliben,项目名称:code-for-blog,代码行数:13,代码来源:rst-link-check.py

示例8: make_rst_section

# 需要导入模块: from docutils import parsers [as 别名]
# 或者: from docutils.parsers import rst [as 别名]
def make_rst_section(heading, char):
    """Format a section header in rst"""
    return '{}\n{}\n\n'.format(heading, char[0] * len(heading)) 
开发者ID:QubesOS,项目名称:qubes-core-admin-client,代码行数:5,代码来源:dochelpers.py


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