Notebook: Enable Code Folding by Default

Created on 28 Feb 2017  Â·  17Comments  Â·  Source: jupyter/notebook

Some users that I support love having the Code folding extension installed.

image

This seems like something we could support out of the box with jupyter notebook instead of having an extension. I'd certainly love having this even for beginners to help deal with unwieldy large notebooks.

Most helpful comment

I'd be fine with enabling this by default without persisting the state for now.

All 17 comments

I take it the bit about needing CodeMirror master is no longer true?

I'd support enabling code folding by default, but probably leave it to users to configure a shortcut for it.

It is better to link to the generated documentation than to the old Wiki:
http://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/codefolding/readme.html

In addition to enabling codefolding in CodeMirror itself, the extension provides saving the folded state in notebook metadata, and an nbconvert preprocessor.

Thanks @juhasch :-)

For putting it in core, I think I'd hold off on storing the state in metadata until we've worked out the 'companion file' question, giving us a place to store metadata that you don't look at in version control.

We're going to start using more metadata fields in nteract, albeit on a namespace (nteract). For small fields like these I'm not worried. It's the base64 encoded images that I want to optionally live separately as a relative asset or by absolute URL.

Small metadata is less annoying, but it can be quite changeable, which is annoying for version control.

Yeah what I want us to enforce going forward is establishing a schema and version for metadata we introduce: https://github.com/nteract/nteract/issues/1465

I just meant the data itself is changeable, rather than the format. I don't want things like code folding state in version control, any more than I want the last position of my cursor in version control - it makes the diff noisier for little gain.

@takluyver alternatively for version control with metadata you can use https://github.com/kynan/nbstripout
I find it works very well

Yep, we've made a variety of tools to make notebooks better with version control. I've done recombinecm and nbexplode, and nbdime is now recommended. But we try to restrict the changeable metadata in the notebook so that you don't have to use any of these tools.

I understand that people have a variety of different uses, but I feel like
for putting notebook files straight into version control the ship sailed
when outputs, especially images, were saved.

On Fri, 3 Mar 2017, 10:37 Thomas Kluyver, notifications@github.com wrote:

Yep, we've made a variety of tools to make notebooks better with version
control. I've done recombinecm https://github.com/takluyver/recombinecm
and nbexplode https://github.com/takluyver/nbexplode, and nbdime
https://github.com/jupyter/nbdime is now recommended. But we try to
restrict the changeable metadata in the notebook so that you don't have
to use any of these tools.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/jupyter/notebook/issues/2235#issuecomment-283921808,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAHCsgEmsXiCBidO3bqVY5vBRgBt_BXVks5rh-16gaJpZM4MNzvp
.

People do put up with it, or commit notebooks without outputs, as you mentioned. I'm keen not to make the situation worse by adding more highly variable metadata, but we have some vague plans taking shape to save two copies of the file - a more version-control friendly file with just inputs and some essential metadata, and a complete file with outputs and more variable metadata.

+1 for code folding!

To completely skirt the metadata issue, we could consider the code folding without the persistence. It would only be transient.

I'd be fine with enabling this by default without persisting the state for now.

+1 for code folding!

+1 code folding is useful

works ok

Was this page helpful?
0 / 5 - 0 ratings

Related issues

itoed picture itoed  Â·  3Comments

ehossain1982 picture ehossain1982  Â·  3Comments

pylang picture pylang  Â·  3Comments

uolter picture uolter  Â·  3Comments

toasteez picture toasteez  Â·  3Comments