8

What, exactly, are the steps involved in using Wolfram Workbench (version 2) to compare two notebooks?

Please be explicit even in such things as what I do in order to open the two notebooks in Workbench.

(I find Workbench fiendishly difficult to use. Its built-in documentation is, I find, of limited value. The tutorial screencasts about it are just too rushed to be able to follow, even with stopping and starting. And there's still a confusion, at least for me, among various versions of sample files that are to accompany the tutorial.)

murray
  • 737
  • 2
  • 10
  • 28
  • I find it easy just to use http://www.quickdiff.com/ to compare notebooks. Copy the code from the notebooks, and paste it in the 2 windows, and click diff. – Nasser Jan 08 '12 at 01:02

2 Answers2

9

I have never used the workbench but when I fired it up I was comparing documents in minutes, so it can't be that hard.

The steps:

  1. Create a project using the File > New > New Project menu (EDIT: many project types will do I think. I have tried both the Application and the Basic Mathematica type)
  2. Add the two files to be compared to the project using import (in the File menu or the right mouse button context menu). EDIT: The best approach is probably using "General/File system". It will ask for a directory to import from. After that you may select the files you want to import from that directory.
  3. Select both files in the package explorer view
  4. Right mouse button > Compare with> Each other
  5. Compare editor fires up showing the two documents side by side

Mathematica graphics

Sjoerd C. de Vries
  • 16,122
  • 3
  • 42
  • 94
  • By "Project"I presume you mean a project of class Mathematica. But which type: Application Project, Basic Project, JLink Project? – murray Jan 08 '12 at 00:56
  • And what kind of Import source? The only choice under the category "Mathematia" is "Code from a File". But I don't want code, do I? I want two notebooks. How import? – murray Jan 08 '12 at 00:59
  • Just so as to try _something_, I selected the Mathematica Application Project and then, for Import, Mathematica > Code from a File. But I don't even see the notebook code in the Package Explorer -- just a comment saying what notebook the code was imported from. – murray Jan 08 '12 at 01:02
  • Aha, I think I see part of my problem. The notebooks I'm trying to compare are both style sheets. So I'm not seeing any code whatsoever. How might I see what differences such style sheets have (aside from manually going through all the types of cells, etc.)? – murray Jan 08 '12 at 01:05
  • @murray Small update, see above. Don't know much about stylefile structure. Would a simple file diff work, as suggested by Nasser? – Sjoerd C. de Vries Jan 08 '12 at 17:00
  • No, for style sheets as it turns out, neither the diff done in Workbench nor a straight file diff is of much use, since they both reveal syntactical differences in the underlying expressions rather than semantic differences in what those expressions do. Szabolcs's answer, to use NotebookTools`NotebookDiff is much more useful here. – murray Jan 08 '12 at 19:53
7

(Welcome to StackOverflow Murray, it's good to see you here!)

This is not a direct answer to your question, but I think you might find it useful to know that the << AuthorTools` package includes functionality for comparing notebooks. Evaluate the following to open the ("hidden") documentation:

NotebookOpen@
 FileNameJoin[{$InstallationDirectory, "AddOns", "Applications", 
   "AuthorTools", "Documentation", "English", "AuthorToolsGuide.nb"}];

Then you can compare them using CreateDocument@NotebookDiff[notebook1, notebook2], or perhaps using the somewhat more convenient

CreateDocument@NotebookDiff[SystemDialogInput["FileOpen"], SystemDialogInput["FileOpen"]]

which will let you select the files more easily.

Alternatively, you can open the two notebooks in the front end, and use this little control panel:

Dynamic@Column[
  {PopupMenu[Dynamic[nb1], 
    Thread[Notebooks[] -> NotebookTools`NotebookName /@ Notebooks[]]],
   PopupMenu[Dynamic[nb2], 
    Thread[Notebooks[] -> NotebookTools`NotebookName /@ Notebooks[]]],
   Button["Show differences", 
    CreateDocument@NotebookTools`NotebookDiff[nb1, nb2]]}
  ]

Mathematica graphics


It's interesting to mention that in Mathematica 8 there's some undocumented notebook-related functionality in the NotebookTools context, including a NotebookTools`NotebookDiff[] function.


Related question: Is it possible to invoke Mathematica's diff functionality from the command line?

Community
  • 1
  • 1
Szabolcs
  • 24,728
  • 9
  • 85
  • 174
  • That's just what I need. Now that I have the differences, it's going to be a bit of a challenge to dig through them: One of the style sheets begins by inheriting Core.nb, while the other begins by inheriting Default.nb. – murray Jan 08 '12 at 19:54
  • 1
    The documentation location is now different. This works in 10.4 NotebookOpen@ FileNameJoin[{$InstallationDirectory, "Documentation", "English", "Packages", "AuthorTools", "Documentation", "English", "Guides", "AuthorTools.nb"}] – gdelfino Jun 20 '16 at 15:52