Patchwork [7,of,8] check-code: check comment for '.. note::' without two newlines

login
register
mail settings
Submitter Simon Heimberg
Date Nov. 2, 2013, 11:36 a.m.
Message ID <62b32b755aacac71a83e.1383392167@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/2844/
State Superseded, archived
Headers show

Comments

Simon Heimberg - Nov. 2, 2013, 11:36 a.m.
# HG changeset patch
# User Simon Heimberg <simohe@besonet.ch>
# Date 1383388423 -3600
#      Sat Nov 02 11:33:43 2013 +0100
# Branch stable
# Node ID 62b32b755aacac71a83eda89229bff551fa8b534
# Parent  dbe30788f7d828caa6fd541dc5d4fe8083cb8137
check-code: check comment for '.. note::' without two newlines

Because string entries are replaced before matching, we must search for
the transformed pattern. But it seems to be quite unique and does not return
false matches. If it will, they can be listed as 3rd arg in pypats.

Patch

diff -r dbe30788f7d8 -r 62b32b755aac contrib/check-code.py
--- a/contrib/check-code.py	Sat Nov 02 11:33:32 2013 +0100
+++ b/contrib/check-code.py	Sat Nov 02 11:33:43 2013 +0100
@@ -263,6 +263,7 @@ 
   ],
   # warnings
   [
+    (r'(^| )oo +xxxxoo[ \n][^\n]', "add two newlines after '.. note::'"),
   ]
 ]
 
diff -r dbe30788f7d8 -r 62b32b755aac tests/test-check-code.t
--- a/tests/test-check-code.t	Sat Nov 02 11:33:32 2013 +0100
+++ b/tests/test-check-code.t	Sat Nov 02 11:33:43 2013 +0100
@@ -204,3 +204,42 @@ 
    don't use old-style two-argument raise, use Exception(message)
   [1]
 
+  $ cat > rst.py <<EOF
+  > """problematic rst text
+  > 
+  > .. note::
+  >     wrong
+  > """
+  > 
+  > '''
+  > 
+  > .. note::
+  > 
+  >     valid
+  > 
+  > new text
+  > 
+  >     .. note::
+  > 
+  >         also valid
+  > '''
+  > 
+  > """mixed
+  > 
+  > .. note::
+  > 
+  >   good
+  > 
+  >     .. note::
+  >         plus bad
+  > """
+  > EOF
+  $ $check_code -w rst.py
+  rst.py:3:
+   > .. note::
+   warning: add two newlines after '.. note::'
+  rst.py:26:
+   >     .. note::
+   warning: add two newlines after '.. note::'
+  [1]
+