Parse the first line of docstring for call signature. Docstring should be of the form 'min(iterable[, key=func])\n'. It can also parse cython docstring of the form 'Minuit.migrad(self, int ncall=10000, resume=True, int nsplit=1)'.
(self, doc)
| 1428 | return matches |
| 1429 | |
| 1430 | def _default_arguments_from_docstring(self, doc): |
| 1431 | """Parse the first line of docstring for call signature. |
| 1432 | |
| 1433 | Docstring should be of the form 'min(iterable[, key=func])\n'. |
| 1434 | It can also parse cython docstring of the form |
| 1435 | 'Minuit.migrad(self, int ncall=10000, resume=True, int nsplit=1)'. |
| 1436 | """ |
| 1437 | if doc is None: |
| 1438 | return [] |
| 1439 | |
| 1440 | #care only the firstline |
| 1441 | line = doc.lstrip().splitlines()[0] |
| 1442 | |
| 1443 | #p = re.compile(r'^[\w|\s.]+\(([^)]*)\).*') |
| 1444 | #'min(iterable[, key=func])\n' -> 'iterable[, key=func]' |
| 1445 | sig = self.docstring_sig_re.search(line) |
| 1446 | if sig is None: |
| 1447 | return [] |
| 1448 | # iterable[, key=func]' -> ['iterable[' ,' key=func]'] |
| 1449 | sig = sig.groups()[0].split(',') |
| 1450 | ret = [] |
| 1451 | for s in sig: |
| 1452 | #re.compile(r'[\s|\[]*(\w+)(?:\s*=\s*.*)') |
| 1453 | ret += self.docstring_kwd_re.findall(s) |
| 1454 | return ret |
| 1455 | |
| 1456 | def _default_arguments(self, obj): |
| 1457 | """Return the list of default arguments of obj if it is callable, |