Show More
@@ -1,3 +1,7 b'' | |||||
|
1 | # Standard library imports | |||
|
2 | import re | |||
|
3 | from textwrap import dedent | |||
|
4 | ||||
1 | # System library imports |
|
5 | # System library imports | |
2 | from PyQt4 import QtCore, QtGui |
|
6 | from PyQt4 import QtCore, QtGui | |
3 |
|
7 | |||
@@ -57,6 +61,17 b' class CallTipWidget(QtGui.QLabel):' | |||||
57 | # 'CallTipWidget' interface |
|
61 | # 'CallTipWidget' interface | |
58 | #-------------------------------------------------------------------------- |
|
62 | #-------------------------------------------------------------------------- | |
59 |
|
63 | |||
|
64 | def show_docstring(self, doc, maxlines=20): | |||
|
65 | """ Attempts to show the specified docstring at the current cursor | |||
|
66 | location. The docstring is dedented and possibly truncated for | |||
|
67 | length. | |||
|
68 | """ | |||
|
69 | doc = dedent(doc.rstrip()).lstrip() | |||
|
70 | match = re.match("(?:[^\n]*\n){%i}" % maxlines, doc) | |||
|
71 | if match: | |||
|
72 | doc = doc[:match.end()] + '\n[Documentation continues...]' | |||
|
73 | return self.show_tip(doc) | |||
|
74 | ||||
60 | def show_tip(self, tip): |
|
75 | def show_tip(self, tip): | |
61 | """ Attempts to show the specified tip at the current cursor location. |
|
76 | """ Attempts to show the specified tip at the current cursor location. | |
62 | """ |
|
77 | """ |
@@ -293,7 +293,7 b' class FrontendWidget(HistoryConsoleWidget):' | |||||
293 | cursor.position() == self._calltip_pos: |
|
293 | cursor.position() == self._calltip_pos: | |
294 | doc = rep['content']['docstring'] |
|
294 | doc = rep['content']['docstring'] | |
295 | if doc: |
|
295 | if doc: | |
296 |
self._call_tip_widget.show_ |
|
296 | self._call_tip_widget.show_docstring(doc) | |
297 |
|
297 | |||
298 | def _started_listening(self): |
|
298 | def _started_listening(self): | |
299 | self.clear() |
|
299 | self.clear() |
General Comments 0
You need to be logged in to leave comments.
Login now