microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.27k stars 283 forks source link

Contextual help #1307

Closed amirhosseindavoody closed 1 year ago

amirhosseindavoody commented 4 years ago

One of the great benefits of python notebook is the exploratory nature of it. I personally find the contextual help window in jupyter lab a very helpful feature that makes the exploratory data analysis very easy by providing a fluid guide for the many API's that one might have to try. I don't know how big of an ask this is, but it would be much appreciated to provide this in VScode notebook editor.

Below is a screen shot of what I am referring to in jupyter lab. The functionality is that by clicking on each function, the docstring for that function is show in the contextual help window.

image

rchiodo commented 4 years ago

We have this on hover? I assume you've already seen that and would prefer a separate window?

amirhosseindavoody commented 4 years ago

Yes, I have seen it. A couple of points:

On a personal note, I find the intelisence not very useful since very often the help hover window takes a lot of time to show up.

javierbq commented 4 years ago

+1

snehmehta commented 4 years ago

I am looking for same feature. is it implemented ? if yes how to enable it

Thank you !

rchiodo commented 4 years ago

This is sort of implemented. We don't have a separate window for it, but the base support of typing a '?' before something in the interactive window works.

Example:

image

snehmehta commented 4 years ago

okay thanks for your response

javierbq commented 4 years ago

@rchiodo not the same, Jupiter’s automatic contextual help is just amazing.

Being able to see the state of variables and documentation just by clicking on a cell is just great. Huge productivity boost.

rchiodo commented 4 years ago

@javierbq so the clicking is the key? ?var returns the same information as the contextual help panel.

Doesn't seem too hard to implement this on clicking on a value.

rchiodo commented 4 years ago

For future reference, contextual help is on the help menu in Jupyter Lab. It opens a tab at the bottom that responds to click events in code with sending an 'inspect_request' to the kernel for whatever is under the mouse. The results of the inspect request are then displayed in the help panel.

amirhosseindavoody commented 4 years ago

@javierbq so the clicking is the key? ?var returns the same information as the contextual help panel.

Doesn't seem too hard to implement this on clicking on a value.

Yes, in my experience it makes a big difference to have the extra tab open side by side the editor and whereever the cursor is, it shows the output of ?var for that variable.

rchiodo commented 4 years ago

/cc @claudiaregio @jmew

allefeld commented 4 years ago

I would like to strongly support this!

I have been switching between Python IDEs on a search for the best, and have now arrived at VS Code which in my experience is superior in many ways.

But one feature I really miss from Jupyter Lab is the automatically updated contextual help panel.

As I wrote in issue microsoft/vscode-python#11655 linked to above, the current pop-up crushes everything together, is too small to read long texts, and disappears too easily on mouse movement. It is also often hard to trigger.

Yes, it is possible to use the IPython-style ?, but that means to open a new cell, type in the command, then scroll through a small viewport. For many packages, documentation can be many pages long, I think that deserves a dedicated panel.

Jaunson commented 4 years ago

Just adding another voice to support this - this feature alone is why I am not in Vscode full time. It might sound trivial but this feature easily saves me hours in development time or when coming up to speed on a package.

ldorigo commented 4 years ago

Same as Jaunson! Getting quick contextual information (docs are a great start but any additional information is welcome) of whatever is under the cursor is a huge productivity boost. Hope to see this implemented soon.

cipri-tom commented 3 years ago

Indeed, this is what keeps me productive in Jupyter. I don't have to memorize all the stuff.

When it gets implemented, please also enable a keyboard shortcut for it. In Jupyter there are 3 shortcuts that display progressively more information:

  1. Shift + Tab

    • parameter hints

    • this is what VS Code currently displays when the caret is within (...). Screenshot 2020-12-02 at 13 08 32

    • In both editors, it is often too small to understand anything

  2. Shift + Tab + Tab [ + Tab] (2 or 3 times)

    • expanded parameter hints
    • It shows the hints, and the documentation, in a slightly taller pop-up.
    • VS Code has this on hover, but size is kind of small Screenshot 2020-12-02 at 13 05 54
    • if Tab is pressed 3 times, the tooltip lingers for a few seconds while you type
    • video from their docs: https://youtu.be/TgqMK1SG7XI
  3. Shift + 4 * Tab

    • contextual help
    • opens a panel at the bottom with nice to read documentation (formatted!)
    • in JupyterLab (not normal notebooks), this panel updates as you move around

An extension that kind of does this is Kite Copilot : https://www.kite.com/copilot/ … but it is an external app and I don't want to install the whole of Kite for this.

Another external app which provides similar functionality is Dash -- there is an extension which interfaces with VS Code, but you need to have Dash window next to VS Code window (to recreate the experience). I haven't tested if it woks in notebooks.


I would say that this functionality will benefit the non-notebook workflow too

loftusa commented 3 years ago

+1 on this. I haven't been able to get shift+tab when I'm working with vscode jupyter to work the same way as it does in browser, and have tried a few things at this point. This feature is pretty much the only reason I still use the browser version.

luiul commented 3 years ago

+1

kevingoh commented 3 years ago

+1

nyschoi commented 3 years ago

++1

GitHunter0 commented 3 years ago

Hey @rchiodo , I think this feature is a major productivity booster and time saver.

RStudio, similarly has a separate window for that, "Help" pane. Just select a function and press F1 and it will open the documentation.

Advantages: (1) You can define the size of "Help" pane. (Kite window size is too small and makes really hard to inspect some documents) (2) Unlike Kite hover feature, it stays open while you work on your code, so that you can reference to it in real time (3) Unlike help(function) command, it already shows the documentation from the beginning, so there is no need to scroll up to the beginning of the output cell every time to see the documentation, which is really painful. (4) It keeps the history of help searches to go back at it

Thank you

ausiddiqui commented 3 years ago

I use VSCode for editing existing Python/SQL scripts but never the Jupyter notebook feature when starting new projects because of this feature. The boost to productivity and learning an API is huge especially with the context panel and the shift tab shortcut. Same issues as other reported with hover and how quickly it disappears, and having to switch between keyboard and mouse is not ideal.

This would be an amazing feature to add as another panel like the data viewer panel but one that you can position permanently on a part of the screen. Thanks for considering this!

Cyberjoe commented 3 years ago

+1 - pls add this functionality to VSCode. It would be a significant breakthrough. You also may want to look at Spyder. I love its always-on help.

Cyberjoe commented 3 years ago

I just discovered this new extension which addresses the issue very well: [https://marketplace.visualstudio.com/items?itemName=bierner.docs-view]

allefeld commented 3 years ago

@Cyberjoe, that's a great find!

Unfortunately, it doesn't work within notebooks, but neither does the standard popup (at least not properly).

GitHunter0 commented 3 years ago

I just discovered this new extension which addresses the issue very well: [https://marketplace.visualstudio.com/items?itemName=bierner.docs-view]

Fantastic extension, it would be great to see it incorporated in VScode as the default. Thanks a lot for the suggestion

GitHunter0 commented 3 years ago

I discovered this trick too using "Open Definition to the Side" command: https://www.youtube.com/watch?v=3p4pXhpPVf4

claudiaregio commented 3 years ago

+1 image

GitHunter0 commented 2 years ago

When this feature comes up, I really hope it works for .py files in Interactive Window too. For that, do we have to open the same issue in vscode-python?

rchiodo commented 2 years ago

@GitHunter0

For that, do we have to open the same issue in vscode-python?

No this window would be created in the jupyter extension for the interactive window. The interactive window is talking to a notebook kernel in the background, and that's what would drive the contextual help. At least one way to do it. @mjbvz's doc-view extension works without a kernel though. It just uses the hover provider.

dennischenfeng commented 2 years ago

+1. This missing feature, because it saves so much time, is basically the only reason I still prefer Jupyter Notebook's standard browser editor over VS Code's Jupyter extension, even though I really like a lot of VS Code's other features. I'd switch to VS Code in a heartbeat if it had as good contextual help as Jupyter Notebook. The following is my reasoning (please correct me if wrong or I'm missing something).

To make the differences clear, I've attached images showing how Jupyter Notebook's "Shift-Tab" contextual help feature is better than VS Code's in all practical cases (in my every day use). I show 3 cases (numpy, pandas, and glob function applications), and compare Jupyter Notebook's "shift-tab" contextual help against VS Code's "hover" documentation. The last cell of each image shows the output of <function>?, for reference.

Jupyter Notebook: , ,

VS Code: , ,

In all cases, the VS Code either shows nothing useful (randint case) or some minimal documentation (not as extensive as Jupyter or ? command), whereas Jupyter Notebook shows either the ? command output or something even more useful (glob case).

My understanding is that the Docs View extension mentioned as a possible solution above (https://marketplace.visualstudio.com/items?itemName=bierner.docs-view) would just show "hover" documentation, which the examples show is still not good in some cases.

I've only started using VS Code recently, so please let me know if I'm missing or misunderstanding something important!

Hoping this feature will come soon!

GitHunter0 commented 2 years ago

In all cases, the VS Code either shows nothing useful (randint case) or some minimal documentation (not as extensive as Jupyter or ? command), whereas Jupyter Notebook shows either the ? command output or something even more useful (glob case).

My understanding is that the Docs View extension mentioned as a possible solution above (https://marketplace.visualstudio.com/items?itemName=bierner.docs-view) would just show "hover" documentation, which the examples show is still not good in some cases.

Yes, I have the same experience, neither VScode/Kite nor Docs View extension display the full documentation of methods in many cases. I think it is a major issue, sometimes I even use RStudio to work on Python files because of these help limitations.

VScode is amazing in some many aspects but this one is definitively a shortcoming.

claudiaregio commented 2 years ago

cc/ @savannahostrowski

LunarLanding commented 2 years ago

This is half of my jupyter workflow; and to be clear, this means wiring up vscode to the interpreter state, instead of getting it from static analysis. I can't switch to vscode-jupyter without this.

bonassifabio commented 2 years ago

+1 This is definitely a huge VSCode shortcoming.

loftusa commented 2 years ago

I'd like to add yet another +1 on this, I've had the exact same experience as @dennischenfeng. It's literally the only thing that causes me to still use Jupyter Lab over VSCode. I'd immediately switch to VSCode exclusively if this feature existed.

bonassifabio commented 2 years ago

Unfortunately it's not just a matter of how information is displayed, but also how detailed is the doc shown to the user Schermata 2021-11-11 alle 16 59 04

Schermata 2021-11-11 alle 16 59 53
loftusa commented 2 years ago

@rchiodo @greazer I honestly think this is the most important issue in VSCode right now.

McClunatic commented 2 years ago

I'm seeing requests for this from colleagues otherwise interested in moving to VS Code! +1 from me!

thetruejacob commented 2 years ago

Is this still not implemented yet? It would provide such a huge boost to productivity.

Cyberjoe commented 2 years ago

The newly introduced side panel provides an opportunity to display contextual help.

  1. Install the Docs View extension
  2. [View] - [Appearance] - [Side Panel]
  3. [View] - [Open View...] - [Documentation - Panel]
  4. Drag and drop the Documentation tab from the panel to the side panel
  5. Type a python command and the documentation shows up in the side panel.
  6. Unfortunately, the documentation disappears as soon as you start typing more code. You can get around this issue by 'pinning' (see screenshot).

There's still significant potential for improvement. VSCode Developers - please have a look at Spyder in terms of process/layout/formatting.

Screenshot-VSCode

GitHunter0 commented 2 years ago

@Cyberjoe , the problem is that Docs View extension, like VScode, in many cases also does not find and display the complete documentation like JupyterLab does. Nonetheless, that was a very good tip.

dennischenfeng commented 2 years ago

I think some parts of this issue have been solved (which I'm happy about!), while others remain unsolved.

Examples that are resolved: Some np, pd, and path lib functions, that I linked to in my original post on this thread (2021/10/14). VS Code now properly shows comparable contextual help to JupyterLab image image image

Examples not yet resolved: I only tested some torch functions (not many other packages), and seems like for some reason their contextual help still hasn't been improved, whereas JupyterLab's contextual help is still better. image image

Idk why some packages show discrepancy between VS Code vs JupyterLab, whereas others don't. Nonetheless, I'm still glad that it's actually being worked on and there has been some improvement so far.

GitHunter0 commented 2 years ago

@dennischenfeng , very glad to know it is improving. As others have claimed and I agree, this is the most important issue of VScode right now.

thorwhalen commented 2 years ago

+1

pcava commented 2 years ago

+1

rchiodo commented 2 years ago

I have some good news. We were able to create a power toys extension that partially implements this feature. I say partial because it's not the exact same behavior as jupyter where you hit F1 and it gives you more and more detail.

You can try it out here with either the insiders version of VS code or wait for the next version of VS code stable to ship.

Contextual help window looks like so: contextualHelp

rchiodo commented 2 years ago

It should be noted it's a little rough. It's from a hackathon project I did last year to try and address this that we never put in the real product. So it might not work, and the UI looks a bit stale. But hopefully it gives the information asked for.

There's a setting to control the detail level of the output:

image

GitHunter0 commented 2 years ago

@rchiodo indeed a great news! Will this work in the Interactive Window too? (I only use Jupyter Notebooks if I really have to, the Interactive Window is a better and cleaner product in my opinion)

rchiodo commented 2 years ago

It kinda works in the interactive window. At least in cells already run. Doesn't work in the input box because VS code doesn't treat that the same.

rchiodo commented 2 years ago

Oh and you have to expand the cells after they run to get the help. image

In that picture I've run a cell where the last line is 'pd.array'. As I move the cursor around in that line, the contextual help changes.