[Python-checkins] r68218 - python/trunk/Doc/tools/rstlint.py

georg.brandl python-checkins at python.org
Sat Jan 3 21:38:59 CET 2009


Author: georg.brandl
Date: Sat Jan  3 21:38:59 2009
New Revision: 68218

Log:
Recognize usage of the default role.


Modified:
   python/trunk/Doc/tools/rstlint.py

Modified: python/trunk/Doc/tools/rstlint.py
==============================================================================
--- python/trunk/Doc/tools/rstlint.py	(original)
+++ python/trunk/Doc/tools/rstlint.py	Sat Jan  3 21:38:59 2009
@@ -40,7 +40,7 @@
 
 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 @@
     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 @@
 @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')


More information about the Python-checkins mailing list