diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2017-05-19 00:25:23 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2017-05-19 00:25:23 +0900 |
commit | dabd356f8eb4d88ce363ed8078b29a160d065c5e (patch) | |
tree | 21cc5c67849aa3cfb38f287b2eace71d2f3ce6cd /sphinx/directives/code.py | |
parent | ec50d014eee0313d7a0fd15a23aa3154f349ed22 (diff) | |
download | sphinx-git-dabd356f8eb4d88ce363ed8078b29a160d065c5e.tar.gz |
Fix #3755: incorrectly warns about dedent with literalinclude
Diffstat (limited to 'sphinx/directives/code.py')
-rw-r--r-- | sphinx/directives/code.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index efa44bc14..f0da0d747 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -209,11 +209,7 @@ class LiteralIncludeReader(object): if 'tab-width' in self.options: text = text.expandtabs(self.options['tab-width']) - lines = text.splitlines(True) - if 'dedent' in self.options: - return dedent_lines(lines, self.options.get('dedent'), location=location) - else: - return lines + return text.splitlines(True) except (IOError, OSError): raise IOError(_('Include file %r not found or reading it failed') % filename) except UnicodeError: @@ -231,7 +227,8 @@ class LiteralIncludeReader(object): self.end_filter, self.lines_filter, self.prepend_filter, - self.append_filter] + self.append_filter, + self.dedent_filter] lines = self.read_file(self.filename, location=location) for func in filters: lines = func(lines, location=location) @@ -367,6 +364,12 @@ class LiteralIncludeReader(object): return lines + def dedent_filter(self, lines, location=None): + if 'dedent' in self.options: + return dedent_lines(lines, self.options.get('dedent'), location=location) + else: + return lines + class LiteralInclude(Directive): """ |