Started extending the PEP-8 fixer to correct PEP-257 issues as well.

Wed, 18 Sep 2013 19:53:54 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 18 Sep 2013 19:53:54 +0200
changeset 2923
01ac1f364b38
parent 2922
16905f0f48be
child 2925
04896af1b0e1

Started extending the PEP-8 fixer to correct PEP-257 issues as well.

Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.pep8.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.UtilitiesPython2.pep8.html file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/Pep8/Pep257Checker.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/Pep8/Pep8Fixer.py file | annotate | diff | comparison | revisions
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Wed Sep 18 19:48:12 2013 +0200
+++ b/Documentation/Help/source.qhp	Wed Sep 18 19:53:54 2013 +0200
@@ -8100,6 +8100,13 @@
       <keyword name="Pep8Fixer (Module)" id="Pep8Fixer (Module)" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html" />
       <keyword name="Pep8Fixer.__codeMatch" id="Pep8Fixer.__codeMatch" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__codeMatch" />
       <keyword name="Pep8Fixer.__findLogical" id="Pep8Fixer.__findLogical" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__findLogical" />
+      <keyword name="Pep8Fixer.__fixD121" id="Pep8Fixer.__fixD121" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__fixD121" />
+      <keyword name="Pep8Fixer.__fixD131" id="Pep8Fixer.__fixD131" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__fixD131" />
+      <keyword name="Pep8Fixer.__fixD141" id="Pep8Fixer.__fixD141" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__fixD141" />
+      <keyword name="Pep8Fixer.__fixD142" id="Pep8Fixer.__fixD142" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__fixD142" />
+      <keyword name="Pep8Fixer.__fixD143" id="Pep8Fixer.__fixD143" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__fixD143" />
+      <keyword name="Pep8Fixer.__fixD144" id="Pep8Fixer.__fixD144" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__fixD144" />
+      <keyword name="Pep8Fixer.__fixD145" id="Pep8Fixer.__fixD145" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__fixD145" />
       <keyword name="Pep8Fixer.__fixE101" id="Pep8Fixer.__fixE101" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__fixE101" />
       <keyword name="Pep8Fixer.__fixE121" id="Pep8Fixer.__fixE121" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__fixE121" />
       <keyword name="Pep8Fixer.__fixE122" id="Pep8Fixer.__fixE122" ref="eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html#Pep8Fixer.__fixE122" />
--- a/Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html	Wed Sep 18 19:48:12 2013 +0200
+++ b/Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.Pep8Fixer.html	Wed Sep 18 19:53:54 2013 +0200
@@ -75,6 +75,27 @@
 <td><a href="#Pep8Fixer.__findLogical">__findLogical</a></td>
 <td>Private method to extract the index of all the starts and ends of lines.</td>
 </tr><tr>
+<td><a href="#Pep8Fixer.__fixD121">__fixD121</a></td>
+<td>Private method to fix a single line docstring on multiple lines (D121).</td>
+</tr><tr>
+<td><a href="#Pep8Fixer.__fixD131">__fixD131</a></td>
+<td>Private method to fix a single line docstring on multiple lines (D121).</td>
+</tr><tr>
+<td><a href="#Pep8Fixer.__fixD141">__fixD141</a></td>
+<td>Private method to fix a function/method docstring preceded by a blank line (D141).</td>
+</tr><tr>
+<td><a href="#Pep8Fixer.__fixD142">__fixD142</a></td>
+<td>Private method to fix a class docstring not preceded by a blank line (D142).</td>
+</tr><tr>
+<td><a href="#Pep8Fixer.__fixD143">__fixD143</a></td>
+<td>Private method to fix a class docstring not followed by a blank line (D143).</td>
+</tr><tr>
+<td><a href="#Pep8Fixer.__fixD144">__fixD144</a></td>
+<td>Private method to fix a docstring summary not followed by a blank line (D144).</td>
+</tr><tr>
+<td><a href="#Pep8Fixer.__fixD145">__fixD145</a></td>
+<td>Private method to fix the last paragraph of a multi-line docstring not followed by a blank line (D143).</td>
+</tr><tr>
 <td><a href="#Pep8Fixer.__fixE101">__fixE101</a></td>
 <td>Private method to fix obsolete tab usage and indentation errors (E101, E111, W191).</td>
 </tr><tr>
@@ -258,6 +279,196 @@
 tuple containing two lists of integer with start and end tuples
             of lines
 </dd>
+</dl><a NAME="Pep8Fixer.__fixD121" ID="Pep8Fixer.__fixD121"></a>
+<h4>Pep8Fixer.__fixD121</h4>
+<b>__fixD121</b>(<i>code, line, pos, apply=False</i>)
+<p>
+        Private method to fix a single line docstring on multiple lines (D121).
+</p><dl>
+<dt><i>code</i></dt>
+<dd>
+code of the issue (string)
+</dd><dt><i>line</i></dt>
+<dd>
+line number of the issue (integer)
+</dd><dt><i>pos</i></dt>
+<dd>
+position inside line (integer)
+</dd><dt><i>apply=</i></dt>
+<dd>
+flag indicating, that the fix should be applied
+            (boolean)
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+value indicating an applied/deferred fix (-1, 0, 1),
+            a message for the fix (string) and an ID for a deferred
+            fix (integer)
+</dd>
+</dl><a NAME="Pep8Fixer.__fixD131" ID="Pep8Fixer.__fixD131"></a>
+<h4>Pep8Fixer.__fixD131</h4>
+<b>__fixD131</b>(<i>code, line, pos</i>)
+<p>
+        Private method to fix a single line docstring on multiple lines (D121).
+</p><dl>
+<dt><i>code</i></dt>
+<dd>
+code of the issue (string)
+</dd><dt><i>line</i></dt>
+<dd>
+line number of the issue (integer)
+</dd><dt><i>pos</i></dt>
+<dd>
+position inside line (integer)
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+value indicating an applied/deferred fix (-1, 0, 1),
+            a message for the fix (string) and an ID for a deferred
+            fix (integer)
+</dd>
+</dl><a NAME="Pep8Fixer.__fixD141" ID="Pep8Fixer.__fixD141"></a>
+<h4>Pep8Fixer.__fixD141</h4>
+<b>__fixD141</b>(<i>code, line, pos, apply=False</i>)
+<p>
+        Private method to fix a function/method docstring preceded by a
+        blank line (D141).
+</p><dl>
+<dt><i>code</i></dt>
+<dd>
+code of the issue (string)
+</dd><dt><i>line</i></dt>
+<dd>
+line number of the issue (integer)
+</dd><dt><i>pos</i></dt>
+<dd>
+position inside line (integer)
+</dd><dt><i>apply=</i></dt>
+<dd>
+flag indicating, that the fix should be applied
+            (boolean)
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+value indicating an applied/deferred fix (-1, 0, 1),
+            a message for the fix (string) and an ID for a deferred
+            fix (integer)
+</dd>
+</dl><a NAME="Pep8Fixer.__fixD142" ID="Pep8Fixer.__fixD142"></a>
+<h4>Pep8Fixer.__fixD142</h4>
+<b>__fixD142</b>(<i>code, line, pos, apply=False</i>)
+<p>
+        Private method to fix a class docstring not preceded by a
+        blank line (D142).
+</p><dl>
+<dt><i>code</i></dt>
+<dd>
+code of the issue (string)
+</dd><dt><i>line</i></dt>
+<dd>
+line number of the issue (integer)
+</dd><dt><i>pos</i></dt>
+<dd>
+position inside line (integer)
+</dd><dt><i>apply=</i></dt>
+<dd>
+flag indicating, that the fix should be applied
+            (boolean)
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+value indicating an applied/deferred fix (-1, 0, 1),
+            a message for the fix (string) and an ID for a deferred
+            fix (integer)
+</dd>
+</dl><a NAME="Pep8Fixer.__fixD143" ID="Pep8Fixer.__fixD143"></a>
+<h4>Pep8Fixer.__fixD143</h4>
+<b>__fixD143</b>(<i>code, line, pos, apply=False</i>)
+<p>
+        Private method to fix a class docstring not followed by a
+        blank line (D143).
+</p><dl>
+<dt><i>code</i></dt>
+<dd>
+code of the issue (string)
+</dd><dt><i>line</i></dt>
+<dd>
+line number of the issue (integer)
+</dd><dt><i>pos</i></dt>
+<dd>
+position inside line (integer)
+</dd><dt><i>apply=</i></dt>
+<dd>
+flag indicating, that the fix should be applied
+            (boolean)
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+value indicating an applied/deferred fix (-1, 0, 1),
+            a message for the fix (string) and an ID for a deferred
+            fix (integer)
+</dd>
+</dl><a NAME="Pep8Fixer.__fixD144" ID="Pep8Fixer.__fixD144"></a>
+<h4>Pep8Fixer.__fixD144</h4>
+<b>__fixD144</b>(<i>code, line, pos, apply=False</i>)
+<p>
+        Private method to fix a docstring summary not followed by a
+        blank line (D144).
+</p><dl>
+<dt><i>code</i></dt>
+<dd>
+code of the issue (string)
+</dd><dt><i>line</i></dt>
+<dd>
+line number of the issue (integer)
+</dd><dt><i>pos</i></dt>
+<dd>
+position inside line (integer)
+</dd><dt><i>apply=</i></dt>
+<dd>
+flag indicating, that the fix should be applied
+            (boolean)
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+value indicating an applied/deferred fix (-1, 0, 1),
+            a message for the fix (string) and an ID for a deferred
+            fix (integer)
+</dd>
+</dl><a NAME="Pep8Fixer.__fixD145" ID="Pep8Fixer.__fixD145"></a>
+<h4>Pep8Fixer.__fixD145</h4>
+<b>__fixD145</b>(<i>code, line, pos, apply=False</i>)
+<p>
+        Private method to fix the last paragraph of a multi-line docstring
+        not followed by a blank line (D143).
+</p><dl>
+<dt><i>code</i></dt>
+<dd>
+code of the issue (string)
+</dd><dt><i>line</i></dt>
+<dd>
+line number of the issue (integer)
+</dd><dt><i>pos</i></dt>
+<dd>
+position inside line (integer)
+</dd><dt><i>apply=</i></dt>
+<dd>
+flag indicating, that the fix should be applied
+            (boolean)
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+value indicating an applied/deferred fix (-1, 0, 1),
+            a message for the fix (string) and an ID for a deferred
+            fix (integer)
+</dd>
 </dl><a NAME="Pep8Fixer.__fixE101" ID="Pep8Fixer.__fixE101"></a>
 <h4>Pep8Fixer.__fixE101</h4>
 <b>__fixE101</b>(<i>code, line, pos</i>)
--- a/Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.pep8.html	Wed Sep 18 19:48:12 2013 +0200
+++ b/Documentation/Source/eric5.Plugins.CheckerPlugins.Pep8.pep8.html	Wed Sep 18 19:53:54 2013 +0200
@@ -57,7 +57,7 @@
 <td>Parse options and run checks on Python source.</td>
 </tr><tr>
 <td><a href="#blank_lines">blank_lines</a></td>
-<td></td>
+<td>Separate top-level function and class definitions with two blank lines.</td>
 </tr><tr>
 <td><a href="#comparison_to_singleton">comparison_to_singleton</a></td>
 <td>Comparisons to singletons like None should always be done with "is" or "is not", never the equality operators.</td>
@@ -66,16 +66,16 @@
 <td>Object type comparisons should always use isinstance() instead of comparing types directly.</td>
 </tr><tr>
 <td><a href="#compound_statements">compound_statements</a></td>
-<td></td>
+<td>Compound statements (multiple statements on the same line) are generally discouraged.</td>
 </tr><tr>
 <td><a href="#continued_indentation">continued_indentation</a></td>
-<td></td>
+<td>Continuation lines should align wrapped elements either vertically using Python's implicit line joining inside parentheses, brackets and braces, or using a hanging indent.</td>
 </tr><tr>
 <td><a href="#expand_indent">expand_indent</a></td>
-<td></td>
+<td>Return the amount of indentation.</td>
 </tr><tr>
 <td><a href="#explicit_line_join">explicit_line_join</a></td>
-<td></td>
+<td>Avoid explicit line join between brackets.</td>
 </tr><tr>
 <td><a href="#extraneous_whitespace">extraneous_whitespace</a></td>
 <td>Avoid extraneous whitespace in the following situations:</td>
@@ -90,10 +90,10 @@
 <td></td>
 </tr><tr>
 <td><a href="#imports_on_separate_lines">imports_on_separate_lines</a></td>
-<td></td>
+<td>Imports should usually be on separate lines.</td>
 </tr><tr>
 <td><a href="#indentation">indentation</a></td>
-<td></td>
+<td>Use 4 spaces per indentation level.</td>
 </tr><tr>
 <td><a href="#init_checks_registry">init_checks_registry</a></td>
 <td>Register all globally visible functions where the first argument name is 'physical_line' or 'logical_line'.</td>
@@ -108,7 +108,7 @@
 <td>JCR: Each comma, semicolon or colon should be followed by whitespace.</td>
 </tr><tr>
 <td><a href="#missing_whitespace_around_operator">missing_whitespace_around_operator</a></td>
-<td></td>
+<td>- Always surround these binary operators with a single space on either side: assignment (=), augmented assignment (+=, -= etc.), comparisons (==, <, >, !=, <>, <=, >=, in, not in, is, is not), Booleans (and, or, not).</td>
 </tr><tr>
 <td><a href="#mute_string">mute_string</a></td>
 <td>Replace contents with 'xxx' to prevent syntax matching.</td>
@@ -123,7 +123,7 @@
 <td>Backticks are removed in Python 3.</td>
 </tr><tr>
 <td><a href="#python_3000_has_key">python_3000_has_key</a></td>
-<td></td>
+<td>The {}.has_key() method is removed in the Python 3.</td>
 </tr><tr>
 <td><a href="#python_3000_not_equal">python_3000_not_equal</a></td>
 <td>!= can also be written <>, but this is an obsolete usage kept for backwards compatibility only.</td>
@@ -147,22 +147,22 @@
 <td></td>
 </tr><tr>
 <td><a href="#tabs_obsolete">tabs_obsolete</a></td>
-<td></td>
+<td>For new projects, spaces-only are strongly recommended over tabs.</td>
 </tr><tr>
 <td><a href="#tabs_or_spaces">tabs_or_spaces</a></td>
-<td></td>
+<td>Never mix tabs and spaces.</td>
 </tr><tr>
 <td><a href="#trailing_blank_lines">trailing_blank_lines</a></td>
-<td></td>
+<td>JCR: Trailing blank lines are superfluous.</td>
 </tr><tr>
 <td><a href="#trailing_whitespace">trailing_whitespace</a></td>
-<td></td>
+<td>JCR: Trailing whitespace is superfluous.</td>
 </tr><tr>
 <td><a href="#whitespace_around_comma">whitespace_around_comma</a></td>
 <td>Avoid extraneous whitespace in the following situations:</td>
 </tr><tr>
 <td><a href="#whitespace_around_keywords">whitespace_around_keywords</a></td>
-<td></td>
+<td>Avoid extraneous whitespace around keywords.</td>
 </tr><tr>
 <td><a href="#whitespace_around_named_parameter_equals">whitespace_around_named_parameter_equals</a></td>
 <td>Don't use spaces around the '=' sign when used to indicate a keyword argument or a default parameter value.</td>
@@ -648,7 +648,26 @@
 <a NAME="blank_lines" ID="blank_lines"></a>
 <h2>blank_lines</h2>
 <b>blank_lines</b>(<i>logical_line, blank_lines, indent_level, line_number, previous_logical, previous_indent_level</i>)
-
+<p>
+    Separate top-level function and class definitions with two blank lines.
+</p><p>
+    Method definitions inside a class are separated by a single blank line.
+</p><p>
+    Extra blank lines may be used (sparingly) to separate groups of related
+    functions.  Blank lines may be omitted between a bunch of related
+    one-liners (e.g. a set of dummy implementations).
+</p><p>
+    Use blank lines in functions, sparingly, to indicate logical sections.
+</p><p>
+    Okay: def a():\n    pass\n\n\ndef b():\n    pass
+    Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
+</p><p>
+    E301: class Foo:\n    b = 0\n    def bar():\n        pass
+    E302: def a():\n    pass\n\ndef b(n):\n    pass
+    E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
+    E303: def a():\n\n\n\n    pass
+    E304: @decorator\n\ndef a():\n    pass
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="comparison_to_singleton" ID="comparison_to_singleton"></a>
@@ -691,25 +710,101 @@
 <a NAME="compound_statements" ID="compound_statements"></a>
 <h2>compound_statements</h2>
 <b>compound_statements</b>(<i>logical_line</i>)
-
+<p>
+    Compound statements (multiple statements on the same line) are
+    generally discouraged.
+</p><p>
+    While sometimes it's okay to put an if/for/while with a small body
+    on the same line, never do this for multi-clause statements. Also
+    avoid folding such long lines!
+</p><p>
+    Okay: if foo == 'blah':\n    do_blah_thing()
+    Okay: do_one()
+    Okay: do_two()
+    Okay: do_three()
+</p><p>
+    E701: if foo == 'blah': do_blah_thing()
+    E701: for x in lst: total += x
+    E701: while t < 10: t = delay()
+    E701: if foo == 'blah': do_blah_thing()
+    E701: else: do_non_blah_thing()
+    E701: try: something()
+    E701: finally: cleanup()
+    E701: if foo == 'blah': one(); two(); three()
+</p><p>
+    E702: do_one(); do_two(); do_three()
+    E703: do_four();  # useless semicolon
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="continued_indentation" ID="continued_indentation"></a>
 <h2>continued_indentation</h2>
 <b>continued_indentation</b>(<i>logical_line, tokens, indent_level, hang_closing, noqa, verbose</i>)
-
+<p>
+    Continuation lines should align wrapped elements either vertically using
+    Python's implicit line joining inside parentheses, brackets and braces, or
+    using a hanging indent.
+</p><p>
+    When using a hanging indent the following considerations should be applied:
+</p><p>
+    - there should be no arguments on the first line, and
+</p><p>
+    - further indentation should be used to clearly distinguish itself as a
+      continuation line.
+</p><p>
+    Okay: a = (\n)
+    E123: a = (\n    )
+</p><p>
+    Okay: a = (\n    42)
+    E121: a = (\n   42)
+    E122: a = (\n42)
+    E123: a = (\n    42\n    )
+    E124: a = (24,\n     42\n)
+    E125: if (a or\n    b):\n    pass
+    E126: a = (\n        42)
+    E127: a = (24,\n      42)
+    E128: a = (24,\n    42)
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="expand_indent" ID="expand_indent"></a>
 <h2>expand_indent</h2>
 <b>expand_indent</b>(<i>line</i>)
-
+<p>
+    Return the amount of indentation.
+    Tabs are expanded to the next multiple of 8.
+</p><p>
+    >>> expand_indent('    ')
+    4
+    >>> expand_indent('\t')
+    8
+    >>> expand_indent('    \t')
+    8
+    >>> expand_indent('       \t')
+    8
+    >>> expand_indent('        \t')
+    16
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="explicit_line_join" ID="explicit_line_join"></a>
 <h2>explicit_line_join</h2>
 <b>explicit_line_join</b>(<i>logical_line, tokens</i>)
-
+<p>
+    Avoid explicit line join between brackets.
+</p><p>
+    The preferred way of wrapping long lines is by using Python's implied line
+    continuation inside parentheses, brackets and braces.  Long lines can be
+    broken over multiple lines by wrapping expressions in parentheses.  These
+    should be used in preference to using a backslash for line continuation.
+</p><p>
+    E502: aaa = [123, \\n       123]
+    E502: aaa = ("bbb " \\n       "ccc")
+</p><p>
+    Okay: aaa = [123,\n       123]
+    Okay: aaa = ("bbb "\n       "ccc")
+    Okay: aaa = "bbb " \\n    "ccc"
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="extraneous_whitespace" ID="extraneous_whitespace"></a>
@@ -775,13 +870,39 @@
 <a NAME="imports_on_separate_lines" ID="imports_on_separate_lines"></a>
 <h2>imports_on_separate_lines</h2>
 <b>imports_on_separate_lines</b>(<i>logical_line</i>)
-
+<p>
+    Imports should usually be on separate lines.
+</p><p>
+    Okay: import os\nimport sys
+    E401: import sys, os
+</p><p>
+    Okay: from subprocess import Popen, PIPE
+    Okay: from myclas import MyClass
+    Okay: from foo.bar.yourclass import YourClass
+    Okay: import myclass
+    Okay: import foo.bar.yourclass
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="indentation" ID="indentation"></a>
 <h2>indentation</h2>
 <b>indentation</b>(<i>logical_line, previous_logical, indent_char, indent_level, previous_indent_level</i>)
-
+<p>
+    Use 4 spaces per indentation level.
+</p><p>
+    For really old code that you don't want to mess up, you can continue to
+    use 8-space tabs.
+</p><p>
+    Okay: a = 1
+    Okay: if a == 0:\n    a = 1
+    E111:   a = 1
+</p><p>
+    Okay: for item in items:\n    pass
+    E112: for item in items:\npass
+</p><p>
+    Okay: a = 1\nb = 2
+    E113: a = 1\n    b = 2
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="init_checks_registry" ID="init_checks_registry"></a>
@@ -841,7 +962,31 @@
 <a NAME="missing_whitespace_around_operator" ID="missing_whitespace_around_operator"></a>
 <h2>missing_whitespace_around_operator</h2>
 <b>missing_whitespace_around_operator</b>(<i>logical_line, tokens</i>)
-
+<p>
+    - Always surround these binary operators with a single space on
+      either side: assignment (=), augmented assignment (+=, -= etc.),
+      comparisons (==, <, >, !=, <>, <=, >=, in, not in, is, is not),
+      Booleans (and, or, not).
+</p><p>
+    - Use spaces around arithmetic operators.
+</p><p>
+    Okay: i = i + 1
+    Okay: submitted += 1
+    Okay: x = x * 2 - 1
+    Okay: hypot2 = x * x + y * y
+    Okay: c = (a + b) * (a - b)
+    Okay: foo(bar, key='word', *args, **kwargs)
+    Okay: alpha[:-i]
+</p><p>
+    E225: i=i+1
+    E225: submitted +=1
+    E225: x = x /2 - 1
+    E225: z = x **y
+    E226: c = (a+b) * (a-b)
+    E226: hypot2 = x*x + y*y
+    E227: c = a|b
+    E228: msg = fmt%(errno, errmsg)
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="mute_string" ID="mute_string"></a>
@@ -890,7 +1035,13 @@
 <a NAME="python_3000_has_key" ID="python_3000_has_key"></a>
 <h2>python_3000_has_key</h2>
 <b>python_3000_has_key</b>(<i>logical_line</i>)
-
+<p>
+    The {}.has_key() method is removed in the Python 3.
+    Use the 'in' operation instead.
+</p><p>
+    Okay: if "alph" in d:\n    print d["alph"]
+    W601: assert d.has_key('alph')
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="python_3000_not_equal" ID="python_3000_not_equal"></a>
@@ -960,25 +1111,65 @@
 <a NAME="tabs_obsolete" ID="tabs_obsolete"></a>
 <h2>tabs_obsolete</h2>
 <b>tabs_obsolete</b>(<i>physical_line</i>)
-
+<p>
+    For new projects, spaces-only are strongly recommended over tabs.  Most
+    editors have features that make this easy to do.
+</p><p>
+    Okay: if True:\n    return
+    W191: if True:\n\treturn
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="tabs_or_spaces" ID="tabs_or_spaces"></a>
 <h2>tabs_or_spaces</h2>
 <b>tabs_or_spaces</b>(<i>physical_line, indent_char</i>)
-
+<p>
+    Never mix tabs and spaces.
+</p><p>
+    The most popular way of indenting Python is with spaces only.  The
+    second-most popular way is with tabs only.  Code indented with a mixture
+    of tabs and spaces should be converted to using spaces exclusively.  When
+    invoking the Python command line interpreter with the -t option, it issues
+    warnings about code that illegally mixes tabs and spaces.  When using -tt
+    these warnings become errors.  These options are highly recommended!
+</p><p>
+    Okay: if a == 0:\n        a = 1\n        b = 1
+    E101: if a == 0:\n        a = 1\n\tb = 1
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="trailing_blank_lines" ID="trailing_blank_lines"></a>
 <h2>trailing_blank_lines</h2>
 <b>trailing_blank_lines</b>(<i>physical_line, lines, line_number</i>)
-
+<p>
+    JCR: Trailing blank lines are superfluous.
+</p><p>
+    Okay: spam(1)
+    W391: spam(1)\n
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="trailing_whitespace" ID="trailing_whitespace"></a>
 <h2>trailing_whitespace</h2>
 <b>trailing_whitespace</b>(<i>physical_line</i>)
-
+<p>
+    JCR: Trailing whitespace is superfluous.
+    FBM: Except when it occurs as part of a blank line (i.e. the line is
+         nothing but whitespace). According to Python docs[1] a line with only
+         whitespace is considered a blank line, and is to be ignored. However,
+         matching a blank line to its indentation level avoids mistakenly
+         terminating a multi-line statement (e.g. class declaration) when
+         pasting code into the standard Python interpreter.
+</p><p>
+         [1] http://docs.python.org/reference/lexical_analysis.html#blank-lines
+</p><p>
+    The warning returned varies on whether the line itself is blank, for easier
+    filtering for those who want to indent their blank lines.
+</p><p>
+    Okay: spam(1)\n#
+    W291: spam(1) \n#
+    W293: class Foo(object):\n    \n    bang = 12
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="whitespace_around_comma" ID="whitespace_around_comma"></a>
@@ -1002,7 +1193,15 @@
 <a NAME="whitespace_around_keywords" ID="whitespace_around_keywords"></a>
 <h2>whitespace_around_keywords</h2>
 <b>whitespace_around_keywords</b>(<i>logical_line</i>)
-
+<p>
+    Avoid extraneous whitespace around keywords.
+</p><p>
+    Okay: True and False
+    E271: True and  False
+    E272: True  and False
+    E273: True and\tFalse
+    E274: True\tand False
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="whitespace_around_named_parameter_equals" ID="whitespace_around_named_parameter_equals"></a>
--- a/Documentation/Source/eric5.UtilitiesPython2.pep8.html	Wed Sep 18 19:48:12 2013 +0200
+++ b/Documentation/Source/eric5.UtilitiesPython2.pep8.html	Wed Sep 18 19:53:54 2013 +0200
@@ -57,7 +57,7 @@
 <td>Parse options and run checks on Python source.</td>
 </tr><tr>
 <td><a href="#blank_lines">blank_lines</a></td>
-<td></td>
+<td>Separate top-level function and class definitions with two blank lines.</td>
 </tr><tr>
 <td><a href="#comparison_to_singleton">comparison_to_singleton</a></td>
 <td>Comparisons to singletons like None should always be done with "is" or "is not", never the equality operators.</td>
@@ -66,16 +66,16 @@
 <td>Object type comparisons should always use isinstance() instead of comparing types directly.</td>
 </tr><tr>
 <td><a href="#compound_statements">compound_statements</a></td>
-<td></td>
+<td>Compound statements (multiple statements on the same line) are generally discouraged.</td>
 </tr><tr>
 <td><a href="#continued_indentation">continued_indentation</a></td>
-<td></td>
+<td>Continuation lines should align wrapped elements either vertically using Python's implicit line joining inside parentheses, brackets and braces, or using a hanging indent.</td>
 </tr><tr>
 <td><a href="#expand_indent">expand_indent</a></td>
-<td></td>
+<td>Return the amount of indentation.</td>
 </tr><tr>
 <td><a href="#explicit_line_join">explicit_line_join</a></td>
-<td></td>
+<td>Avoid explicit line join between brackets.</td>
 </tr><tr>
 <td><a href="#extraneous_whitespace">extraneous_whitespace</a></td>
 <td>Avoid extraneous whitespace in the following situations:</td>
@@ -87,10 +87,10 @@
 <td></td>
 </tr><tr>
 <td><a href="#imports_on_separate_lines">imports_on_separate_lines</a></td>
-<td></td>
+<td>Imports should usually be on separate lines.</td>
 </tr><tr>
 <td><a href="#indentation">indentation</a></td>
-<td></td>
+<td>Use 4 spaces per indentation level.</td>
 </tr><tr>
 <td><a href="#init_checks_registry">init_checks_registry</a></td>
 <td>Register all globally visible functions where the first argument name is 'physical_line' or 'logical_line'.</td>
@@ -105,7 +105,7 @@
 <td>JCR: Each comma, semicolon or colon should be followed by whitespace.</td>
 </tr><tr>
 <td><a href="#missing_whitespace_around_operator">missing_whitespace_around_operator</a></td>
-<td></td>
+<td>- Always surround these binary operators with a single space on either side: assignment (=), augmented assignment (+=, -= etc.), comparisons (==, <, >, !=, <>, <=, >=, in, not in, is, is not), Booleans (and, or, not).</td>
 </tr><tr>
 <td><a href="#mute_string">mute_string</a></td>
 <td>Replace contents with 'xxx' to prevent syntax matching.</td>
@@ -120,7 +120,7 @@
 <td>Backticks are removed in Python 3.</td>
 </tr><tr>
 <td><a href="#python_3000_has_key">python_3000_has_key</a></td>
-<td></td>
+<td>The {}.has_key() method is removed in the Python 3.</td>
 </tr><tr>
 <td><a href="#python_3000_not_equal">python_3000_not_equal</a></td>
 <td>!= can also be written <>, but this is an obsolete usage kept for backwards compatibility only.</td>
@@ -144,22 +144,22 @@
 <td></td>
 </tr><tr>
 <td><a href="#tabs_obsolete">tabs_obsolete</a></td>
-<td></td>
+<td>For new projects, spaces-only are strongly recommended over tabs.</td>
 </tr><tr>
 <td><a href="#tabs_or_spaces">tabs_or_spaces</a></td>
-<td></td>
+<td>Never mix tabs and spaces.</td>
 </tr><tr>
 <td><a href="#trailing_blank_lines">trailing_blank_lines</a></td>
-<td></td>
+<td>JCR: Trailing blank lines are superfluous.</td>
 </tr><tr>
 <td><a href="#trailing_whitespace">trailing_whitespace</a></td>
-<td></td>
+<td>JCR: Trailing whitespace is superfluous.</td>
 </tr><tr>
 <td><a href="#whitespace_around_comma">whitespace_around_comma</a></td>
 <td>Avoid extraneous whitespace in the following situations:</td>
 </tr><tr>
 <td><a href="#whitespace_around_keywords">whitespace_around_keywords</a></td>
-<td></td>
+<td>Avoid extraneous whitespace around keywords.</td>
 </tr><tr>
 <td><a href="#whitespace_around_named_parameter_equals">whitespace_around_named_parameter_equals</a></td>
 <td>Don't use spaces around the '=' sign when used to indicate a keyword argument or a default parameter value.</td>
@@ -645,7 +645,26 @@
 <a NAME="blank_lines" ID="blank_lines"></a>
 <h2>blank_lines</h2>
 <b>blank_lines</b>(<i>logical_line, blank_lines, indent_level, line_number, previous_logical, previous_indent_level</i>)
-
+<p>
+    Separate top-level function and class definitions with two blank lines.
+</p><p>
+    Method definitions inside a class are separated by a single blank line.
+</p><p>
+    Extra blank lines may be used (sparingly) to separate groups of related
+    functions.  Blank lines may be omitted between a bunch of related
+    one-liners (e.g. a set of dummy implementations).
+</p><p>
+    Use blank lines in functions, sparingly, to indicate logical sections.
+</p><p>
+    Okay: def a():\n    pass\n\n\ndef b():\n    pass
+    Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
+</p><p>
+    E301: class Foo:\n    b = 0\n    def bar():\n        pass
+    E302: def a():\n    pass\n\ndef b(n):\n    pass
+    E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
+    E303: def a():\n\n\n\n    pass
+    E304: @decorator\n\ndef a():\n    pass
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="comparison_to_singleton" ID="comparison_to_singleton"></a>
@@ -688,25 +707,101 @@
 <a NAME="compound_statements" ID="compound_statements"></a>
 <h2>compound_statements</h2>
 <b>compound_statements</b>(<i>logical_line</i>)
-
+<p>
+    Compound statements (multiple statements on the same line) are
+    generally discouraged.
+</p><p>
+    While sometimes it's okay to put an if/for/while with a small body
+    on the same line, never do this for multi-clause statements. Also
+    avoid folding such long lines!
+</p><p>
+    Okay: if foo == 'blah':\n    do_blah_thing()
+    Okay: do_one()
+    Okay: do_two()
+    Okay: do_three()
+</p><p>
+    E701: if foo == 'blah': do_blah_thing()
+    E701: for x in lst: total += x
+    E701: while t < 10: t = delay()
+    E701: if foo == 'blah': do_blah_thing()
+    E701: else: do_non_blah_thing()
+    E701: try: something()
+    E701: finally: cleanup()
+    E701: if foo == 'blah': one(); two(); three()
+</p><p>
+    E702: do_one(); do_two(); do_three()
+    E703: do_four();  # useless semicolon
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="continued_indentation" ID="continued_indentation"></a>
 <h2>continued_indentation</h2>
 <b>continued_indentation</b>(<i>logical_line, tokens, indent_level, hang_closing, noqa, verbose</i>)
-
+<p>
+    Continuation lines should align wrapped elements either vertically using
+    Python's implicit line joining inside parentheses, brackets and braces, or
+    using a hanging indent.
+</p><p>
+    When using a hanging indent the following considerations should be applied:
+</p><p>
+    - there should be no arguments on the first line, and
+</p><p>
+    - further indentation should be used to clearly distinguish itself as a
+      continuation line.
+</p><p>
+    Okay: a = (\n)
+    E123: a = (\n    )
+</p><p>
+    Okay: a = (\n    42)
+    E121: a = (\n   42)
+    E122: a = (\n42)
+    E123: a = (\n    42\n    )
+    E124: a = (24,\n     42\n)
+    E125: if (a or\n    b):\n    pass
+    E126: a = (\n        42)
+    E127: a = (24,\n      42)
+    E128: a = (24,\n    42)
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="expand_indent" ID="expand_indent"></a>
 <h2>expand_indent</h2>
 <b>expand_indent</b>(<i>line</i>)
-
+<p>
+    Return the amount of indentation.
+    Tabs are expanded to the next multiple of 8.
+</p><p>
+    >>> expand_indent('    ')
+    4
+    >>> expand_indent('\t')
+    8
+    >>> expand_indent('    \t')
+    8
+    >>> expand_indent('       \t')
+    8
+    >>> expand_indent('        \t')
+    16
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="explicit_line_join" ID="explicit_line_join"></a>
 <h2>explicit_line_join</h2>
 <b>explicit_line_join</b>(<i>logical_line, tokens</i>)
-
+<p>
+    Avoid explicit line join between brackets.
+</p><p>
+    The preferred way of wrapping long lines is by using Python's implied line
+    continuation inside parentheses, brackets and braces.  Long lines can be
+    broken over multiple lines by wrapping expressions in parentheses.  These
+    should be used in preference to using a backslash for line continuation.
+</p><p>
+    E502: aaa = [123, \\n       123]
+    E502: aaa = ("bbb " \\n       "ccc")
+</p><p>
+    Okay: aaa = [123,\n       123]
+    Okay: aaa = ("bbb "\n       "ccc")
+    Okay: aaa = "bbb " \\n    "ccc"
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="extraneous_whitespace" ID="extraneous_whitespace"></a>
@@ -751,13 +846,39 @@
 <a NAME="imports_on_separate_lines" ID="imports_on_separate_lines"></a>
 <h2>imports_on_separate_lines</h2>
 <b>imports_on_separate_lines</b>(<i>logical_line</i>)
-
+<p>
+    Imports should usually be on separate lines.
+</p><p>
+    Okay: import os\nimport sys
+    E401: import sys, os
+</p><p>
+    Okay: from subprocess import Popen, PIPE
+    Okay: from myclas import MyClass
+    Okay: from foo.bar.yourclass import YourClass
+    Okay: import myclass
+    Okay: import foo.bar.yourclass
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="indentation" ID="indentation"></a>
 <h2>indentation</h2>
 <b>indentation</b>(<i>logical_line, previous_logical, indent_char, indent_level, previous_indent_level</i>)
-
+<p>
+    Use 4 spaces per indentation level.
+</p><p>
+    For really old code that you don't want to mess up, you can continue to
+    use 8-space tabs.
+</p><p>
+    Okay: a = 1
+    Okay: if a == 0:\n    a = 1
+    E111:   a = 1
+</p><p>
+    Okay: for item in items:\n    pass
+    E112: for item in items:\npass
+</p><p>
+    Okay: a = 1\nb = 2
+    E113: a = 1\n    b = 2
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="init_checks_registry" ID="init_checks_registry"></a>
@@ -817,7 +938,31 @@
 <a NAME="missing_whitespace_around_operator" ID="missing_whitespace_around_operator"></a>
 <h2>missing_whitespace_around_operator</h2>
 <b>missing_whitespace_around_operator</b>(<i>logical_line, tokens</i>)
-
+<p>
+    - Always surround these binary operators with a single space on
+      either side: assignment (=), augmented assignment (+=, -= etc.),
+      comparisons (==, <, >, !=, <>, <=, >=, in, not in, is, is not),
+      Booleans (and, or, not).
+</p><p>
+    - Use spaces around arithmetic operators.
+</p><p>
+    Okay: i = i + 1
+    Okay: submitted += 1
+    Okay: x = x * 2 - 1
+    Okay: hypot2 = x * x + y * y
+    Okay: c = (a + b) * (a - b)
+    Okay: foo(bar, key='word', *args, **kwargs)
+    Okay: alpha[:-i]
+</p><p>
+    E225: i=i+1
+    E225: submitted +=1
+    E225: x = x /2 - 1
+    E225: z = x **y
+    E226: c = (a+b) * (a-b)
+    E226: hypot2 = x*x + y*y
+    E227: c = a|b
+    E228: msg = fmt%(errno, errmsg)
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="mute_string" ID="mute_string"></a>
@@ -866,7 +1011,13 @@
 <a NAME="python_3000_has_key" ID="python_3000_has_key"></a>
 <h2>python_3000_has_key</h2>
 <b>python_3000_has_key</b>(<i>logical_line</i>)
-
+<p>
+    The {}.has_key() method is removed in the Python 3.
+    Use the 'in' operation instead.
+</p><p>
+    Okay: if "alph" in d:\n    print d["alph"]
+    W601: assert d.has_key('alph')
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="python_3000_not_equal" ID="python_3000_not_equal"></a>
@@ -936,25 +1087,65 @@
 <a NAME="tabs_obsolete" ID="tabs_obsolete"></a>
 <h2>tabs_obsolete</h2>
 <b>tabs_obsolete</b>(<i>physical_line</i>)
-
+<p>
+    For new projects, spaces-only are strongly recommended over tabs.  Most
+    editors have features that make this easy to do.
+</p><p>
+    Okay: if True:\n    return
+    W191: if True:\n\treturn
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="tabs_or_spaces" ID="tabs_or_spaces"></a>
 <h2>tabs_or_spaces</h2>
 <b>tabs_or_spaces</b>(<i>physical_line, indent_char</i>)
-
+<p>
+    Never mix tabs and spaces.
+</p><p>
+    The most popular way of indenting Python is with spaces only.  The
+    second-most popular way is with tabs only.  Code indented with a mixture
+    of tabs and spaces should be converted to using spaces exclusively.  When
+    invoking the Python command line interpreter with the -t option, it issues
+    warnings about code that illegally mixes tabs and spaces.  When using -tt
+    these warnings become errors.  These options are highly recommended!
+</p><p>
+    Okay: if a == 0:\n        a = 1\n        b = 1
+    E101: if a == 0:\n        a = 1\n\tb = 1
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="trailing_blank_lines" ID="trailing_blank_lines"></a>
 <h2>trailing_blank_lines</h2>
 <b>trailing_blank_lines</b>(<i>physical_line, lines, line_number</i>)
-
+<p>
+    JCR: Trailing blank lines are superfluous.
+</p><p>
+    Okay: spam(1)
+    W391: spam(1)\n
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="trailing_whitespace" ID="trailing_whitespace"></a>
 <h2>trailing_whitespace</h2>
 <b>trailing_whitespace</b>(<i>physical_line</i>)
-
+<p>
+    JCR: Trailing whitespace is superfluous.
+    FBM: Except when it occurs as part of a blank line (i.e. the line is
+         nothing but whitespace). According to Python docs[1] a line with only
+         whitespace is considered a blank line, and is to be ignored. However,
+         matching a blank line to its indentation level avoids mistakenly
+         terminating a multi-line statement (e.g. class declaration) when
+         pasting code into the standard Python interpreter.
+</p><p>
+         [1] http://docs.python.org/reference/lexical_analysis.html#blank-lines
+</p><p>
+    The warning returned varies on whether the line itself is blank, for easier
+    filtering for those who want to indent their blank lines.
+</p><p>
+    Okay: spam(1)\n#
+    W291: spam(1) \n#
+    W293: class Foo(object):\n    \n    bang = 12
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="whitespace_around_comma" ID="whitespace_around_comma"></a>
@@ -978,7 +1169,15 @@
 <a NAME="whitespace_around_keywords" ID="whitespace_around_keywords"></a>
 <h2>whitespace_around_keywords</h2>
 <b>whitespace_around_keywords</b>(<i>logical_line</i>)
-
+<p>
+    Avoid extraneous whitespace around keywords.
+</p><p>
+    Okay: True and False
+    E271: True and  False
+    E272: True  and False
+    E273: True and\tFalse
+    E274: True\tand False
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
 <a NAME="whitespace_around_named_parameter_equals" ID="whitespace_around_named_parameter_equals"></a>
--- a/Plugins/CheckerPlugins/Pep8/Pep257Checker.py	Wed Sep 18 19:48:12 2013 +0200
+++ b/Plugins/CheckerPlugins/Pep8/Pep257Checker.py	Wed Sep 18 19:53:54 2013 +0200
@@ -349,7 +349,7 @@
         
         if len(lines) == 1 or len(line) > 0:
             return line, 0
-        return lines[1].strip(), 1
+        return lines[1].strip().replace('"""', "").replace("'''", ""), 1
     
     ##################################################################
     ## Parsing functionality below
@@ -663,6 +663,9 @@
                              nonEmptyLines[0].strip() + '"""')
                 if context.contextType() != "module":
                     modLen += 4
+                if not nonEmptyLines[0].strip().endswith("."):
+                    # account for a trailing dot
+                    modLen += 1
                 if modLen <= self.__maxLineLength:
                     self.__error(docstringContext.start(), 0, "D121")
     
@@ -799,7 +802,6 @@
             not contextLines[cti].strip().startswith(
                 ('"""', 'r"""', 'u"""', "'''", "r'''", "u'''")):
             cti += 1
-        
         if cti == len(contextLines):
             return
         
@@ -813,6 +815,8 @@
                 not contextLines[cti].strip().endswith(('"""', "'''")):
             cti += 1
         end = cti
+        if cti == len(contextLines):
+            return
         
         if contextLines[start - 1].strip():
             self.__error(docstringContext.start(), 0, "D142")
@@ -836,8 +840,9 @@
             return
         
         summary, lineNumber = self.__getSummaryLine(docstringContext)
-        if docstrings[lineNumber + 1].strip():
-            self.__error(docstringContext.start() + lineNumber, 0, "D144")
+        if len(docstrings) > 2:
+            if docstrings[lineNumber + 1].strip():
+                self.__error(docstringContext.start() + lineNumber, 0, "D144")
     
     def __checkBlankAfterLastParagraph(self, docstringContext, context):
         """
@@ -851,7 +856,7 @@
             return
         
         docstrings = docstringContext.source()
-        if len(docstrings) in [1, 3]:
+        if len(docstrings) <= 3:
             # correct/invalid one-liner
             return
         
--- a/Plugins/CheckerPlugins/Pep8/Pep8Fixer.py	Wed Sep 18 19:48:12 2013 +0200
+++ b/Plugins/CheckerPlugins/Pep8/Pep8Fixer.py	Wed Sep 18 19:53:54 2013 +0200
@@ -21,8 +21,10 @@
 import Utilities
 
 # TODO: add fixers for some docstring issues
+# D111, D112, D113
 
-Pep8FixableIssues = ["E101", "E111", "E121", "E122", "E123", "E124",
+Pep8FixableIssues = ["D121", "D131", "D141", "D142", "D143", "D144", "D145", 
+                     "E101", "E111", "E121", "E122", "E123", "E124",
                      "E125", "E126", "E127", "E128", "E133", "E201",
                      "E202", "E203", "E211", "E221", "E222", "E223",
                      "E224", "E225", "E226", "E227", "E228", "E231",
@@ -78,6 +80,13 @@
                 "fixed_" + os.path.basename(self.__filename))
         
         self.__fixes = {
+            "D121": self.__fixD121,
+            "D131": self.__fixD131,
+            "D141": self.__fixD141,
+            "D142": self.__fixD142,
+            "D143": self.__fixD143,
+            "D144": self.__fixD144,
+            "D145": self.__fixD145,
             "E101": self.__fixE101,
             "E111": self.__fixE101,
             "E121": self.__fixE121,
@@ -1333,6 +1342,211 @@
         """
         self.__source[line - 1] = self.__source[line - 1].replace("<>", "!=")
         return (1, self.trUtf8("'<>' replaced by '!='."), 0)
+    
+    def __fixD121(self, code, line, pos, apply=False):
+        """
+        Private method to fix a single line docstring on multiple lines (D121).
+        
+        @param code code of the issue (string)
+        @param line line number of the issue (integer)
+        @param pos position inside line (integer)
+        @keyparam apply flag indicating, that the fix should be applied
+            (boolean)
+        @return value indicating an applied/deferred fix (-1, 0, 1),
+            a message for the fix (string) and an ID for a deferred
+            fix (integer)
+        """
+        if apply:
+            line = line - 1
+            if not self.__source[line].lstrip().startswith(
+                    ('"""', 'r"""', 'u"""')):
+                # only correctly formatted docstrings will be fixed
+                return (0, "", 0)
+            
+            docstring = self.__source[line].rstrip() + \
+                self.__source[line + 1].strip()
+            if docstring.endswith('"""'):
+                docstring += self.__getEol()
+            else:
+                docstring += self.__source[line + 2].lstrip()
+                self.__source[line + 2] = ""
+            
+            self.__source[line] = docstring
+            self.__source[line + 1] = ""
+            return (
+                1,
+                self.trUtf8("Single line docstring put on one line."),
+                0)
+        else:
+            id = self.__getID()
+            self.__stack.append((id, code, line, pos))
+            return (-1, "", id)
+    
+    def __fixD131(self, code, line, pos):
+        """
+        Private method to fix a single line docstring on multiple lines (D121).
+        
+        @param code code of the issue (string)
+        @param line line number of the issue (integer)
+        @param pos position inside line (integer)
+        @return value indicating an applied/deferred fix (-1, 0, 1),
+            a message for the fix (string) and an ID for a deferred
+            fix (integer)
+        """
+        line = line - 1
+        newText = ""
+        if self.__source[line].rstrip().endswith(('"""', "'''")) and \
+           self.__source[line].lstrip().startswith( ('"""', 'r"""', 'u"""')):
+            # it is a one-liner
+            newText = self.__source[line].rstrip()[:-3] + "." + \
+                self.__source[line].rstrip()[-3:] + self.__getEol()
+        else:
+            if line < len(self.__source) - 1 and \
+                   (not self.__source[line + 1].strip() or
+                    self.__source[line + 1].strip() in ('"""', "'''")):
+                newText = self.__source[line].rstrip() + "." + self.__getEol()
+        
+        if newText:
+            self.__source[line] = newText
+            return (1, self.trUtf8("Period added to summary line."), 0)
+        else:
+            return (0, "", 0)
+    
+    def __fixD141(self, code, line, pos, apply=False):
+        """
+        Private method to fix a function/method docstring preceded by a
+        blank line (D141).
+        
+        @param code code of the issue (string)
+        @param line line number of the issue (integer)
+        @param pos position inside line (integer)
+        @keyparam apply flag indicating, that the fix should be applied
+            (boolean)
+        @return value indicating an applied/deferred fix (-1, 0, 1),
+            a message for the fix (string) and an ID for a deferred
+            fix (integer)
+        """
+        if apply:
+            line = line - 1
+            self.__source[line - 1] = ""
+            return (
+                1,
+                self.trUtf8(
+                    "Blank line before function/method docstring removed."),
+                0)
+        else:
+            id = self.__getID()
+            self.__stack.append((id, code, line, pos))
+            return (-1, "", id)
+    
+    def __fixD142(self, code, line, pos, apply=False):
+        """
+        Private method to fix a class docstring not preceded by a
+        blank line (D142).
+        
+        @param code code of the issue (string)
+        @param line line number of the issue (integer)
+        @param pos position inside line (integer)
+        @keyparam apply flag indicating, that the fix should be applied
+            (boolean)
+        @return value indicating an applied/deferred fix (-1, 0, 1),
+            a message for the fix (string) and an ID for a deferred
+            fix (integer)
+        """
+        if apply:
+            line = line - 1
+            self.__source[line] = self.__getEol() + self.__source[line]
+            return (
+                1,
+                self.trUtf8("Blank line inserted before class docstring."),
+                0)
+        else:
+            id = self.__getID()
+            self.__stack.append((id, code, line, pos))
+            return (-1, "", id)
+    
+    def __fixD143(self, code, line, pos, apply=False):
+        """
+        Private method to fix a class docstring not followed by a
+        blank line (D143).
+        
+        @param code code of the issue (string)
+        @param line line number of the issue (integer)
+        @param pos position inside line (integer)
+        @keyparam apply flag indicating, that the fix should be applied
+            (boolean)
+        @return value indicating an applied/deferred fix (-1, 0, 1),
+            a message for the fix (string) and an ID for a deferred
+            fix (integer)
+        """
+        if apply:
+            line = line - 1
+            self.__source[line] += self.__getEol()
+            return (
+                1,
+                self.trUtf8("Blank line inserted after class docstring."),
+                0)
+        else:
+            id = self.__getID()
+            self.__stack.append((id, code, line, pos))
+            return (-1, "", id)
+    
+    def __fixD144(self, code, line, pos, apply=False):
+        """
+        Private method to fix a docstring summary not followed by a
+        blank line (D144).
+        
+        @param code code of the issue (string)
+        @param line line number of the issue (integer)
+        @param pos position inside line (integer)
+        @keyparam apply flag indicating, that the fix should be applied
+            (boolean)
+        @return value indicating an applied/deferred fix (-1, 0, 1),
+            a message for the fix (string) and an ID for a deferred
+            fix (integer)
+        """
+        if apply:
+            line = line - 1
+            if not self.__source[line].rstrip().endswith("."):
+                # only correct summary lines can be fixed here
+                return (0, "", 0)
+            
+            self.__source[line] += self.__getEol()
+            return (
+                1,
+                self.trUtf8("Blank line inserted after docstring summary."),
+                0)
+        else:
+            id = self.__getID()
+            self.__stack.append((id, code, line, pos))
+            return (-1, "", id)
+    
+    def __fixD145(self, code, line, pos, apply=False):
+        """
+        Private method to fix the last paragraph of a multi-line docstring
+        not followed by a blank line (D143).
+        
+        @param code code of the issue (string)
+        @param line line number of the issue (integer)
+        @param pos position inside line (integer)
+        @keyparam apply flag indicating, that the fix should be applied
+            (boolean)
+        @return value indicating an applied/deferred fix (-1, 0, 1),
+            a message for the fix (string) and an ID for a deferred
+            fix (integer)
+        """
+        if apply:
+            line = line - 1
+            self.__source[line] = self.__getEol() + self.__source[line]
+            return (
+                1,
+                self.trUtf8("Blank line inserted after last paragraph"
+                            " of docstring."),
+                0)
+        else:
+            id = self.__getID()
+            self.__stack.append((id, code, line, pos))
+            return (-1, "", id)
 
 
 class Pep8Reindenter(object):

eric ide

mercurial