jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.7k stars 4.93k forks source link

Open the help in a bottom panel #6692

Open jtpio opened 1 year ago

jtpio commented 1 year ago

The classic notebook (v6) opens the help panel at the bottom of the page, for example when using the following code snippet:

import math
math.pi?

image

JupyterLab inlines the help in the output:

image

Jupyter Notebook 7 does the same as JupyterLab since it uses the same notebook component:

image

Opening this issue to track this feature parity difference. Not sure this needs to be addressed for Notebook 7 but at least it's tracked somewhere.

jtpio commented 1 year ago

In the classic notebook this is also called the "pager":

image

jtpio commented 1 year ago

For reference this is handled here in JupyterLab:

https://github.com/jtpio/jupyterlab/blob/eeaa6505f658f7eaaad18ea2d7f15c3c5da0b23a/packages/outputarea/src/widget.ts#L664-L688

The content of the message contains "source": "page" as part of the payload:

{
  "content": {
    "status": "ok",
    "execution_count": 3,
    "user_expressions": {},
    "payload": [
      {
        "source": "page",
        "data": {
          "text/plain": "\u001b[0;31mType:\u001b[0m        float\n\u001b[0;31mString form:\u001b[0m 3.141592653589793\n\u001b[0;31mDocstring:\u001b[0m   Convert a string or number to a floating point number, if possible."
        },
        "start": 0
      }
    ]
  },
  "channel": "shell"
}
jtpio commented 1 year ago

The "Messaging in Jupyter" documentation also has some information about page: https://jupyter-client.readthedocs.io/en/stable/messaging.html#payloads-deprecated

Pager output is used for introspection, or other displayed information that’s not considered output. Pager payloads are generally displayed in a separate pane, that can be viewed alongside code, and are not included in notebook documents.

jtpio commented 1 year ago

It's not clear whether this will be addressed in time for 7.0. Bumping to 7.1, but if someone would like to have a look at it feel free to comment here!

janxkoci commented 5 months ago

I'm using Jupyter with R, and in R and the classic notebook interface I can get the help in the bottom pager with either e.g. ?sin (or equivalently help(sin)), or I can get help by putting cursor in a function name and pressing F1. Note that the F1 shortcut is understood by Jupyter even if on other pages the same shortcut opens the browser's manual (as is the case for e.g. GNOME Web/Epiphany).

The same shortcut has no such effect in both Jupyterlab and the Notebook v7 interfaces. Using the ?sin method puts help inline, as in the screenshots above. In Jupyterlab, there is also the "interactive help", which stays in place when scrolling, but changes during typing, so it's not a full replacement for the classic-style pager.