Merge with 'stable'

This commit is contained in:
shimizukawa
2016-01-24 13:47:51 +09:00
11 changed files with 130 additions and 16 deletions

View File

@@ -0,0 +1,13 @@
===========================
Literal Includes for python
===========================
block start with blank or comment
=================================
.. literalinclude:: target.py
:pyobject: block_start_with_comment
.. literalinclude:: target.py
:pyobject: block_start_with_blank

View File

@@ -0,0 +1,22 @@
# Literally included file using Python highlighting
# -*- coding: utf-8 -*-
foo = "Including Unicode characters: üöä"
class Foo:
pass
class Bar:
def baz():
pass
# comment after Bar class definition
def bar(): pass
def block_start_with_comment():
# Comment
return 1
def block_start_with_blank():
return 1

View File

@@ -544,3 +544,25 @@ def test_toctree_maxdepth_howto(app, status, warning):
print(status.getvalue())
print(warning.getvalue())
assert '\\setcounter{tocdepth}{2}' in result
@with_app(buildername='latex', testroot='toctree-maxdepth',
confoverrides={'master_doc': 'foo'})
def test_toctree_not_found(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
assert '\\setcounter{tocdepth}' not in result
@with_app(buildername='latex', testroot='toctree-maxdepth',
confoverrides={'master_doc': 'bar'})
def test_toctree_without_maxdepth(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
print(result)
print(status.getvalue())
print(warning.getvalue())
assert '\\setcounter{tocdepth}' not in result

View File

@@ -98,6 +98,30 @@ def test_literal_include_dedent(app, status, warning):
assert blocks[5].text == '\n\n' # dedent: 1000
@with_app('xml', testroot='directive-code')
def test_literal_include_block_start_with_comment_or_brank(app, status, warning):
app.builder.build(['python'])
et = ElementTree.parse(app.outdir / 'python.xml')
secs = et.findall('./section/section')
literal_include = secs[0].findall('literal_block')
assert len(literal_include) > 0
actual = literal_include[0].text
expect = (
'def block_start_with_comment():\n'
' # Comment\n'
' return 1\n'
)
assert actual == expect
actual = literal_include[1].text
expect = (
'def block_start_with_blank():\n'
'\n'
' return 1\n'
)
assert actual == expect
@with_app('html', testroot='directive-code')
def test_literal_include_linenos(app, status, warning):
app.builder.build(['linenos'])