diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index a106813..4cc8f9c 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -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. diff --git a/IPython/html/static/notebook/js/tooltip.js b/IPython/html/static/notebook/js/tooltip.js index df903a2..94ab40c 100644 --- a/IPython/html/static/notebook/js/tooltip.js +++ b/IPython/html/static/notebook/js/tooltip.js @@ -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 = $('
').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 = ""; } + this.tooltip.fadeIn('fast'); + this._hidden = false; this.text.children().remove(); var pre = $('
').html(utils.fixConsole(docstring));