Skip to content

Commit 53177ea

Browse files
committed
Triple backticks can be legitimately used to show single backticks to readers.
1 parent 6083c74 commit 53177ea

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

sphinxlint.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,16 @@ def type_of_explicit_markup(line):
402402
)
403403

404404

405-
@checker(".rst", severity=2)
405+
@checker(".rst", falsepositives=True, severity=2)
406406
def check_triple_backticks(file, lines):
407-
f"""Check for triple backticks.
407+
"""Check for triple backticks.
408408
409409
Good: ``Point``
410410
Bad: ```Point```
411+
412+
But in reality, triple backticks are valid: ```foo``` gets
413+
rendered as `foo`, it's at least used by Sphinx to document rst
414+
syntax, but it's really uncommon.
411415
"""
412416
for lno, line in enumerate(lines):
413417
match = triple_backticks.search(line)
File renamed without changes.

tests/test_sphinxlint.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,28 @@ def test_sphinxlint_shall_pass(file, capsys):
1919
assert error_count == 0
2020

2121

22+
@pytest.mark.parametrize(
23+
"file", [str(f) for f in (FIXTURE_DIR / "triggers-false-positive").iterdir()]
24+
)
25+
def test_sphinxlint_shall_trigger_false_positive(file, capsys):
26+
try:
27+
main(["sphinxlint.py", str(file)])
28+
except SystemExit as err:
29+
error_count = err.code
30+
out, err = capsys.readouterr()
31+
assert out == "No problems found.\n"
32+
assert err == ""
33+
assert error_count == 0
34+
try:
35+
main(["sphinxlint.py", "-f", str(file)])
36+
except SystemExit as err:
37+
error_count = err.code
38+
out, err = capsys.readouterr()
39+
assert out != "No problems found.\n"
40+
assert err == ""
41+
assert error_count > 0
42+
43+
2244
@pytest.mark.parametrize("file", [str(f) for f in (FIXTURE_DIR / "xfail").iterdir()])
2345
def test_sphinxlint_shall_not_pass(file, capsys):
2446
try:

0 commit comments

Comments
 (0)