本文整理汇总了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
示例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")
示例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")
示例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")
示例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
示例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
示例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
示例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
示例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")
示例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
示例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
示例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
示例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
示例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()
示例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")