Plugins/CheckerPlugins/CodeStyleChecker/DocStyleChecker.py

changeset 5813
82349b9ceb4d
parent 5812
ffc31e1cff4e
child 5815
223fa32b3a32
diff -r ffc31e1cff4e -r 82349b9ceb4d Plugins/CheckerPlugins/CodeStyleChecker/DocStyleChecker.py
--- a/Plugins/CheckerPlugins/CodeStyleChecker/DocStyleChecker.py	Wed Jul 19 19:48:38 2017 +0200
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/DocStyleChecker.py	Wed Jul 19 20:16:25 2017 +0200
@@ -1383,6 +1383,30 @@
                 if firstWord != 'special':
                     self.__error(docstringContext.start() + lineNumber, 0,
                                  "D232", 'special')
+            elif context.special() == "staticmethod":
+                if firstWord != 'static':
+                    self.__error(docstringContext.start() + lineNumber, 0,
+                                 "D232", 'static')
+            elif arguments.startswith(('cls,', 'cls)')) or \
+                    context.special() == "classmethod":
+                secondWord = summary.strip().split(None, 2)[1].lower()
+                if firstWord != 'class' and secondWord != 'class':
+                    self.__error(docstringContext.start() + lineNumber, 0,
+                                 "D232", 'class')
+                elif secondWord == 'class':
+                    if functionName.startswith(('__', 'on_')):
+                        if firstWord != 'private':
+                            self.__error(docstringContext.start() + lineNumber,
+                                         0, "D232", 'private class')
+                    elif functionName.startswith('_') or \
+                            functionName.endswith('Event'):
+                        if firstWord != 'protected':
+                            self.__error(docstringContext.start() + lineNumber,
+                                         0, "D232", 'protected class')
+                    else:
+                        if firstWord != 'public':
+                            self.__error(docstringContext.start() + lineNumber,
+                                         0, "D232", 'public class')
             elif functionName.startswith(('__', 'on_')):
                 if firstWord != 'private':
                     self.__error(docstringContext.start() + lineNumber, 0,
@@ -1392,15 +1416,6 @@
                 if firstWord != 'protected':
                     self.__error(docstringContext.start() + lineNumber, 0,
                                  "D232", 'protected')
-            elif arguments.startswith(('cls,', 'cls)')) or \
-                    context.special() == "classmethod":
-                if firstWord != 'class':
-                    self.__error(docstringContext.start() + lineNumber, 0,
-                                 "D232", 'class')
-            elif context.special() == "staticmethod":
-                if firstWord != 'static':
-                    self.__error(docstringContext.start() + lineNumber, 0,
-                                 "D232", 'static')
             else:
                 if firstWord != 'public':
                     self.__error(docstringContext.start() + lineNumber, 0,

eric ide

mercurial