mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Applied Black, refs #2544
This commit is contained in:
parent
6de83bf3a9
commit
06b442c894
1 changed files with 17 additions and 13 deletions
|
|
@ -109,13 +109,13 @@ def test_functions_marked_with_documented_are_documented(documented_fns, fn):
|
||||||
def test_rst_heading_underlines_match_title_length():
|
def test_rst_heading_underlines_match_title_length():
|
||||||
"""Test that RST heading underlines are the same length as their titles."""
|
"""Test that RST heading underlines are the same length as their titles."""
|
||||||
# Common RST underline characters
|
# Common RST underline characters
|
||||||
underline_chars = ['-', '=', '~', '^', '+', '*', '#']
|
underline_chars = ["-", "=", "~", "^", "+", "*", "#"]
|
||||||
|
|
||||||
errors = []
|
errors = []
|
||||||
|
|
||||||
for rst_file in docs_path.glob("*.rst"):
|
for rst_file in docs_path.glob("*.rst"):
|
||||||
content = rst_file.read_text()
|
content = rst_file.read_text()
|
||||||
lines = content.split('\n')
|
lines = content.split("\n")
|
||||||
|
|
||||||
for i in range(len(lines) - 1):
|
for i in range(len(lines) - 1):
|
||||||
current_line = lines[i]
|
current_line = lines[i]
|
||||||
|
|
@ -123,10 +123,12 @@ def test_rst_heading_underlines_match_title_length():
|
||||||
|
|
||||||
# Check if next line is entirely made of a single underline character
|
# Check if next line is entirely made of a single underline character
|
||||||
# and is at least 5 characters long (to avoid false positives)
|
# and is at least 5 characters long (to avoid false positives)
|
||||||
if (next_line and
|
if (
|
||||||
len(next_line) >= 5 and
|
next_line
|
||||||
len(set(next_line)) == 1 and
|
and len(next_line) >= 5
|
||||||
next_line[0] in underline_chars):
|
and len(set(next_line)) == 1
|
||||||
|
and next_line[0] in underline_chars
|
||||||
|
):
|
||||||
# Skip if the previous line is empty (blank line before underline)
|
# Skip if the previous line is empty (blank line before underline)
|
||||||
if not current_line:
|
if not current_line:
|
||||||
continue
|
continue
|
||||||
|
|
@ -135,11 +137,13 @@ def test_rst_heading_underlines_match_title_length():
|
||||||
# Look at the line before current_line to see if it's also an underline
|
# Look at the line before current_line to see if it's also an underline
|
||||||
if i > 0:
|
if i > 0:
|
||||||
prev_line = lines[i - 1]
|
prev_line = lines[i - 1]
|
||||||
if (prev_line and
|
if (
|
||||||
len(prev_line) >= 5 and
|
prev_line
|
||||||
len(set(prev_line)) == 1 and
|
and len(prev_line) >= 5
|
||||||
prev_line[0] in underline_chars and
|
and len(set(prev_line)) == 1
|
||||||
len(prev_line) == len(next_line)):
|
and prev_line[0] in underline_chars
|
||||||
|
and len(prev_line) == len(next_line)
|
||||||
|
):
|
||||||
# This is overline+underline style, skip it
|
# This is overline+underline style, skip it
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
@ -156,8 +160,8 @@ def test_rst_heading_underlines_match_title_length():
|
||||||
|
|
||||||
if errors:
|
if errors:
|
||||||
raise AssertionError(
|
raise AssertionError(
|
||||||
f"Found {len(errors)} RST heading(s) with mismatched underline length:\n\n" +
|
f"Found {len(errors)} RST heading(s) with mismatched underline length:\n\n"
|
||||||
"\n\n".join(errors)
|
+ "\n\n".join(errors)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue