Skip to content

Commit 999b43d

Browse files
committed
Push default-role to severity=0 as it's allowed according to Sphinx doc.
1 parent c985541 commit 999b43d

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

sphinxlint.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,14 @@ def check_suspicious_constructs_in_paragraphs(file, lines):
234234
backtick_in_front_of_role = re.compile(rf"(^|\s)`:{simplename}:`{role_body}`")
235235

236236

237+
@checker(".rst", severity=0)
238+
def check_default_role(file, lines):
239+
"""Check for default roles."""
240+
for lno, line in enumerate(hide_non_rst_blocks(lines), start=1):
241+
if default_role_re.search(line):
242+
yield lno, "default role used (hint: for inline code, use double backticks)"
243+
244+
237245
@checker(".rst", severity=2)
238246
def check_suspicious_constructs(file, lines):
239247
"""Check for suspicious reST constructs."""
@@ -261,8 +269,6 @@ def check_suspicious_constructs(file, lines):
261269
error = role_missing_surrogate_escape.search(line)
262270
if error and not is_in_a_table(error, line):
263271
yield lno, f"role missing surrogate escape before plural: {error.group(0)!r}"
264-
if default_role_re.search(line):
265-
yield lno, "default role used (hint: for inline code, use double backticks)"
266272

267273

268274
@checker(".py", ".rst")

tests/fixtures/xpass/sections.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
The following are all valid section title adornment characters
2-
according to https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#sections.
2+
according to
3+
https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#sections.
34

45

56
Section
@@ -128,4 +129,3 @@ Section
128129

129130
Section
130131
~~~~~~~
131-

tests/fixtures/xpass/splitted-role-in-a-table.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
In the following table there's a role spanning in two lines, this should not raise any error:
1+
In the following table there's a role spanning in two lines, this
2+
should not raise any error:
23

34
+-----------------------------------------+
45
| Method |

tests/test_nonregression.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import pytest
21
from sphinxlint import check
32

43

tests/test_sphinxlint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@pytest.mark.parametrize("file", [str(f) for f in (FIXTURE_DIR / "xpass").glob("*.*")])
1111
def test_sphinxlint_shall_pass(file, capsys):
1212
try:
13-
main(["sphinxlint.py", str(file)])
13+
main(["sphinxlint.py", "--severity=0", str(file)])
1414
except SystemExit as err:
1515
error_count = err.code
1616
out, err = capsys.readouterr()
@@ -22,7 +22,7 @@ def test_sphinxlint_shall_pass(file, capsys):
2222
@pytest.mark.parametrize("file", [str(f) for f in (FIXTURE_DIR / "xfail").glob("*.*")])
2323
def test_sphinxlint_shall_not_pass(file, capsys):
2424
try:
25-
main(["sphinxlint.py", str(file)])
25+
main(["sphinxlint.py", "--severity=0", str(file)])
2626
except SystemExit as err:
2727
error_count = err.code
2828
out, err = capsys.readouterr()

0 commit comments

Comments
 (0)