mwouts / jupytext

Jupyter Notebooks as Markdown Documents, Julia, Python or R scripts
https://jupytext.readthedocs.io
MIT License
6.6k stars 386 forks source link

Create language specific Text notebooks #1157

Closed mahendrapaipuri closed 10 months ago

mahendrapaipuri commented 10 months ago

1154 will add ability to create text notebooks from JupyterLab interface. However, we are making a strong assumption that these text notebooks are based on Python kernel. So, when user creates a Text notebook with Percent format, it will always create a file with .py extension.

We should be able to create text notebook for any arbitrary kernel (see comment) and so we should be able to create file with arbitrary file extensions. However, it is a bit tricky now as we choose kernel only after creating a file.

mwouts commented 10 months ago

Hi @mahendrapaipuri , seeing this screenshot in the docs: image made me think that maybe we could simply have a R:percent format for the people that wish to create R-percent notebooks?

Two more remarks/questions

mahendrapaipuri commented 10 months ago

Maybe we could iterate through the available kernels to determine which languages should be made available by default

If I understand you correctly, your suggestion is that we add formats programatically by iterating through available kernels. That solution is orthogonal to configuring formats via Settings, right?! I mean, the formats will be added automatically based on available kernels and those formats will not appear in the Settings. And users will not have a way to disable those automatically added formats. Does it make sense?

An option here is to add another Settings parameter like "Detect formats automatically" and we add the format icons based on available kernels if users choose this setting. This option should take precedence over configuring formats manually. And not using this setting, users will be able to add formats manually as in the screenshot in the above comment. What do you think?

Is it possible to use an icon that would correspond to the file extension?

Yes, should be possible.

made me think that maybe we could simply have a R:percent format for the people that wish to create R-percent notebooks?

Yes, this is a simpler solution. Users will have to do this only once given that their JUPYTER_CONFIG_DIR is persisted.

When are you aiming to make 1.16.0 release? It would be nice to sort this out before the release!

parmentelat commented 10 months ago

Hey there It's my understanding too that json settings and programmatically building UI contents are mutually exclusive, at least I ran into this issue when tweaking MainMenu in another context Personally I would argue to keep it simple for a first iteration of this feature, but this is because I am way less comfortable with extensions than @mahendrapaipuri :) In any case I cannot thank you enough:), and am very sorry to not being able to help more as I am currently afk for a couple of weeks..

mwouts commented 10 months ago

Hi @mahendrapaipuri , @parmentelat , thank you for your inputs!

Yes, I see what you mean! Then my preference, if that makes sense/if that's feasible, would be to keep the setting pages as is, but then programmatically replace auto: with every extension for which a kernel exists in both auto:percent and auto:light. I am a big fan of default settings that are useful to everyone (i.e. settings that you don't need to know of!)

Re the icon, that would be great! Also maybe we might need to include the language or at least the extension in the entry if we have e.g. both 'Python percent notebook' and 'R percent notebook' in the launcher.

When are you aiming to make 1.16.0 release? It would be nice to sort this out before the release!

Oh I think the test reorganization (#1136) might be ready by the end of this week, we can release any time after that, so I'd say one or two weeks. I do agree with you that it would be very nice to include the current issue in the release, and I'd be happy to give you more time if you'd like to propose something!

mahendrapaipuri commented 10 months ago

Yes, I see what you mean! Then my preference, if that makes sense/if that's feasible, would be to keep the setting pages as is, but then programmatically replace auto: with every extension for which a kernel exists in both auto:percent and auto:light

I can see two options here

Personally, I feel the first option would be more clear for users and we can document in the Settings page that auto will be replaced by py by default. Let me know what you both think.

Re the icon, that would be great! Also maybe we might need to include the language or at least the extension in the entry if we have e.g. both 'Python percent notebook' and 'R percent notebook' in the launcher.

Agree and this should not be an issue.

I'd be happy to give you more time if you'd like to propose something!

I will give it a go this weekend. It should not be very complicated (unless I am missing something). Let's see and try to fix it before the release.