Show More
@@ -497,6 +497,12 b' class IPCompleter(Completer):' | |||||
497 | else: |
|
497 | else: | |
498 | self.clean_glob = self._clean_glob |
|
498 | self.clean_glob = self._clean_glob | |
499 |
|
499 | |||
|
500 | #regexp to parse docstring for function signature | |||
|
501 | self.docstring_sig_re = re.compile(r'^[\w|\s.]+\(([^)]*)\).*') | |||
|
502 | self.docstring_kwd_re = re.compile(r'[\s|\[]*(\w+)(?:\s*=\s*.*)') | |||
|
503 | #use this if positional argument name is also needed | |||
|
504 | #= re.compile(r'[\s|\[]*(\w+)(?:\s*=?\s*.*)') | |||
|
505 | ||||
500 | # All active matcher routines for completion |
|
506 | # All active matcher routines for completion | |
501 | self.matchers = [self.python_matches, |
|
507 | self.matchers = [self.python_matches, | |
502 | self.file_matches, |
|
508 | self.file_matches, | |
@@ -670,24 +676,23 b' class IPCompleter(Completer):' | |||||
670 | form 'min(iterable[, key=func])\n' to find |
|
676 | form 'min(iterable[, key=func])\n' to find | |
671 | keyword argument names. |
|
677 | keyword argument names. | |
672 | """ |
|
678 | """ | |
673 |
if doc is None: |
|
679 | if doc is None: | |
674 | doc = doc.lstrip() |
|
680 | return [] | |
675 | sio = StringIO.StringIO(doc) |
|
681 | sio = StringIO.StringIO(doc.lstrip()) | |
676 | #care only the firstline |
|
682 | #care only the firstline | |
677 | #docstring can be long |
|
683 | #docstring can be long | |
678 | line = sio.readline() |
|
684 | line = sio.readline() | |
679 | p = re.compile(r'^[\w|\s.]+\(([^)]*)\).*') |
|
685 | #p = re.compile(r'^[\w|\s.]+\(([^)]*)\).*') | |
680 | #'min(iterable[, key=func])\n' -> 'iterable[, key=func]' |
|
686 | #'min(iterable[, key=func])\n' -> 'iterable[, key=func]' | |
681 |
sig = |
|
687 | sig = self.docstring_sig_re.search(line) | |
682 |
if sig is None: |
|
688 | if sig is None: | |
|
689 | return [] | |||
683 | # iterable[, key=func]' -> ['iterable[' ,' key=func]'] |
|
690 | # iterable[, key=func]' -> ['iterable[' ,' key=func]'] | |
684 | sig = sig.groups()[0].split(',') |
|
691 | sig = sig.groups()[0].split(',') | |
685 | #use this if you want iterable to show up too |
|
|||
686 | #q = re.compile('[\s|\[]*(\w+)(?:\s*=?\s*.*)') |
|
|||
687 | q = re.compile('[\s|\[]*(\w+)(?:\s*=\s*.*)') |
|
|||
688 | ret = [] |
|
692 | ret = [] | |
689 | for s in sig: |
|
693 | for s in sig: | |
690 | ret += q.findall(s) |
|
694 | #re.compile(r'[\s|\[]*(\w+)(?:\s*=\s*.*)') | |
|
695 | ret += self.docstring_kwd_re.findall(s) | |||
691 | return ret |
|
696 | return ret | |
692 |
|
697 | |||
693 | def _default_arguments(self, obj): |
|
698 | def _default_arguments(self, obj): |
General Comments 0
You need to be logged in to leave comments.
Login now