150 class Function(ClbrBaseClasses.Function, VisibilityMixin): |
152 class Function(ClbrBaseClasses.Function, VisibilityMixin): |
151 """ |
153 """ |
152 Class to represent a Python function. |
154 Class to represent a Python function. |
153 """ |
155 """ |
154 def __init__(self, module, name, file, lineno, signature='', separator=',', |
156 def __init__(self, module, name, file, lineno, signature='', separator=',', |
155 modifierType=ClbrBaseClasses.Function.General): |
157 modifierType=ClbrBaseClasses.Function.General, annotation=""): |
156 """ |
158 """ |
157 Constructor |
159 Constructor |
158 |
160 |
159 @param module name of the module containing this function |
161 @param module name of the module containing this function |
160 @param name name of this function |
162 @param name name of this function |
161 @param file filename containing this class |
163 @param file filename containing this class |
162 @param lineno linenumber of the class definition |
164 @param lineno linenumber of the class definition |
163 @param signature parameterlist of the method |
165 @param signature parameterlist of the method |
164 @param separator string separating the parameters |
166 @param separator string separating the parameters |
165 @param modifierType type of the function |
167 @param modifierType type of the function |
|
168 @param annotation return annotation |
166 """ |
169 """ |
167 ClbrBaseClasses.Function.__init__(self, module, name, file, lineno, |
170 ClbrBaseClasses.Function.__init__(self, module, name, file, lineno, |
168 signature, separator, modifierType) |
171 signature, separator, modifierType, |
|
172 annotation) |
169 VisibilityMixin.__init__(self) |
173 VisibilityMixin.__init__(self) |
170 |
174 |
171 |
175 |
172 class Attribute(ClbrBaseClasses.Attribute, VisibilityMixin): |
176 class Attribute(ClbrBaseClasses.Attribute, VisibilityMixin): |
173 """ |
177 """ |
295 thisindent = _indent(m.group("MethodIndent")) |
299 thisindent = _indent(m.group("MethodIndent")) |
296 meth_name = m.group("MethodName") |
300 meth_name = m.group("MethodName") |
297 meth_sig = m.group("MethodSignature") |
301 meth_sig = m.group("MethodSignature") |
298 meth_sig = meth_sig.replace('\\\n', '') |
302 meth_sig = meth_sig.replace('\\\n', '') |
299 meth_sig = _commentsub('', meth_sig) |
303 meth_sig = _commentsub('', meth_sig) |
|
304 meth_ret = m.group("MethodReturnAnnotation") |
|
305 meth_ret = meth_ret.replace('\\\n', '') |
|
306 meth_ret = _commentsub('', meth_ret) |
300 lineno = lineno + src.count('\n', last_lineno_pos, start) |
307 lineno = lineno + src.count('\n', last_lineno_pos, start) |
301 last_lineno_pos = start |
308 last_lineno_pos = start |
302 if modifierType and modifierIndent == thisindent: |
309 if modifierType and modifierIndent == thisindent: |
303 if modifierType == "@staticmethod": |
310 if modifierType == "@staticmethod": |
304 modifier = ClbrBaseClasses.Function.Static |
311 modifier = ClbrBaseClasses.Function.Static |
334 # it's a class method |
341 # it's a class method |
335 cur_class = classstack[-1][0] |
342 cur_class = classstack[-1][0] |
336 if cur_class: |
343 if cur_class: |
337 # it's a method/nested def |
344 # it's a method/nested def |
338 f = Function(None, meth_name, |
345 f = Function(None, meth_name, |
339 file, lineno, meth_sig, modifierType=modifier) |
346 file, lineno, meth_sig, annotation=meth_ret, |
|
347 modifierType=modifier) |
340 cur_class._addmethod(meth_name, f) |
348 cur_class._addmethod(meth_name, f) |
341 else: |
349 else: |
342 # it's a function |
350 # it's a function |
343 f = Function(module, meth_name, |
351 f = Function(module, meth_name, |
344 file, lineno, meth_sig, modifierType=modifier) |
352 file, lineno, meth_sig, annotation=meth_ret, |
|
353 modifierType=modifier) |
345 if meth_name in dict_counts: |
354 if meth_name in dict_counts: |
346 dict_counts[meth_name] += 1 |
355 dict_counts[meth_name] += 1 |
347 meth_name = "{0}_{1:d}".format( |
356 meth_name = "{0}_{1:d}".format( |
348 meth_name, dict_counts[meth_name]) |
357 meth_name, dict_counts[meth_name]) |
349 else: |
358 else: |