-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Restore TOC code cells feature #14975
Comments
For information, that specific feature was removed for two reasons:
The way forward is likely not to include that in the table of content but to bring either or both:
|
Adding to the above, we could also consider:
|
Thank you for the quick reply. I will probably first go for publishing the extension in jupyterlab-contrib for simplicity and no changes are needed in the JupyterLab API as it is. Regarding the huge performance cost, was it mostly due to having to build numerous code cell editors in the case of long notebooks or to the toc becoming populated with too much content ? Would opting for a more lightweight way to display the code solve that problem or not ? |
Thanks a lot @Rmarieta for proposing your help
Both: lots of DOM nodes and lots of editors (CM 6 used in Lab 4 help on that front). I was thinking again about this. And a nice meaningful compact view of code cells that I would support to add to the ToC would be to display the cell code outline instead of the content; like you can do with LSP:
or
|
The LSP outline is high on priority list for LSP extension - but first need to finish porting it to 4.0. And could go straight to core if we want :) Inspired by the above, one notebook-oriented approach would be to show one line for each cell and (optionally) each output (truncated to say 3 outputs):
For me when analysing data this would be more useful than having code symbols - when navigating across large notebook I am usually interested in navigating to a specific visualisation/table I am working on rather than to a specific variable, because relevant variables are all proximal to the cell of interest (or imported) anyways. |
I agree that
would be an interesting solution to integrate the code cell input/output content as part of the toc. @krassowski I'm not so familiar with the LSP extension, are you talking about |
These two will hopefully converge in the future, I was in fact suggesting that it could go to the second one, skipping incubation in the former as outline is an additive low-risk feature.
The way I see it is that LSP outline would not give us the notebook structure needed for more notebook-oriented navigation. Maybe these should be two separate widgets or just separate subtrees in a single "navigation" panel. Maybe there are better ways to approach it - I am curious what @fcollonval envisioned. |
@krassowski I like your proposal of having two ToCs as proposed in jupyter-lsp/jupyterlab-lsp#970 |
Problem
Edit : You can use this TOC again with JupyterLab >= 4 installing this extension : https://github.com/jupyterlab-contrib/jupyterlab-code-toc
I've been working with the table of contents feature in collaboration with teachers and assistants for some time, and I have had the feedback multiple times that the old table of contents that included the code cells and "non-heading" markdown content was preferred. By old table of contents, I mean the following table of contents that was the default
toc
in older version of jupyterlab such as 3.6.3 and that got refactored around July 2021 :I have looked for issues or explanations in the commit history as to why the removal of the code cells and other extra features was decided at that time but I could not find a proper explanation. For the code cell toggle option in particular, would it be possible to restore that in the newer versions of the table of contents ? Removing the code cells from the table of contents and going for a newer version without an alternative is surprising so if there is an underlying technical issue justifying that decision, I would be happy to learn about it.
Proposed Solution
To restore that feature, since the way the
toc
is built has changed from using generators and monitoring changes in the notebook to connecting to changes in headings and retrieving them, the way the code cell content is retrieved would have to be adapted. I would be open to implement that feature myself since I've been building extensions with the current and the previoustoc
extensions, and I've already restored the oldtoc
in jupyterlab 4.x for my personal use.The way I could see it working would be to add a toolbar toggle button and add a config/setting so the user can include that feature or not. To achieve the display of the code cells, the
toc
extension would have to be modified. Here are the suggested modifications :tocitem.tsx
: run an additional check (only in the case of a NotebookPanel) to see if the heading cellRef corresponds to a code cell. If it does, render a CodeMirror editor with the cell input content instead of :toc
. Or, use the available jupyterlab API to build an editor.The text was updated successfully, but these errors were encountered: