nbdime icon indicating copy to clipboard operation
nbdime copied to clipboard

nbdiff-web output with folded diffs

Open BoPeng opened this issue 7 years ago • 4 comments

I am interested in generating HTML report from Jupyter notebooks in a style similar to https://stephenslab.github.io/gtexresults/Uk3.html . I have already have the TOC and revision info done, but the "expand here to see past version" part is more difficult. I do not need to have the exact output, so something like an earlier version of the output cell that is hidden by default would be suffice.

How difficult would it be to add a such style to output of nbdiff-web? Does it need changes at the core (python) level or some new template would be sufficient? I can contribute this style to nbdime if you think it is useful.

image

BoPeng avatar Aug 06 '18 14:08 BoPeng

This seems interesting! There are several questions that would determine what would the best way to build this document:

  1. Is this history only for two versions, or a full history of all previous versions?
  2. Is the history only for outputs? Or cells as well?
  3. What would you expect to be the result if outputs (or cells) are added/removed?
  4. Would you want to actually include the previous outputs in the document, or just have links to an historical version, like it is for the link you posted? Would that link point to the specific output only, or a historical version of the notebook itself?

You'll likely be able to reuse parts of nbdime for the solution either way, but the answers will probably change which parts needs to be customized.

vidartf avatar Aug 13 '18 11:08 vidartf

I think the motivation is to display the full-version of the current document and allow users to see the changes that have been made, a little like what MS Word shows the current version with the revisions marked to the side. The example I showed is from a R package and we do not have to follow their model. Let me try to answer your questions:

  1. I am mostly interested in the diffs between two versions. If I want diff further, I can pick a further revision and compare. This of course depends on if nbdime can diff two arbitrary versions.
  2. Should be both, but only the output if the input is the same.
  3. The removed cells could be inserted in a hidden state. The added cells can be displayed with special inserted mark.
  4. I would like to keep the entire output. I saw a version of the example with the full output, but perhaps they decided to get rid of it or added an option to include only the links because the size of the output?

So in the end I think I just want a variant of the side by side diff with the left side displayed in full and the right side folded appropriately.

BoPeng avatar Aug 15 '18 15:08 BoPeng

Thanks for the detailed feedback. Given the requirements as outlined, the existing backend (python) code would be sufficient. Only the frontend code would need modification. I would be curious to see how much of this would be possible with CSS only!

If you want to play around with the CSS on your own, that would be ideal. This does sound interesting, but I don't think I could prioritize it in the near term. If you need any DOM changes I could help out with that, or give feedback to any new CSS proposed. Let me know if you want to put some time into that!

vidartf avatar Aug 16 '18 13:08 vidartf

I plan to include such output as one of the SoS templates but this is also not urgent. I will have a look when I get back from JupyterCon and will let you know when I need help.

BoPeng avatar Aug 16 '18 14:08 BoPeng