diff --git a/CHANGES b/CHANGES index e054dc24a..b186a7fc7 100644 --- a/CHANGES +++ b/CHANGES @@ -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 ---------- diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index dc855e83d..bbe323391 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -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'), diff --git a/tests/test_directive_code.py b/tests/test_directive_code.py index c1d476250..f2ca9f040 100644 --- a/tests/test_directive_code.py +++ b/tests/test_directive_code.py @@ -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)