Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Steps to compare notebooks in Workbench

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.)

like image 815
murray Avatar asked Jan 07 '12 23:01

murray


2 Answers

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

like image 81
Sjoerd C. de Vries Avatar answered Sep 21 '22 13:09

Sjoerd C. de Vries


(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?

like image 29
Szabolcs Avatar answered Sep 19 '22 13:09

Szabolcs