Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contextual help #1307

Closed
amirhosseindavoody opened this issue Oct 9, 2019 · 57 comments
Closed

Contextual help #1307

amirhosseindavoody opened this issue Oct 9, 2019 · 57 comments
Assignees
Labels
feature-request Request for new features or functionality

Comments

@amirhosseindavoody
Copy link

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
Copy link
Contributor

rchiodo commented Oct 9, 2019

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

@amirhosseindavoody
Copy link
Author

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

  • The window is more helpful, since it can show more context. Generally, this is very helpful where the API is not trivial like in pandas and it could get long.
  • Also, I don't think the contextual help uses any intelisense, but it is a static readout of what the source code is. So, if the object does not exists then the contextual help window does not show anything. But, if the object exists (or the library has been imported already in the IPython kernel), then the window is much more responsive and more reliable since it can just read the the source code.

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
Copy link

javierbq commented Mar 9, 2020

+1

@snehmehta
Copy link

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

Thank you !

@rchiodo
Copy link
Contributor

rchiodo commented Apr 22, 2020

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
Copy link

snehmehta commented Apr 30, 2020

okay thanks for your response

@javierbq
Copy link

javierbq commented May 9, 2020

@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
Copy link
Contributor

rchiodo commented May 11, 2020

@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
Copy link
Contributor

rchiodo commented May 11, 2020

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
Copy link
Author

@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
Copy link
Contributor

rchiodo commented May 11, 2020

/cc @claudiaregio @jmew

@allefeld
Copy link

allefeld commented Jun 15, 2020

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
Copy link

Jaunson commented Jul 19, 2020

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
Copy link

ldorigo commented Jul 29, 2020

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.

@DonJayamanne DonJayamanne transferred this issue from microsoft/vscode-python Nov 13, 2020
@cipri-tom
Copy link

cipri-tom commented Dec 2, 2020

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

  1. 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
  1. 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
Copy link

loftusa commented Dec 15, 2020

+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
Copy link

luiul commented Dec 19, 2020

+1

1 similar comment
@kevingoh
Copy link

+1

@nyschoi
Copy link

nyschoi commented Dec 29, 2020

++1

@GitHunter0
Copy link

GitHunter0 commented Jan 7, 2021

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
Copy link

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
Copy link

Cyberjoe commented Feb 4, 2021

+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
Copy link

Cyberjoe commented Feb 4, 2021

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

@allefeld
Copy link

allefeld commented Feb 4, 2021

@Cyberjoe, that's a great find!

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

@GitHunter0
Copy link

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
Copy link

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

@GitHunter0
Copy link

@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
Copy link
Contributor

rchiodo commented May 2, 2022

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
Copy link
Contributor

rchiodo commented May 2, 2022

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.

@amirhosseindavoody
Copy link
Author

This is great! Thanks for working on this.

@greazer greazer added feature-request Request for new features or functionality and removed enhancement labels May 4, 2022
@loftusa
Copy link

loftusa commented May 12, 2022

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

This is such great news!! So happy to hear that this is being worked on, it remains probably the most important issue in vscode for me!

@Fred-Wu
Copy link

Fred-Wu commented May 15, 2022

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

This is great. Thanks for implementing this. It is very much needed.

Just wondering, whether this could be brought to python script as well?

@rchiodo
Copy link
Contributor

rchiodo commented May 16, 2022

@Fred-Wu this particular window is using the jupyter kernel's requestInspect message. That might be possible if the user was using the interactive window with a python file but otherwise there's no backing kernel.

However the docs-view extension mentioned elsewhere in this thread might be usable for you. It provides the pylance hover documentation in a separate window.

@Fred-Wu
Copy link

Fred-Wu commented May 17, 2022

@Fred-Wu this particular window is using the jupyter kernel's requestInspect message. That might be possible if the user was using the interactive window with a python file but otherwise there's no backing kernel.

However the docs-view extension mentioned elsewhere in this thread might be usable for you. It provides the pylance hover documentation in a separate window.

Thanks for the information. I have tried docs-view extension.

Just wondering why pylance hover doc behaves differently to jupyter kernel doc, in which pylance provides minimal and incomplete information compared to jupyter doc.

For example, with your extension, or run with ? I can see docstring for a bounded method

Code under cursor: twitter_samples.strings

Signature: twitter_samples.strings(fileids=None)
Docstring:
Returns only the text content of Tweets in the file(s)
:return: the given file(s) as a list of Tweets.
:rtype: list(str)
File:
Type: method

But in a normal script, it just shows

strings: Any

Also when I point to the JUPYTER: CONTEXTUAL HELP window, and select Cut/Copy/Paste, it actually performs these functions in the notebook for the section of codes the cursor points to. Is this an intended function or a bug here?

@rchiodo
Copy link
Contributor

rchiodo commented May 17, 2022

Pylance doesn't know the actual type of something because things can be unions or have no type specified. Only actually running something can the type always be figured out. That's why Jupyter shows more information.

For your second question, VS code doesn't seem to support copying from our panel. Not sure why. You could log a bug here:
https://github.com/microsoft/vscode-jupyter-powertoys/issues

@IanMatthewHuff IanMatthewHuff removed their assignment Nov 10, 2022
@DonJayamanne DonJayamanne added contextual-help and removed notebook-intellisense Intellisense & other language features in notebook cells for any language notebook-workflow Issues that interrupt expected or desirable behavior labels Dec 4, 2022
@DonJayamanne
Copy link
Contributor

I'm closing this issue as we have an extension that provides this functionality in the following extension
If the provided functionality doesn't work as expected please file an issue on the corresponding repo
Here is the link to the exctension https://marketplace.visualstudio.com/items?itemName=ms-toolsai.vscode-jupyter-powertoys
& here's the link to the corresponding repo https://github.com/microsoft/vscode-jupyter-powertoys

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests