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

login
register
mail settings
Submitter Simon Heimberg
Date Nov. 5, 2013, 8:06 a.m.
Message ID <0d56501f3381b0066453.1383638798@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/2854/
State Accepted
Commit 289bbb294e824e4afed3796d5b23955de9b4a85b
Headers show

Comments

Simon Heimberg - Nov. 5, 2013, 8:06 a.m.
# HG changeset patch
# User Simon Heimberg <simohe@besonet.ch>
# Date 1383638431 -3600
#      Tue Nov 05 09:00:31 2013 +0100
# Branch stable
# Node ID 0d56501f3381b0066453cb238ada262bad114b3a
# Parent  c9c7cfa3440b22eb72cabcbcf3bde87bf8f905ab
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 c9c7cfa3440b -r 0d56501f3381 contrib/check-code.py
--- a/contrib/check-code.py	Tue Nov 05 08:59:55 2013 +0100
+++ b/contrib/check-code.py	Tue Nov 05 09:00:31 2013 +0100
@@ -263,6 +263,7 @@ 
   ],
   # warnings
   [
+    (r'(^| )oo +xxxxoo[ \n][^\n]', "add two newlines after '.. note::'"),
   ]
 ]
 
diff -r c9c7cfa3440b -r 0d56501f3381 tests/test-check-code.t
--- a/tests/test-check-code.t	Tue Nov 05 08:59:55 2013 +0100
+++ b/tests/test-check-code.t	Tue Nov 05 09:00:31 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]
+