109 "D130", "D131", "D132", "D133", "D134", |
109 "D130", "D131", "D132", "D133", "D134", |
110 "D141", "D142", "D143", "D144", "D145", |
110 "D141", "D142", "D143", "D144", "D145", |
111 |
111 |
112 "D203", "D205", |
112 "D203", "D205", |
113 "D221", "D222", |
113 "D221", "D222", |
114 "D231", "D234", "D235", "D236", "D237", "D238", "D239", |
114 "D231", "D232", "D234", "D235", "D236", "D237", "D238", "D239", |
115 "D242", "D243", "D244", "D245", "D246", "D247", |
115 "D242", "D243", "D244", "D245", "D246", "D247", |
116 "D250", "D251", |
116 "D250", "D251", |
117 |
117 |
118 "D901", |
118 "D901", |
119 ] |
119 ] |
206 (self.__checkClassDocstring, ("D104", "D205")), |
206 (self.__checkClassDocstring, ("D104", "D205")), |
207 (self.__checkEricNoBlankBeforeAndAfterClassOrFunction, |
207 (self.__checkEricNoBlankBeforeAndAfterClassOrFunction, |
208 ("D242", "D243")), |
208 ("D242", "D243")), |
209 ], |
209 ], |
210 "methodDocstring": [ |
210 "methodDocstring": [ |
|
211 (self.__checkEricSummary, ("D232")), |
211 ], |
212 ], |
212 "defDocstring": [ |
213 "defDocstring": [ |
213 (self.__checkFunctionDocstring, ("D102", "D203")), |
214 (self.__checkFunctionDocstring, ("D102", "D203")), |
214 (self.__checkImperativeMood, ("D132",)), |
215 (self.__checkImperativeMood, ("D132",)), |
215 (self.__checkNoSignature, ("D133",)), |
216 (self.__checkNoSignature, ("D133",)), |
1209 # correct/invalid one-liner |
1210 # correct/invalid one-liner |
1210 return |
1211 return |
1211 |
1212 |
1212 if not docstrings[-2].strip(): |
1213 if not docstrings[-2].strip(): |
1213 self.__error(docstringContext.end(), 0, "D247") |
1214 self.__error(docstringContext.end(), 0, "D247") |
|
1215 |
|
1216 def __checkEricSummary(self, docstringContext, context): |
|
1217 """ |
|
1218 Private method to check, that method docstring summaries start with |
|
1219 specific words. |
|
1220 |
|
1221 @param docstringContext docstring context (DocStyleContext) |
|
1222 @param context context of the docstring (DocStyleContext) |
|
1223 """ |
|
1224 if docstringContext is None: |
|
1225 return |
|
1226 |
|
1227 summary, lineNumber = self.__getSummaryLine(docstringContext) |
|
1228 if summary: |
|
1229 # check, if the first word is 'Constructor', 'Public', |
|
1230 # 'Protected' or 'Private' |
|
1231 functionName = context.source()[0].lstrip().split()[1]\ |
|
1232 .split("(")[0] |
|
1233 firstWord = summary.strip().split(None, 1)[0].lower() |
|
1234 if functionName == '__init__': |
|
1235 if firstWord != 'constructor': |
|
1236 self.__error(docstringContext.start() + lineNumber, 0, |
|
1237 "D232", 'constructor') |
|
1238 elif functionName.startswith('__'): |
|
1239 if firstWord != 'private': |
|
1240 self.__error(docstringContext.start() + lineNumber, 0, |
|
1241 "D232", 'private') |
|
1242 elif functionName.startswith('_'): |
|
1243 if firstWord != 'protected': |
|
1244 self.__error(docstringContext.start() + lineNumber, 0, |
|
1245 "D232", 'protected') |
|
1246 else: |
|
1247 if firstWord != 'public': |
|
1248 self.__error(docstringContext.start() + lineNumber, 0, |
|
1249 "D232", 'public') |