diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2017-02-17 23:03:05 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2017-02-17 23:36:12 +0900 |
commit | 88b84a532fbfd2df5917b2fc6800f756d313adc7 (patch) | |
tree | 597aa2f999000a4f3d5ddd71bd4ac0ba54eef0d5 /sphinx/directives/code.py | |
parent | 2f3a3d8cc2580e606e2e3dc595853a63d6ff7150 (diff) | |
download | sphinx-git-88b84a532fbfd2df5917b2fc6800f756d313adc7.tar.gz |
Add testcase for :lineno-match: option
Diffstat (limited to 'sphinx/directives/code.py')
-rw-r--r-- | sphinx/directives/code.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index 5b375a590..cb561fab7 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -261,7 +261,7 @@ class LiteralIncludeReader(object): # make sure the line list is not "disjoint". first = linelist[0] if all(first + i == n for i, n in enumerate(linelist)): - self.lineno_start = linelist[0] + 1 + self.lineno_start += linelist[0] else: raise ValueError(_('Cannot use "lineno-match" with a disjoint ' 'set of "lines"')) @@ -284,12 +284,15 @@ class LiteralIncludeReader(object): if start: for lineno, line in enumerate(lines): if start in line: - if 'lineno-match' in self.options: - self.lineno_start += lineno + 1 - if inclusive: + if 'lineno-match' in self.options: + self.lineno_start += lineno + 1 + return lines[lineno + 1:] else: + if 'lineno-match' in self.options: + self.lineno_start += lineno + return lines[lineno:] return lines @@ -308,9 +311,6 @@ class LiteralIncludeReader(object): if end: for lineno, line in enumerate(lines): if end in line: - if 'lineno-match' in self.options: - self.lineno_start += lineno + 1 - if inclusive: return lines[:lineno + 1] else: |