[IPython-User] custom tooltips (docstring) for cell magics in notebook
Fri Jan 25 03:50:02 CST 2013
Le 25 janv. 2013 à 05:40, Ben Mabey a écrit :
> Hi all,
> Based on the current behavior of the R cell magic it looks like the
> docstring tooltips in the notebook always return docstrings for python
> functions. Being able to customize the tooltips for various magics
> would be a useful feature IMO.
> A cursory browsing of tooltip.js seems to indicate that docstrings are
> fetched from the kernel via the 'object_info_request' message/command.
> The only thing being passed to this handler is the name of the function
> you want the docstring for and not any context of the cell it is being
> ran in. Ideally a cell magic could provide a custom `object_inspect`
> that would be used instead of the default one in the shell object (i.e.
> python's). The tooltip js code would then need to also pass info to the
> kernel about the cell magic of the current cell so the kernel can
> attempt to delegate `object_inspect` appropriately.
> Has any thought or effort already been put into allowing for cell magic
> aware tooltips?
This is a idea to pursue, unfortunately I don't think it will be that easy.
You have to detect that you are actually in a cell magic, ad as the kernel is concerned,
cell magic are just function that take a string an execute something base on this string.
It does not always imply another language.
We probably want to have a way to get tooltip for other languages but we need to keep in mind that
this should also be the case fro other fronted than notebook. In notebook it should not be too hard to
'detect' some cell magic as different languages (it already does it for highlighting), but this is not alway the case.
There is one PR right now which decouple the tooltip from the rest of the notebook, and it might be easier to customize.
What might be to consider is the ability to also have native kernels so that you could directly ask to the corresponding kernel
instead of trying to go through the IPython one.
> IPython-User mailing list
More information about the IPython-User