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
RST and heading cells #1331
RST and heading cells #1331
Conversation
Looking great! A few comments:
Awesome job! I haven't reviewed the code yet, just playing with the functionality for now. |
|
Hey, On Thu, Jan 26, 2012 at 11:23 PM, Brian E. Granger
Well, I'm wondering if it doesn't make sense to have both: rst cells
Oh sure, that's totally for later. It's fine if for now there's not
Ah, I didn't realize because they weren't listed in the keybindings But they seem to work fine, which is awesome! |
|
Can I ask why, in general, RST is abbreviated (and as the unconventional RST no less), and others are not? It seems like the menu item should say 'reStructuredText', or at least use the more common 'reST' abbreviation if that's too long for some reason. Abbreviations in menu items are generally a bad idea. And yes, I think we do need to increment the notebook version if you are adding things that aren't sensible in previous versions. We also should add all the planned cell metadata (UUIDs, etc.) in the next revision, and ideally the hash mechanism Stefan would need for his plan to reduce the enormous network traffic on save, which will be critical once remote notebook servers of anything beyond trivial notebooks become common. |
On Fri, Jan 27, 2012 at 5:49 PM, Min RK
Hehe, good question. I am completely unsatisfied with the traditional "reStructuredText is sometimes abbreviated as RST, ReST, or reST" I suppose "reStructuredText" is the best non-abbreviated version and I
OK I will increment the nbformat version in this PR. I agree that we
Brian E. Granger |
So there's just one cell type for 'untransformed'? Then I think it should definitely not be called RST. How about calling it 'raw'?
Yes, I didn't mean that this should all be part of the same PR, I was just making the point that since we have additions planned that already require incrementing the format, we don't need to try to fit this change into the previous version since there will never be a release with this change and not a new format. |
I have not implemented this yet, but I was going to call these cells
Ahh OK this sounds good.
Brian E. Granger |
I'm OK with leaving just one plaintext cell type for now. We can always revisit that later if we find a compelling need for both plaintext and explicit reST cells for some reason. @ellisonbg, it seems that once you update the cell name in the menu, this one is almost ready to go, right? The only thing I see missing is that the new cell types will need to be added to the drop-list in the new toolbar, which got merged in the meantime. |
BTW, I suggest we wait on merging this one until #1332 is in, to avoid creating that conflict again which @astraw has already had to manually disentangle twice. That one seems more or less good to go, I just don't want to merge it without Brian having a chance to look at it first in its final state. |
More work is needed on this one before it is merged, #1332 should be On Sun, Jan 29, 2012 at 12:09 PM, Fernando Perez
Brian E. Granger |
OK, I just merged #1332 and there are no conflicts here, which is good. It also seems to work fine, the only changes I see still pending are:
Did I miss anything? |
I will need to put the old v2 nbformat back in.
* Implemented conversion function (no-op for now). * Other misc changes.
* json separator is not ',' to avoid adding extra space at EOL. * vs used throughout nbformat.current. * Cell collapse is properly loaded from notebook.
Added plaintext and heading cells to the notebook UI and nbformat. In the process we have updated the nbformat to v3 and integrated these new cell types into the new toolbar.
I'm not sure this was ready for merge, because the notebook format version handling was not fully fleshed out. For instance, if I open an existing notebook and add rst/heading cells to it, and save it, it remains notebook format v2, which is inaccurate. |
@minrk: Hmm, I thought I tested everything pretty well, but looks like there is a bug. Do you have an example of a notebook that behaves in this way, or is it completely general? |
What if you open the notebook and resave without adding any new cell types? On Mon, Jan 30, 2012 at 6:27 PM, Min RK
Brian E. Granger |
Also, can you do an extra notebook reload or two. The nbformat used On Mon, Jan 30, 2012 at 6:34 PM, Brian Granger ellisonbg@gmail.com wrote:
Brian E. Granger |
Hm, could have been my mistake being too hasty. Do we really want to be silently upgrading users' notebooks to a version incompatible with the stable release, with no indication that this is happening at all? |
You should send a message on the dev list that notebook version is bumped, hopefully I do have versionning of my .ipynb files |
Yes, let's be careful with this in the future. This very nearly bit me yesterday, as I was writing (using master) a set of notebooks for a lecture at Berkeley, that were meant to be used by a bunch of students using EPD. Fortunately I hadn't pulled during the day, but it could have led to an awkward scramble to disentangle a version mess in front of the whole class (they were meant to follow me along). So let's try to be pretty strict from now on about announcing clearly whenever we bump the notebook version number so at least it doesn't happen silently under the hood. And I think that whenever a notebook gets opened that's in an older format, we should pop up immediately a dialog saying something like: "This notebook was saved in an older format X, note that the first time you save it, it will be written in the new format Y. If you do not want this to happen, reopen it with the older version of IPython used to create it." or similar. We don't want to say that on save, b/c by that point the user may have already done a bunch of work, so I think that warning on open is the right approach. I'm at the airport about to board a flight, so I'll be offline at least until tomorrow; but I think pinging the lists (both -dev and -user) soon explaining this would be a good idea. |
A few points:
On Tue, Jan 31, 2012 at 5:09 AM, Fernando Perez
Brian E. Granger |
Right, and this is why this is the first real notebook increment. The notebook format was v2 before it was even in master, I think, and certainly well before anybody other than you and Fernando were using it for real.
Yes, I think we must do this. It is terrible practice to silently upgrade in a destructive way, which we are doing in master now. Information is preserved, but compatibility is destroyed.
I think that's fair. We just want to avoid destroying their ability to collaborate with 0.12 users without giving them a chance to take some precautions. Probably just offering to: save / cancel / duplicate old version before save should do it. If we want a 'compatibility mode', we would need to define a v3->v2 conversion on the server side, which would of course not be lossless as we are adding new metadata and cell types, but would still probably be useful.
Great, thanks! |
Just to say that I think the dialog as added is fine. As long as the user has a way to back off from the destructive write (not everybody has backups or uses version control), that's OK. So I think in the future (there will be more instances of this) we can keep this policy: notify both user/dev lists, and add a similar dialog that at least lets people back off manually before they clobber the on-disk version of their notebooks. |
Added plaintext and heading cells to the notebook UI and nbformat. In the process we have updated the nbformat to v3 and integrated these new cell types into the new toolbar.
Added RST and heading cells to the notebook. The basic implementation is done, but there are a few questions to resolve:
We also need to implement a UI element that clearly shows the type of the currently selected cell. I would like to put that in a separate PR on some related UI work. Export/import to .py files should work. Anyone bored and want to implement RST export? :)