summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-01-03 20:38:59 (GMT)
committerGeorg Brandl <georg@python.org>2009-01-03 20:38:59 (GMT)
commitae24e7b5a2cfeb3e40ea6e619c01d27a79cf740c (patch)
tree098189769a5efcd3422c7bd806f898f40120b933 /Doc
parent9f7a3398ab55e4ccfa4e225a2908918c04c14e40 (diff)
downloadcpython-ae24e7b5a2cfeb3e40ea6e619c01d27a79cf740c.zip
cpython-ae24e7b5a2cfeb3e40ea6e619c01d27a79cf740c.tar.gz
cpython-ae24e7b5a2cfeb3e40ea6e619c01d27a79cf740c.tar.bz2
Recognize usage of the default role.
Diffstat (limited to 'Doc')
-rwxr-xr-xDoc/tools/rstlint.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Doc/tools/rstlint.py b/Doc/tools/rstlint.py
index 0d08e72..7e73942 100755
--- a/Doc/tools/rstlint.py
+++ b/Doc/tools/rstlint.py
@@ -40,7 +40,7 @@ directives = [
all_directives = '(' + '|'.join(directives) + ')'
seems_directive_re = re.compile(r'\.\. %s([^a-z:]|:(?!:))' % all_directives)
-
+default_role_re = re.compile(r'(^| )`\w([^`]*?\w)?`($| )')
leaked_markup_re = re.compile(r'[a-z]::[^=]|:[a-z]+:|`|\.\.\s*\w+:')
@@ -65,7 +65,8 @@ def check_syntax(fn, lines):
try:
code = ''.join(lines)
if '\r' in code:
- yield 0, '\\r in code file'
+ if os.name != 'nt':
+ yield 0, '\\r in code file'
code = code.replace('\r', '')
compile(code, fn, 'exec')
except SyntaxError, err:
@@ -75,9 +76,16 @@ def check_syntax(fn, lines):
@checker('.rst', severity=2)
def check_suspicious_constructs(fn, lines):
"""Check for suspicious reST constructs."""
+ inprod = False
for lno, line in enumerate(lines):
if seems_directive_re.match(line):
yield lno+1, 'comment seems to be intended as a directive'
+ if '.. productionlist::' in line:
+ inprod = True
+ elif not inprod and default_role_re.search(line):
+ yield lno+1, 'default role used'
+ elif inprod and not line.strip():
+ inprod = False
@checker('.py', '.rst')