microsoft / codetour

VS Code extension that allows you to record and play back guided tours of codebases, directly within the editor.
https://aka.ms/codetour
MIT License
4.36k stars 113 forks source link

Support for tour steps within Jupyter Notebooks #233

Open andrewgiessel opened 2 years ago

andrewgiessel commented 2 years ago

This is a great plugin, and I my team and I would to be able to use it within the Jupyter notebook editor. Currently you /can/ add steps to any line in any cell, but when you visit the step, it does so in the un-rendered text version of the file, not in the notebook editor.

What would be needed to make this happen? Is this an upstream issue that would need changes to the notebook editor to support line annotation within a cell? I would be willing to help but would require some guidance on where to get started.

lostintangent commented 2 years ago

Hey! Yeah I'd love to be able to add this capability. I believe it will require support from VS Code in order to enable the complete E2E. In particular...

Let me do some investigations to confirm my assumptions above. And also, I'm tagging @rebornix, who would also be able to weigh in on the current VS Code APIs for notebooks.

andrewgiessel commented 2 years ago

Hey, thanks for the quick response! Regarding the first point, it feels doable. You can certainly highlight specific lines in cells (like when you put a debugging breakpoint), and the .ipynb is actually a JSON that has input and output sections. https://nbformat.readthedocs.io/en/latest/format_description.html

The second point is trickier for more than scrolling to the cell (typically there is no scrolling inside the cell, btw). Notebooks have state that is built up by executing code, and that state might not exist when you move to that step in the tour. I think this can be worked around, because you could have a step at the top of the file, and then ask the user to execute cells from there.

For more context: the main thing I'm hoping for is a way to have a seperate annotation level on code w/i the notebook. I have colleagues that have begun to use CodeTour for technical interviews and it would be cool to do the same in a data science setting.

edit: for clarity

rebornix commented 2 years ago

VS Code already has an API to open a notebook, but I don't believe it allows programmatically scrolling to a specific cell. And then I'm not sure if it supports programmatically scrolling a cell's editor. We'd need both in order to open a notebook and then navigate to a specific cell, and line of code within in

We actually support that. This is also how clicking on an error on problems panel to open/reveal a cell works now. Before we introduce link to cells, we might need to store the cell index which you want to link and then locate that cell in the notebook document. @lostintangent