Skip to content

Commit 78a49c1

Browse files
author
awu42
committed
Edited find_titles method
1 parent 88dfc46 commit 78a49c1

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

scripts/validate_rst_title_capitalization.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,13 @@ def find_titles(rst_file: str) -> Generator[Tuple[str, int], None, None]:
120120
table = str.maketrans("", "", "*`_")
121121

122122
for i, line in enumerate(lines):
123-
if line and lines[i - 1]:
124-
line_chars = set(line)
125-
if len(line_chars) == 1 and line_chars.pop() in symbols:
126-
if i >= 2:
127-
if line == lines[i - 2]:
128-
if len(line) == len(lines[i - 1]):
129-
yield lines[i - 1].translate(table), i
130-
continue
131-
if len(line) >= len(lines[i - 1]):
132-
yield lines[i - 1].translate(table), i
123+
line_chars = set(line)
124+
if (
125+
len(line_chars) == 1
126+
and line_chars.pop() in symbols
127+
and len(line) == len(lines[i - 1])
128+
):
129+
yield lines[i - 1].translate(table), i
133130

134131

135132
def find_rst_files(source_paths: List[str]) -> Generator[str, None, None]:

0 commit comments

Comments
 (0)