diff options
author | jfbu <jfbu@free.fr> | 2017-02-10 17:50:41 +0100 |
---|---|---|
committer | jfbu <jfbu@free.fr> | 2017-02-10 17:50:41 +0100 |
commit | eb08ba27138f35d21f320f84d2fe4a9b8238c1d6 (patch) | |
tree | 6665f558198af625ca27ef4e6ed3aea57c882631 /sphinx/directives/code.py | |
parent | a2338e4838223ed9c65397eba57f6fd14e1a062f (diff) | |
download | sphinx-git-eb08ba27138f35d21f320f84d2fe4a9b8238c1d6.tar.gz |
Fix an issue with lineno-start and a flake8 violation
Diffstat (limited to 'sphinx/directives/code.py')
-rw-r--r-- | sphinx/directives/code.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index c9d073abd..85fc28941 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -256,6 +256,8 @@ class LiteralInclude(Directive): lines = list(diff) linenostart = self.options.get('lineno-start', 1) + if 'lineno-match' in self.options: + linenostart = 1 objectname = self.options.get('pyobject') if objectname is not None: from sphinx.pycode import ModuleAnalyzer @@ -294,12 +296,12 @@ class LiteralInclude(Directive): res = [] for line_number, line in enumerate(lines): if not use and start_str and start_str in line: - if 'lineno-match' in self.options: - linenostart = line_number + 1 if start_inclusive: res.append(line) - else: - linenostart +=1 + if 'lineno-match' in self.options: + linenostart = line_number + 1 + if not start_inclusive: + linenostart += 1 use = True elif use and end_str and end_str in line: if end_inclusive: |