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


Python LiteralIncludeReader.read方法代码示例

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


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

示例1: test_LiteralIncludeReader_start_after

# 需要导入模块: from sphinx.directives.code import LiteralIncludeReader [as 别名]
# 或者: from sphinx.directives.code.LiteralIncludeReader import read [as 别名]
def test_LiteralIncludeReader_start_after(literal_inc_path):
    options = {'lineno-match': True, 'start-after': 'Foo', 'end-before': 'Bar'}
    reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == ("    pass\n"
                       "\n")
    assert reader.lineno_start == 7
开发者ID:AWhetter,项目名称:sphinx,代码行数:9,代码来源:test_directive_code.py

示例2: test_LiteralIncludeReader_tabwidth

# 需要导入模块: from sphinx.directives.code import LiteralIncludeReader [as 别名]
# 或者: from sphinx.directives.code.LiteralIncludeReader import read [as 别名]
def test_LiteralIncludeReader_tabwidth(testroot):
    # tab-width: 4
    options = {'tab-width': 4, 'pyobject': 'Qux'}
    reader = LiteralIncludeReader(testroot / 'target.py', options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == ("class Qux:\n"
                       "    def quux(self):\n"
                       "        pass\n")

    # tab-width: 8
    options = {'tab-width': 8, 'pyobject': 'Qux'}
    reader = LiteralIncludeReader(testroot / 'target.py', options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == ("class Qux:\n"
                       "        def quux(self):\n"
                       "                pass\n")
开发者ID:AWhetter,项目名称:sphinx,代码行数:18,代码来源:test_directive_code.py

示例3: test_LiteralIncludeReader_prepend

# 需要导入模块: from sphinx.directives.code import LiteralIncludeReader [as 别名]
# 或者: from sphinx.directives.code.LiteralIncludeReader import read [as 别名]
def test_LiteralIncludeReader_prepend(literal_inc_path):
    options = {'lines': '1', 'prepend': 'Hello', 'append': 'Sphinx'}
    reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == ("Hello\n"
                       "# Literally included file using Python highlighting\n"
                       "Sphinx\n")
开发者ID:AWhetter,项目名称:sphinx,代码行数:9,代码来源:test_directive_code.py

示例4: test_LiteralIncludeReader_lines2

# 需要导入模块: from sphinx.directives.code import LiteralIncludeReader [as 别名]
# 或者: from sphinx.directives.code.LiteralIncludeReader import read [as 别名]
def test_LiteralIncludeReader_lines2(literal_inc_path):
    options = {'lines': '1,4,6'}
    reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == (u"# Literally included file using Python highlighting\n"
                       u"foo = \"Including Unicode characters: üöä\"\n"
                       u"class Foo:\n")
开发者ID:AWhetter,项目名称:sphinx,代码行数:9,代码来源:test_directive_code.py

示例5: test_LiteralIncludeReader_lineno_start

# 需要导入模块: from sphinx.directives.code import LiteralIncludeReader [as 别名]
# 或者: from sphinx.directives.code.LiteralIncludeReader import read [as 别名]
def test_LiteralIncludeReader_lineno_start():
    options = {'lineno-start': 5}
    reader = LiteralIncludeReader(LITERAL_INC_PATH, options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == LITERAL_INC_PATH.text()
    assert lines == 14
    assert reader.lineno_start == 5
开发者ID:nwf,项目名称:sphinx,代码行数:9,代码来源:test_directive_code.py

示例6: test_LiteralIncludeReader_lineno_start

# 需要导入模块: from sphinx.directives.code import LiteralIncludeReader [as 别名]
# 或者: from sphinx.directives.code.LiteralIncludeReader import read [as 别名]
def test_LiteralIncludeReader_lineno_start(literal_inc_path):
    options = {'lineno-start': 5}
    reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == literal_inc_path.text()
    assert lines == 14
    assert reader.lineno_start == 5
开发者ID:AWhetter,项目名称:sphinx,代码行数:9,代码来源:test_directive_code.py

示例7: test_LiteralIncludeReader_pyobject1

# 需要导入模块: from sphinx.directives.code import LiteralIncludeReader [as 别名]
# 或者: from sphinx.directives.code.LiteralIncludeReader import read [as 别名]
def test_LiteralIncludeReader_pyobject1(literal_inc_path):
    options = {'lineno-match': True, 'pyobject': 'Foo'}
    reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == ("class Foo:\n"
                       "    pass\n")
    assert reader.lineno_start == 6
开发者ID:AWhetter,项目名称:sphinx,代码行数:9,代码来源:test_directive_code.py

示例8: test_LiteralIncludeReader_lines_and_lineno_match1

# 需要导入模块: from sphinx.directives.code import LiteralIncludeReader [as 别名]
# 或者: from sphinx.directives.code.LiteralIncludeReader import read [as 别名]
def test_LiteralIncludeReader_lines_and_lineno_match1(literal_inc_path):
    options = {'lines': '4-6', 'lineno-match': True}
    reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == (u"foo = \"Including Unicode characters: üöä\"\n"
                       u"\n"
                       u"class Foo:\n")
    assert reader.lineno_start == 4
开发者ID:AWhetter,项目名称:sphinx,代码行数:10,代码来源:test_directive_code.py

示例9: test_LiteralIncludeReader_lines1

# 需要导入模块: from sphinx.directives.code import LiteralIncludeReader [as 别名]
# 或者: from sphinx.directives.code.LiteralIncludeReader import read [as 别名]
def test_LiteralIncludeReader_lines1():
    options = {'lines': '1-4'}
    reader = LiteralIncludeReader(LITERAL_INC_PATH, options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == (u"# Literally included file using Python highlighting\n"
                       u"# -*- coding: utf-8 -*-\n"
                       u"\n"
                       u"foo = \"Including Unicode characters: üöä\"\n")
开发者ID:nwf,项目名称:sphinx,代码行数:10,代码来源:test_directive_code.py

示例10: test_LiteralIncludeReader_pyobject2

# 需要导入模块: from sphinx.directives.code import LiteralIncludeReader [as 别名]
# 或者: from sphinx.directives.code.LiteralIncludeReader import read [as 别名]
def test_LiteralIncludeReader_pyobject2(literal_inc_path):
    options = {'pyobject': 'Bar'}
    reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == ("class Bar:\n"
                       "    def baz():\n"
                       "        pass\n")
    assert reader.lineno_start == 1  # no lineno-match
开发者ID:AWhetter,项目名称:sphinx,代码行数:10,代码来源:test_directive_code.py

示例11: test_LiteralIncludeReader_start_at_and_lines

# 需要导入模块: from sphinx.directives.code import LiteralIncludeReader [as 别名]
# 或者: from sphinx.directives.code.LiteralIncludeReader import read [as 别名]
def test_LiteralIncludeReader_start_at_and_lines(literal_inc_path):
    options = {'lines': '2, 3, 5', 'start-at': 'foo', 'end-before': '#'}
    reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == ("\n"
                       "class Foo:\n"
                       "\n")
    assert reader.lineno_start == 1
开发者ID:AWhetter,项目名称:sphinx,代码行数:10,代码来源:test_directive_code.py

示例12: test_LiteralIncludeReader_start_at

# 需要导入模块: from sphinx.directives.code import LiteralIncludeReader [as 别名]
# 或者: from sphinx.directives.code.LiteralIncludeReader import read [as 别名]
def test_LiteralIncludeReader_start_at():
    options = {'lineno-match': True, 'start-at': 'Foo', 'end-at': 'Bar'}
    reader = LiteralIncludeReader(LITERAL_INC_PATH, options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == ("class Foo:\n"
                       "    pass\n"
                       "\n"
                       "class Bar:\n")
    assert reader.lineno_start == 6
开发者ID:nwf,项目名称:sphinx,代码行数:11,代码来源:test_directive_code.py

示例13: test_LiteralIncludeReader_start_after_and_lines

# 需要导入模块: from sphinx.directives.code import LiteralIncludeReader [as 别名]
# 或者: from sphinx.directives.code.LiteralIncludeReader import read [as 别名]
def test_LiteralIncludeReader_start_after_and_lines(literal_inc_path):
    options = {'lineno-match': True, 'lines': '6-',
               'start-after': 'coding', 'end-before': 'comment'}
    reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == ("\n"
                       "class Bar:\n"
                       "    def baz():\n"
                       "        pass\n"
                       "\n")
    assert reader.lineno_start == 8
开发者ID:AWhetter,项目名称:sphinx,代码行数:13,代码来源:test_directive_code.py

示例14: test_LiteralIncludeReader_missing_start_and_end

# 需要导入模块: from sphinx.directives.code import LiteralIncludeReader [as 别名]
# 或者: from sphinx.directives.code.LiteralIncludeReader import read [as 别名]
def test_LiteralIncludeReader_missing_start_and_end(literal_inc_path):
    options = {'start-at': 'NOTHING'}
    reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
    with pytest.raises(ValueError):
        content, lines = reader.read()

    options = {'end-at': 'NOTHING'}
    reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
    with pytest.raises(ValueError):
        content, lines = reader.read()

    options = {'start-after': 'NOTHING'}
    reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
    with pytest.raises(ValueError):
        content, lines = reader.read()

    options = {'end-before': 'NOTHING'}
    reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
    with pytest.raises(ValueError):
        content, lines = reader.read()
开发者ID:AWhetter,项目名称:sphinx,代码行数:22,代码来源:test_directive_code.py

示例15: test_LiteralIncludeReader_dedent

# 需要导入模块: from sphinx.directives.code import LiteralIncludeReader [as 别名]
# 或者: from sphinx.directives.code.LiteralIncludeReader import read [as 别名]
def test_LiteralIncludeReader_dedent(literal_inc_path):
    # dedent: 2
    options = {'lines': '10-12', 'dedent': 2}
    reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == ("  def baz():\n"
                       "      pass\n"
                       "\n")

    # dedent: 4
    options = {'lines': '10-12', 'dedent': 4}
    reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == ("def baz():\n"
                       "    pass\n"
                       "\n")

    # dedent: 6
    options = {'lines': '10-12', 'dedent': 6}
    reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
    content, lines = reader.read()
    assert content == ("f baz():\n"
                       "  pass\n"
                       "\n")
开发者ID:AWhetter,项目名称:sphinx,代码行数:26,代码来源:test_directive_code.py


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