literalinclude directive allows combination of :pyobject: and :lines:

This commit is contained in:
Takeshi KOMIYA 2017-02-22 00:29:24 +09:00
parent 3eb5b2960a
commit 675b5f4237
3 changed files with 10 additions and 1 deletions

View File

@ -109,6 +109,8 @@ Features added
* Support requests-2.0.0 (experimental) (refs: #3367)
* (latex) PDF page margin dimensions may be customized (refs: #3387)
* ``literalinclude`` directive allows combination of ``:pyobject:`` and
``:lines:`` options (refs: #3416)
Bugs fixed
----------

View File

@ -170,7 +170,6 @@ class CodeBlock(Directive):
class LiteralIncludeReader(object):
INVALID_OPTIONS_PAIR = [
('pyobject', 'lines'),
('lineno-match', 'lineno-start'),
('lineno-match', 'append'),
('lineno-match', 'prepend'),

View File

@ -65,6 +65,14 @@ def test_LiteralIncludeReader_pyobject3():
" pass\n")
def test_LiteralIncludeReader_pyobject_and_lines():
options = {'pyobject': 'Bar', 'lines': '2-'}
reader = LiteralIncludeReader(LITERAL_INC_PATH, options, DUMMY_CONFIG)
content, lines = reader.read()
assert content == (" def baz():\n"
" pass\n")
def test_LiteralIncludeReader_lines1():
options = {'lines': '1-4'}
reader = LiteralIncludeReader(LITERAL_INC_PATH, options, DUMMY_CONFIG)