Skip to content

Commit aad06d0

Browse files
committed
Also do paragraphs()
1 parent 7d63ef3 commit aad06d0

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

sphinxlint/sphinxlint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def check_text(filename, text, checkers, options=None):
3636
errors = []
3737
ext = splitext(filename)[1]
3838
checkers = {checker for checker in checkers if ext in checker.suffixes}
39-
lines = text.splitlines(keepends=True)
39+
lines = tuple(text.splitlines(keepends=True))
4040
if any(checker.rst_only for checker in checkers):
4141
lines_with_rst_only = hide_non_rst_blocks(lines)
4242
for check in checkers:

sphinxlint/utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@ def escape2null(text):
7979
start = found + 2 # skip character after escape
8080

8181

82+
@lru_cache()
8283
def paragraphs(lines):
8384
"""Yield (paragraph_line_no, paragraph_text) pairs describing
8485
paragraphs of the given lines.
8586
"""
87+
output = []
8688
paragraph = []
8789
paragraph_lno = 1
8890
for lno, line in enumerate(lines, start=1):
@@ -92,10 +94,11 @@ def paragraphs(lines):
9294
paragraph_lno = lno
9395
paragraph.append(line)
9496
elif paragraph:
95-
yield paragraph_lno, "".join(paragraph)
97+
output.append((paragraph_lno, "".join(paragraph)))
9698
paragraph = []
9799
if paragraph:
98-
yield paragraph_lno, "".join(paragraph)
100+
output.append((paragraph_lno, "".join(paragraph)))
101+
return tuple(output)
99102

100103

101104
def looks_like_glued(match):

tests/test_sphinxlint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_sphinxlint_shall_not_pass(file, expected_errors, capsys):
7070
@pytest.mark.parametrize("file", [str(FIXTURE_DIR / "paragraphs.rst")])
7171
def test_paragraphs(file):
7272
with open(file) as f:
73-
lines = f.readlines()
73+
lines = tuple(f.readlines())
7474
actual = paragraphs(lines)
7575
for lno, para in actual:
7676
firstpline = para.splitlines(keepends=True)[0]

0 commit comments

Comments
 (0)