Merge pull request #3793 from jhamrick/master

Disable autotooltip if no docstring 

This will disable the tooltip if there's no docstring, after ( is typed. Pressing tab to request the tooltip will still bring it up. This hasn't been tested against the Julia kernel, however.

Closes #3788
pull/37/head
Matthias Bussonnier 13 years ago
commit e2538556b7

@ -167,7 +167,9 @@ var IPython = (function (IPython) {
// triger on keypress (!) otherwise inconsistent event.which depending on plateform
// browser and keyboard layout !
// Pressing '(' , request tooltip, don't forget to reappend it
IPython.tooltip.pending(that);
// The second argument says to hide the tooltip if the docstring
// is actually empty
IPython.tooltip.pending(that, true);
} else if (event.which === key.UPARROW && event.type === 'keydown') {
// If we are not at the top, let CM handle the up arrow and
// prevent the global keydown handler from handling it.

@ -39,6 +39,9 @@ var IPython = (function (IPython) {
// 'sticky ?'
this._sticky = false;
// display tooltip if the docstring is empty?
this._hide_if_no_docstring = false;
// contain the button in the upper right corner
this.buttons = $('<div/>').addClass('tooltipbuttons');
@ -178,10 +181,10 @@ var IPython = (function (IPython) {
}
// will trigger tooltip after timeout
Tooltip.prototype.pending = function (cell) {
Tooltip.prototype.pending = function (cell, hide_if_no_docstring) {
var that = this;
this._tooltip_timeout = setTimeout(function () {
that.request(cell)
that.request(cell, hide_if_no_docstring)
}, that.time_before_tooltip);
}
@ -212,7 +215,7 @@ var IPython = (function (IPython) {
}
// make an imediate completion request
Tooltip.prototype.request = function (cell) {
Tooltip.prototype.request = function (cell, hide_if_no_docstring) {
// request(codecell)
// Deal with extracting the text from the cell and counting
// call in a row
@ -224,6 +227,8 @@ var IPython = (function (IPython) {
ch: 0
}, cursor).trim();
this._hide_if_no_docstring = hide_if_no_docstring;
if(editor.somethingSelected()){
text = editor.getSelection();
}
@ -312,8 +317,6 @@ var IPython = (function (IPython) {
this.arrow.animate({
'left': posarrowleft + 'px'
});
this.tooltip.fadeIn('fast');
this._hidden = false;
// build docstring
var defstring = reply.call_def;
@ -331,10 +334,15 @@ var IPython = (function (IPython) {
if (docstring == null) {
docstring = reply.docstring;
}
if (docstring == null) {
if (docstring == null && this._hide_if_no_docstring) {
return;
} else {
docstring = "<empty docstring>";
}
this.tooltip.fadeIn('fast');
this._hidden = false;
this.text.children().remove();
var pre = $('<pre/>').html(utils.fixConsole(docstring));

Loading…
Cancel
Save