Plugins/CheckerPlugins/CodeStyleChecker/DocStyleChecker.py

changeset 3590
5280e37405b8
parent 3589
48aded8560dc
child 3622
7a9a8fb4b8c6
equal deleted inserted replaced
3589:48aded8560dc 3590:5280e37405b8
1226 1226
1227 summary, lineNumber = self.__getSummaryLine(docstringContext) 1227 summary, lineNumber = self.__getSummaryLine(docstringContext)
1228 if summary: 1228 if summary:
1229 # check, if the first word is 'Constructor', 'Public', 1229 # check, if the first word is 'Constructor', 'Public',
1230 # 'Protected' or 'Private' 1230 # 'Protected' or 'Private'
1231 functionName = context.source()[0].lstrip().split()[1]\ 1231 functionName, arguments = context.source()[0].lstrip()\
1232 .split("(")[0] 1232 .split()[1].split("(", 1)
1233 firstWord = summary.strip().split(None, 1)[0].lower() 1233 firstWord = summary.strip().split(None, 1)[0].lower()
1234 if functionName == '__init__': 1234 if functionName == '__init__':
1235 if firstWord != 'constructor': 1235 if firstWord != 'constructor':
1236 self.__error(docstringContext.start() + lineNumber, 0, 1236 self.__error(docstringContext.start() + lineNumber, 0,
1237 "D232", 'constructor') 1237 "D232", 'constructor')
1238 elif functionName.startswith('__') and \
1239 functionName.endswith('__'):
1240 if firstWord != 'special':
1241 self.__error(docstringContext.start() + lineNumber, 0,
1242 "D232", 'special')
1238 elif functionName.startswith(('__', 'on_')): 1243 elif functionName.startswith(('__', 'on_')):
1239 if firstWord != 'private': 1244 if firstWord != 'private':
1240 self.__error(docstringContext.start() + lineNumber, 0, 1245 self.__error(docstringContext.start() + lineNumber, 0,
1241 "D232", 'private') 1246 "D232", 'private')
1242 elif functionName.startswith('_') or \ 1247 elif functionName.startswith('_') or \
1243 functionName.endswith('Event'): 1248 functionName.endswith('Event'):
1244 if firstWord != 'protected': 1249 if firstWord != 'protected':
1245 self.__error(docstringContext.start() + lineNumber, 0, 1250 self.__error(docstringContext.start() + lineNumber, 0,
1246 "D232", 'protected') 1251 "D232", 'protected')
1252 elif arguments.startswith(('cls,', 'cls)')):
1253 if firstWord != 'class':
1254 self.__error(docstringContext.start() + lineNumber, 0,
1255 "D232", 'class')
1247 else: 1256 else:
1248 if firstWord != 'public': 1257 if firstWord != 'public':
1249 self.__error(docstringContext.start() + lineNumber, 0, 1258 self.__error(docstringContext.start() + lineNumber, 0,
1250 "D232", 'public') 1259 "D232", 'public')

eric ide

mercurial