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)
| 2839 | return matches |
| 2840 | |
| 2841 | def _default_arguments_from_docstring(self, doc): |
| 2842 | """Parse the first line of docstring for call signature. |
| 2843 | |
| 2844 | Docstring should be of the form 'min(iterable[, key=func])\n'. |
| 2845 | It can also parse cython docstring of the form |
| 2846 | 'Minuit.migrad(self, int ncall=10000, resume=True, int nsplit=1)'. |
| 2847 | """ |
| 2848 | if doc is None: |
| 2849 | return [] |
| 2850 | |
| 2851 | #care only the firstline |
| 2852 | line = doc.lstrip().splitlines()[0] |
| 2853 | |
| 2854 | #p = re.compile(r'^[\w|\s.]+\(([^)]*)\).*') |
| 2855 | #'min(iterable[, key=func])\n' -> 'iterable[, key=func]' |
| 2856 | sig = self.docstring_sig_re.search(line) |
| 2857 | if sig is None: |
| 2858 | return [] |
| 2859 | # iterable[, key=func]' -> ['iterable[' ,' key=func]'] |
| 2860 | sig = sig.groups()[0].split(',') |
| 2861 | ret = [] |
| 2862 | for s in sig: |
| 2863 | #re.compile(r'[\s|\[]*(\w+)(?:\s*=\s*.*)') |
| 2864 | ret += self.docstring_kwd_re.findall(s) |
| 2865 | return ret |
| 2866 | |
| 2867 | def _default_arguments(self, obj): |
| 2868 | """Return the list of default arguments of obj if it is callable, |