本文整理汇总了Python中sphinx.directives.code.LiteralIncludeReader类的典型用法代码示例。如果您正苦于以下问题:Python LiteralIncludeReader类的具体用法?Python LiteralIncludeReader怎么用?Python LiteralIncludeReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LiteralIncludeReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_LiteralIncludeReader_prepend
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,代码行数:7,代码来源:test_directive_code.py
示例2: test_LiteralIncludeReader_lines2
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,代码行数:7,代码来源:test_directive_code.py
示例3: test_LiteralIncludeReader_lineno_start
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,代码行数:7,代码来源:test_directive_code.py
示例4: test_LiteralIncludeReader_lineno_start
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,代码行数:7,代码来源:test_directive_code.py
示例5: test_LiteralIncludeReader_start_after
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,代码行数:7,代码来源:test_directive_code.py
示例6: test_LiteralIncludeReader_pyobject1
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,代码行数:7,代码来源:test_directive_code.py
示例7: test_LiteralIncludeReader_lines_and_lineno_match1
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,代码行数:8,代码来源:test_directive_code.py
示例8: test_LiteralIncludeReader_lines1
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,代码行数:8,代码来源:test_directive_code.py
示例9: test_LiteralIncludeReader_start_at_and_lines
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,代码行数:8,代码来源:test_directive_code.py
示例10: test_LiteralIncludeReader_pyobject2
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,代码行数:8,代码来源:test_directive_code.py
示例11: test_LiteralIncludeReader_start_at
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,代码行数:9,代码来源:test_directive_code.py
示例12: test_LiteralIncludeReader_start_after_and_lines
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,代码行数:11,代码来源:test_directive_code.py
示例13: test_LiteralIncludeReader_tabwidth
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,代码行数:16,代码来源:test_directive_code.py
示例14: test_LiteralIncludeReader_diff
def test_LiteralIncludeReader_diff():
options = {'diff': TESTROOT_PATH / 'literal-diff.inc'}
reader = LiteralIncludeReader(LITERAL_INC_PATH, options, DUMMY_CONFIG)
content, lines = reader.read()
assert content == ("--- " + TESTROOT_PATH + "/literal-diff.inc\n"
"+++ " + TESTROOT_PATH + "/literal.inc\n"
"@@ -7,8 +7,8 @@\n"
" pass\n"
" \n"
" class Bar:\n"
"- def baz(self):\n"
"+ def baz():\n"
" pass\n"
" \n"
"-# comment after Bar class\n"
"+# comment after Bar class definition\n"
" def bar(): pass\n")
开发者ID:nwf,项目名称:sphinx,代码行数:17,代码来源:test_directive_code.py
示例15: test_LiteralIncludeReader_diff
def test_LiteralIncludeReader_diff(testroot, literal_inc_path):
options = {'diff': testroot / 'literal-diff.inc'}
reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
content, lines = reader.read()
assert content == ("--- " + testroot + "/literal-diff.inc\n"
"+++ " + testroot + "/literal.inc\n"
"@@ -7,8 +7,8 @@\n"
" pass\n"
" \n"
" class Bar:\n"
"- def baz(self):\n"
"+ def baz():\n"
" pass\n"
" \n"
"-# comment after Bar class\n"
"+# comment after Bar class definition\n"
" def bar(): pass\n")
开发者ID:AWhetter,项目名称:sphinx,代码行数:17,代码来源:test_directive_code.py
示例16: test_LiteralIncludeReader_missing_start_and_end
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,代码行数:20,代码来源:test_directive_code.py
示例17: test_LiteralIncludeReader_dedent
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,代码行数:24,代码来源:test_directive_code.py
示例18: test_LiteralIncludeReader_tabwidth_dedent
def test_LiteralIncludeReader_tabwidth_dedent(testroot):
options = {'tab-width': 4, 'dedent': 4, 'pyobject': 'Qux.quux'}
reader = LiteralIncludeReader(testroot / 'target.py', options, DUMMY_CONFIG)
content, lines = reader.read()
assert content == ("def quux(self):\n"
" pass\n")
开发者ID:AWhetter,项目名称:sphinx,代码行数:6,代码来源:test_directive_code.py
示例19: test_LiteralIncludeReader_pyobject3
def test_LiteralIncludeReader_pyobject3():
options = {'pyobject': 'Bar.baz'}
reader = LiteralIncludeReader(LITERAL_INC_PATH, options, DUMMY_CONFIG)
content, lines = reader.read()
assert content == (" def baz():\n"
" pass\n")
开发者ID:nwf,项目名称:sphinx,代码行数:6,代码来源:test_directive_code.py
示例20: test_LiteralIncludeReader_lines_and_lineno_match3
def test_LiteralIncludeReader_lines_and_lineno_match3(literal_inc_path, app, status, warning):
options = {'lines': '100-', 'lineno-match': True}
reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
with pytest.raises(ValueError):
content, lines = reader.read()
开发者ID:AWhetter,项目名称:sphinx,代码行数:5,代码来源:test_directive_code.py
注:本文中的sphinx.directives.code.LiteralIncludeReader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论